Skip to main content

llama-index llms siliconflow integration

Project description

LlamaIndex Llms Integration: SiliconFlow

1. Product Introduction

SiliconCloud provides cost-effective GenAI services based on an excellent open-source foundation model. introduction: https://docs.siliconflow.cn/introduction

2. Product features

  • As a one-stop cloud service platform that integrates top large models, SiliconCloud is committed to providing developers with faster, cheaper, more comprehensive, and smoother model APIs.

    • SiliconCloud has been listed on Qwen2.5-72B, DeepSeek-V2.5, Qwen2, InternLM2.5-20B-Chat, BCE, BGE, SenseVoice-Small, Llama-3.1, FLUX.1, DeepSeek-Coder-V2, SD3 Medium, GLM-4-9B-Chat, A variety of open-source large language models, image generation models, code generation models, vector and reordering models, and multimodal large models, including InstantID.

    • Among them, Qwen 2.5 (7B), Llama 3.1 (8B) and other large model APIs are free to use, so that developers and product managers do not need to worry about the computing power costs caused by the R&D stage and large-scale promotion, and realize "token freedom".

  • Provide out-of-the-box large model inference acceleration services to bring a more efficient user experience to your GenAI applications.

3. Installation

pip install llama-index-llms-siliconflow

4. Usage

Complete/Chat

import asyncio
import os
from llama_index.core.llms import ChatMessage
from llama_index.llms.siliconflow import SiliconFlow

llm = SiliconFlow(
    api_key=os.getenv("SILICONFLOW_API_KEY"),
)

response = llm.complete("...")
print(response)

response = asyncio.run(llm.acomplete("..."))
print(response)

messages = [ChatMessage(role="user", content="...")]

response = llm.chat(messages)
print(response)

response = asyncio.run(llm.achat(messages))
print(response)

Function Calling

from llama_index.llms.siliconflow import SiliconFlow

llm = SiliconFlow(
    api_key=os.getenv("SILICONFLOW_API_KEY"),
)
tools = [
    {
        "type": "function",
        "function": {
            "name": "add",
            "description": "Compute the sum of two numbers",
            "parameters": {
                "type": "object",
                "properties": {
                    "a": {
                        "type": "int",
                        "description": "A number",
                    },
                    "b": {
                        "type": "int",
                        "description": "A number",
                    },
                },
                "required": ["a", "b"],
            },
        },
    },
    ...,
]
response = llm.complete("...", tools=tools)
print(llm.get_tool_calls_from_response(response))

# output
# [ToolSelection(tool_id='...', tool_name='add', tool_kwargs={'a': x, 'b': x})]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_llms_siliconflow-0.5.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_siliconflow-0.5.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_siliconflow-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_siliconflow-0.5.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_siliconflow-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0bfb839d60d9f5a0ef287be164f28487baab6f9fd1f845cd012ab801692024d7
MD5 6fbfa65766685e8ef91b976e53a0cd6a
BLAKE2b-256 58b450253d4164b0080d8c3577b0a59529c96e27fa895c73ea7788db9a181c07

See more details on using hashes here.

File details

Details for the file llama_index_llms_siliconflow-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_siliconflow-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_llms_siliconflow-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 572049166b944949ff0bd0ba53690346c9a2207e8e0c14f34d55e42df6c7f8f7
MD5 b70001e47ec8747aded92cb071e2dd27
BLAKE2b-256 39426b20dfb754bca4bbd02f346a5ab7a43595505557902a1f829144d36df0a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page