### Configuration Setup (.env) Source: https://docs.siliconflow.cn/llms-full.txt Configuration guide for setting up local project environments to connect to SiliconFlow services. ```APIDOC ## Configuration Setup ### Description Configure your local .env file to authenticate and point to the SiliconFlow API gateway. ### Configuration Fields - **LLM_API_KEY** (string) - Required - Your unique API key from https://cloud.siliconflow.cn/account/ak - **LLM_API_BASE** (string) - Required - Set to https://api.siliconflow.cn/v1 - **PRIMARY_MODEL** (string) - Required - The model to use (e.g., Qwen/Qwen3-14B) ### Example LLM_API_KEY=your_api_key_here LLM_API_BASE=https://api.siliconflow.cn/v1 PRIMARY_MODEL=Qwen/Qwen3-14B ``` -------------------------------- ### Function Calling Setup Source: https://docs.siliconflow.cn/api-reference/chat-completions/chat-completions Illustrates the initial setup for function calling in Python. This feature allows the model to intelligently select which function to call based on user input and provided function descriptions. The example shows how to define tools with function specifications. ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.siliconflow.cn/v1" ) tools = [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the ``` -------------------------------- ### WiseFlow Project Setup and Execution Source: https://docs.siliconflow.cn/llms-full.txt Commands to set up and run the WiseFlow project, including virtual environment activation, dependency synchronization, browser driver installation, and script execution. ```Bash cd wiseflow uv venv # 仅第一次执行需要 source .venv/bin/activate # Linux/macOS# #或者在 Windows 上: # .venv\Scripts\activate uv sync # 仅第一次执行需要 python -m playwright install --with-deps chromium # 仅第一次执行需要 chmod +x run.sh # 仅第一次执行需要 ./run.sh ``` -------------------------------- ### DB-GPT Setup and Dependencies Source: https://docs.siliconflow.cn/llms-full.txt This Bash script outlines the steps to set up DB-GPT, including cloning the repository, creating and activating a conda virtual environment, and installing necessary dependencies with proxy model support. ```bash git clone https://github.com/eosphoros-ai/DB-GPT.git cd DB-GPT conda create -n dbgpt_env python=3.10 conda activate dbgpt_env pip install -e ".[proxy]" ``` -------------------------------- ### Python Example: Using System Preset Voices with OpenAI Source: https://docs.siliconflow.cn/capabilities/text-to-speech A Python code snippet demonstrating how to use system preset voices with the OpenAI library. This example shows the necessary imports and basic setup for speech synthesis. ```python from pathlib import Path from openai import OpenAI speech_file_path = Path(__file__).parent / "speech.mp3" client = OpenAI() speech_file_path = Path(__file__).parent / "speech.mp3" response = client.audio.speech.create( model="tts-1", voice="alloy", input="Hello world" ) # הפלט הוא זרם אודיו response.stream_to_file(speech_file_path) ``` -------------------------------- ### Start MindSearch Frontend (Shell) Source: https://docs.siliconflow.cn/llms-full.txt This shell command shows how to start the frontend for the MindSearch application, using Gradio as an example. It assumes the backend is already running and configured to use SiliconFlow. This command is used to interact with the AI-powered search functionality. ```shell python frontend/mindsearch_gradio.py ``` -------------------------------- ### ComfyUI Prompt Assistant Installation Source: https://docs.siliconflow.cn/llms-full.txt Instructions for installing the ComfyUI Prompt Assistant extension, which leverages SiliconFlow's large model APIs for various prompt manipulation tasks. Installation can be done via the ComfyUI Manager, the Qiuye Launcher, or manually by cloning the repository. ```git git clone https://github.com/yawiii/comfyui_prompt_assistant.git ``` -------------------------------- ### Audio Understanding Examples Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision Example for transcribing audio content. ```APIDOC ## Audio Understanding Examples ### Audio Content Analysis Transcribes the content of an audio file. ```json { "role": "user", "content": [ { "type": "audio_url", "audio_url": { "url": "https://example.com/audio.mp3" } }, { "type": "text", "text": "Transcribe the content of this audio." } ] } ``` ``` -------------------------------- ### Streaming Output Example Source: https://docs.siliconflow.cn/faqs/stream-mode Example of how to handle streaming output from the LLM, including conditional logic for reasoning content. ```APIDOC ## Streaming Output Logic ### Description This section illustrates the Python code used to process and display streaming output from the LLM. It includes conditional logic to differentiate between reasoning content and other output, and handles potential errors during the process. ### Method N/A (Illustrative Code Snippet) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A #### Success Response (Illustrative) ```python # ... (previous code) if reasoning_content: print(reasoning_content, "end"="") full_reasoning_content += reasoning_content else: print(f"请求失败,状态码:{response.status_code}") # ... (subsequent code) ``` #### Response Example N/A ``` -------------------------------- ### Visual Understanding Examples Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision Examples demonstrating how to use the API for image analysis, comparing multiple images, and performing OCR on PDF documents. ```APIDOC ## Visual Understanding Examples ### Image Analysis Analyzes a single image and responds to a text prompt about it. ```json { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": "https://example.com/image.jpg", "detail": "high" } }, { "type": "text", "text": "Describe this image content." } ] } ``` ### Multi-Image Comparison Compares two images based on a text prompt. ```json { "role": "user", "content": [ { "type": "image_url", "image_url": {"url": "https://example.com/image1.jpg"} }, { "type": "image_url", "image_url": {"url": "https://example.com/image2.jpg"} }, { "type": "text", "text": "Compare the similarities and differences between these two images." } ] } ``` ### PDF OCR Performs OCR on a PDF document, supporting various prompt types for different extraction needs. ```json { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": "data:application/pdf;base64," + base64.b64encode( open("xxx.pdf", "rb").read()).decode("utf-8") } }, { "type": "text", "text": "\n<|grounding|>Convert the document to markdown. " } ] } ``` **Note**: DeepSeek-OCR supports prompts like `Convert the document to markdown.`, `OCR this image.`, `Free OCR.`, `Parse the figure.`, `Describe this image in detail.`, and `Locate <|ref|>specific text<|/ref|> in the image.` ``` -------------------------------- ### API Examples (cURL, Python, JavaScript) Source: https://docs.siliconflow.cn/api-reference/audio/create-speech Demonstrates how to interact with the SiliconFlow API using cURL, Python, and JavaScript. These examples cover common use cases and showcase the flexibility of the API. ```curl curl https://api.siliconflow.cn/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ \ "model": "siliconflow/silicon-llama-2-7b-chat", \ "messages": [{"role": "user", "content": "Hello!"}] \ }' ``` ```python from openai import OpenAI client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.siliconflow.cn/v1" ) completion = client.chat.completions.create( model="siliconflow/silicon-llama-2-7b-chat", messages=[ {"role": "user", "content": "Hello!"} ] ) print(completion.choices[0].message.content) ``` ```javascript import OpenAI from 'openai'; const openai = new OpenAI({ apiKey: 'YOUR_API_KEY', baseURL: 'https://api.siliconflow.cn/v1', }); async function main() { const completion = await openai.chat.completions.create({ model: 'siliconflow/silicon-llama-2-7b-chat', messages: [ { role: 'user', content: 'Hello!' }, ], }); console.log(completion.choices[0].message.content); } main(); ``` -------------------------------- ### Install wiseflow Dependencies Source: https://docs.siliconflow.cn/llms-full.txt Commands to install the uv package manager and clone the wiseflow source code repository. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh git clone https://github.com/TeamWiseFlow/wiseflow.git ``` -------------------------------- ### Image Analysis Example (JSON) Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision A JSON example demonstrating how to perform image analysis. It includes the role as 'user' and the content specifying the image analysis task. ```json { "role": "user", "content": "{\"image_url\": \"https://example.com/image.jpg\", \"detail\": \"high\"}" } ``` -------------------------------- ### Python Example for MOSS-TTSD-v0.5 Source: https://docs.siliconflow.cn/capabilities/text-to-speech This Python code snippet provides an example of using the MOSS-TTSD-v0.5 model for text-to-speech conversion. It shows how to set up the model and process audio streams. ```python # Example usage of MOSS-TTSD-v0.5 # This is a placeholder for the actual Python code. # The provided text only contains comments and partial structure. # Actual implementation would involve model loading and inference. # For example: # from moss_ttsd import MOSS_TTSD # model = MOSS_TTSD() # audio_data = model.synthesize(text='Your text here') # with open('output.wav', 'wb') as f: # f.write(audio_data) ``` -------------------------------- ### Starting DB-GPT Web Server Source: https://docs.siliconflow.cn/llms-full.txt This Bash command starts the DB-GPT web server on a specified port (5670). After execution, the DB-GPT application can be accessed via a web browser at http://127.0.0.1:5670/. ```bash dbgpt start webserver --port 5670 ``` -------------------------------- ### Get Weather Information Source: https://docs.siliconflow.cn/cn/userguide/guides/function-calling This example demonstrates how to use the WeatherAPI to fetch current weather information for a specified city. ```APIDOC ## Get Weather Information ### Description This function retrieves current weather data for a given city using the WeatherAPI. ### Method GET ### Endpoint `{base_url}/weather` ### Parameters #### Query Parameters - **key** (string) - Required - Your WeatherAPI key. - **q** (string) - Required - The city name for which to get weather information. ### Request Example ```python import requests # Assuming api_key and base_url are already configured # api_key = "您的WeatherAPI APIKEY" # base_url = "http://api.weatherapi.com/v1/current.json" def get_weather(city: str): params = { "key": api_key, "q": city } response = requests.get(base_url, params=params) return response.json() # Example usage: # weather_data = get_weather("London") # print(weather_data) ``` ### Response #### Success Response (200) - **location** (object) - Information about the location. - **current** (object) - Current weather conditions. #### Response Example ```json { "location": { "name": "London", "region": "City of London, Greater London", "country": "United Kingdom", "lat": 51.52, "lon": -0.11, "tz_id": "Europe/London", "localtime_epoch": 1678889400, "localtime": "2023-03-15 13:50" }, "current": { "temp_c": 10.0, "condition": { "text": "Partly cloudy", "icon": "//cdn.weatherapi.com/weather/64x64/day/116.png", "code": 1003 }, "wind_kph": 11.2, "humidity": 70, "feelslike_c": 8.0 } } ``` ``` -------------------------------- ### POST /v1/chat/completions (Prefix Completion) Source: https://docs.siliconflow.cn/llms-full.txt Guides the model's output by providing a starting prefix string to complete. ```APIDOC ## POST /v1/chat/completions ### Description Allows users to provide a specific prefix string that the model will use as the starting point for its generation, improving instruction following for specific formats. ### Method POST ### Endpoint https://api.siliconflow.cn/v1/chat/completions ### Parameters #### Request Body - **extra_body** (object) - Required - Contains the 'prefix' key with the desired starting content. ### Request Example { "model": "deepseek-ai/DeepSeek-V2.5", "messages": [{"role": "user", "content": "Complete the sentence."}], "extra_body": {"prefix": "The capital of France is"} } ``` -------------------------------- ### LLM API Parameter Configuration Examples (Bash) Source: https://docs.siliconflow.cn/llms-full.txt These examples demonstrate the configuration of key parameters for controlling LLM output creativity and reliability. It shows how to set the temperature for balancing creativity and predictability, and top_p for controlling the diversity of word selection. ```bash # 温度参数(0.0~2.0) temperature=0.5 # 平衡创造性与可靠性 # 核采样(top_p) top_p=0.9 # 仅考虑概率累积90%的词集 ``` -------------------------------- ### Define Qwen2.5-7B-Instruct System Prompt Source: https://docs.siliconflow.cn/guides/fine-tune An example of the system prompt configuration used for the Qwen2.5-7B-Instruct model prior to fine-tuning, demonstrating the input structure for the model. ```json Qwen2.5-7B-Instruct 系统Prompt ``` -------------------------------- ### Configure Completions API Request Source: https://docs.siliconflow.cn/features/fim A JSON payload example for the completions API, showing the inclusion of model, prompt, and suffix parameters to guide the generation process. ```json { "model": "model info", "prompt": "前缀内容", "suffix": "后缀内容" } ``` -------------------------------- ### Initialize SiliconFlow API Client Source: https://docs.siliconflow.cn/features/fim Demonstrates how to configure the base URL and create a completion request using the SiliconFlow API client. ```python base_url = "https://api.siliconflow.cn/v1" response = client.completions.create( model="deepseek-ai/DeepSeek-V2.5", prompt=f"""""", suffix=f"""""" ) ``` -------------------------------- ### SiliconFlow Config.yaml Example Source: https://docs.siliconflow.cn/llms-full.txt This YAML configuration is a complete example for `config.yaml` used by Continue. It defines multiple models from SiliconFlow, including their providers, model names, and API keys. It also includes settings for tab completion models and options. ```yaml name: Local Config version: 1.0.0 schema: v1 models: - name: Pro/zai-org/GLM-4.7 provider: siliconflow model: Pro/zai-org/GLM-4.7 apiKey: "您的_SILICONFLOW_API_KEY" - name: deepseek-ai/DeepSeek-V3.2 provider: siliconflow model: deepseek-ai/DeepSeek-V3.2 apiKey: "您的_SILICONFLOW_API_KEY" - name: Pro/deepseek-ai/DeepSeek-V3.2 provider: siliconflow model: Pro/deepseek-ai/DeepSeek-V3.2 apiKey: "您的_SILICONFLOW_API_KEY" - id: Qwen/Qwen3-Coder-480B-A35B-Instruct name: Qwen/Qwen3-Coder-480B-A35B-Instruct provider: siliconflow model: Qwen/Qwen3-Coder-480B-A35B-Instruct apiKey: "您的_SILICONFLOW_API_KEY" tabAutocompleteModel: id: Qwen/Qwen3-Coder-480B-A35B-Instruct provider: siliconflow tabAutocompleteOptions: debounceMs: 100 maxPrefixLines: 10 acceptSuggestionsBinding: ["tab", "right"] timeoutMs: 5000 ``` -------------------------------- ### Initiating and Monitoring Fine-tuning Source: https://docs.siliconflow.cn/guides/fine-tune Describes the process of starting the fine-tuning job and monitoring its progress until completion. ```text 1. Click 'Start Fine-tuning'. 2. Wait for the task to complete. 3. Obtain the model identifier. ``` -------------------------------- ### Function Calling for External API Integration Source: https://docs.siliconflow.cn/cn/userguide/guides/function-calling This example demonstrates how to use function calling with an LLM to interact with external APIs. It defines a function to get weather information and configures the LLM to call this function when needed. ```APIDOC ## POST /api/chat/completions (Example using Function Calling) ### Description This endpoint allows for chat completions with function calling capabilities. It enables the LLM to understand when to call external functions based on user prompts and process their results. ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **model** (string) - Required - The model to use for chat completions (e.g., "deepseek-ai/DeepSeek-V2.5"). - **messages** (array) - Required - A list of message objects representing the conversation history. - **role** (string) - Required - The role of the message sender ('user', 'assistant', 'tool'). - **content** (string) - Required - The content of the message. - **tool_call_id** (string) - Required (if role is 'tool') - The ID of the tool call being responded to. - **temperature** (number) - Optional - Controls the randomness of the output (e.g., 0.01). - **top_p** (number) - Optional - Controls nucleus sampling (e.g., 0.95). - **stream** (boolean) - Optional - Whether to stream the response (e.g., false). - **tools** (array) - Optional - A list of tools the model may call. - **type** (string) - Required - The type of tool ('function'). - **function** (object) - Required - The function definition. - **name** (string) - Required - The name of the function. - **description** (string) - Optional - A description of what the function does. - **parameters** (object) - Required - The parameters the function accepts. - **type** (string) - Required - The type of the parameters ('object'). - **properties** (object) - Required - An object defining the properties of the parameters. - **param_name** (object) - Required - Definition of a specific parameter. - **type** (string) - Required - The data type of the parameter (e.g., 'string', 'integer'). - **description** (string) - Optional - A description of the parameter. - **required** (array) - Optional - A list of parameter names that are required. ### Request Example ```json { "model": "deepseek-ai/DeepSeek-V2.5", "messages": [ {"role": "user", "content": "how is the weather today in beijing?"} ], "temperature": 0.01, "top_p": 0.95, "stream": false, "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a given city.", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "The name of the city to query weather for." } }, "required": ["city"] } } } ] } ``` ### Response #### Success Response (200) - **message** (object) - The assistant's message, which may include a tool call. - **role** (string) - The role of the sender ('assistant'). - **tool_calls** (array) - A list of tool calls requested by the model. - **id** (string) - The ID of the tool call. - **type** (string) - The type of tool call ('function'). - **function** (object) - The function to call. - **name** (string) - The name of the function. - **arguments** (string) - JSON string representing the arguments for the function. #### Response Example (First Turn - Tool Call) ```json { "id": "chatcmpl-xxxxxxxxxxxxxxxxx", "object": "chat.completion", "created": 1700000000, "model": "deepseek-ai/DeepSeek-V2.5", "choices": [ { "index": 0, "message": { "role": "assistant", "tool_calls": [ { "id": "call_xxxxxxxxxxxxxxxxx", "type": "function", "function": { "name": "get_weather", "arguments": "{\"city\": \"beijing\"}" } } ] }, "finish_reason": "tool_calls" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` #### Success Response (200) - After Tool Execution - **content** (string) - The final response from the assistant after processing the tool's output. #### Response Example (Second Turn - Final Answer) ```json { "id": "chatcmpl-yyyyyyyyyyyyy", "object": "chat.completion", "created": 1700000001, "model": "deepseek-ai/DeepSeek-V2.5", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The weather in Beijing today is sunny with a temperature of 21.4°C." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 30, "completion_tokens": 20, "total_tokens": 50 } } ``` ### Error Handling - **400 Bad Request**: Invalid request payload or parameters. - **401 Unauthorized**: Invalid API key. - **404 Not Found**: Model or resource not found. - **500 Internal Server Error**: Server-side error. ``` -------------------------------- ### cURL Chat Completion with Function Calling Source: https://docs.siliconflow.cn/cn/api-reference/chat-completions/chat-completions Shows how to make a chat completion request using cURL, including the definition of a function for getting current weather. This example is useful for testing API endpoints directly. ```curl curl --location 'https://api.siliconflow.cn/v1/chat/completions' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --data '{ "model": "Pro/zai-org/GLM-4.7", "messages": [ { "role": "user", "content": "What is the weather like in Boston today?" } ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } } ], "tool_choice": "auto" }' ``` -------------------------------- ### Initialize and Configure SiliconFlow SDK Source: https://docs.siliconflow.cn/cn/userguide/rate-limits/rate-limit-and-upgradation This snippet demonstrates how to initialize the SiliconFlow SDK with necessary configurations such as API keys and domain settings. It sets up the client for interacting with SiliconFlow services. ```javascript const siliconflow = require('siliconflow'); siliconflow.init({ apiKey: 'YOUR_API_KEY', domain: 'https://api.siliconflow.cn' }); console.log('SiliconFlow SDK initialized.'); ``` -------------------------------- ### Configure PaddleOCR-VL with SiliconFlow Cloud API Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision This example shows how to configure the PaddleOCR-VL pipeline to use the SiliconFlow cloud API. It includes settings for the recognition backend, server URL, model name, and API key for authentication. This setup is suitable for cloud-based deployments. ```python pipeline = PaddleOCRVL( vl_rec_backend="vllm-server", vl_rec_server_url="https://api.siliconflow.cn/v1", vl_rec_api_model_name="PaddlePaddle/PaddleOCR-VL", vl_rec_api_key="xxxxxx", ) ``` -------------------------------- ### Configuration File Example Source: https://docs.siliconflow.cn/llms-full.txt This snippet shows how to configure the translation service to use SiliconFlow's API. It includes setting the API endpoint, the desired model, and the API key. It also demonstrates thread pool configuration for API calls. ```properties #translate.service.leimingyun.domain=http://api.translate.zvo.cn translate.service.openai.url=https://api.siliconflow.cn/v1/chat/completions translate.service.openai.model=Qwen/Qwen3-32B translate.service.openai.key=sk-kqpnpfhlikgacrmdab2946d28eb00ede7acd9b3axfiIadf4P81 translate.service.thread.number=100 ``` -------------------------------- ### LLM API Chat Completion for Data Analysis (Python) Source: https://docs.siliconflow.cn/llms-full.txt This Python example illustrates how to perform data analysis using the chat completion API. It includes setting a system role to guide the model's persona and output format (Markdown), and a user prompt for analyzing sales data. ```python from openai import OpenAI client = OpenAI(api_key="YOUR_KEY", base_url="https://api.siliconflow.cn/v1") response = client.chat.completions.create( model="Qwen/QVQ-72B-Preview", messages=[ {"role": "system", "content": "你是数据分析专家,用Markdown输出结果"}, {"role": "user", "content": "分析2023年新能源汽车销售数据趋势" }], temperature=0.7, max_tokens=4096 ) ``` -------------------------------- ### Initialize and Configure SiliconFlow SDK Source: https://docs.siliconflow.cn/guides/fine-tune This JavaScript snippet demonstrates how to initialize and configure the SiliconFlow SDK. It sets up the application ID, auto-boot behavior, and user authentication. It also configures the subdomain and Git source for the project. ```javascript let a = {}; let b = "en"; let c = []; let d = "data-banner-state"; let e = "bannerDismissed"; try { let f = window.location.pathname.split("/").filter(a => a !== "" && "global" !== a).slice(0, 2); let g = f.find(a => c.includes(a)); let h = []; g ? h.push(g) : h.push(b); h.push("global"); let i = h; let j = i.find(a => a); let k = a[j]; if (k?.content) { f = k.content; g = j; } } catch (err) { console.error(err); f = undefined; g = undefined; } if (!f) { document.documentElement.setAttribute(d, "hidden"); } let l = true; let m = 0; while (m < localStorage.length) { let n = localStorage.key(m); m++; if (!n?.endsWith(e)) continue; let o = localStorage.getItem(n); if (o && o === f) { l = false; break; } if (g && (n.startsWith(`lang:${g}_`) || !n.startsWith("lang:"))) { localStorage.removeItem(n); m--; } } document.documentElement.setAttribute(d, l ? "visible" : "hidden"); ``` -------------------------------- ### GET /videos/get_videos_status Source: https://docs.siliconflow.cn/api-reference/models/get-model-list Get the status of a video processing job. ```APIDOC ## GET /videos/get_videos_status ### Description Get the status of a video processing job. ### Method GET ### Endpoint /videos/get_videos_status ### Parameters #### Query Parameters - **job_id** (string) - Required - The ID of the video processing job. ### Request Example ```json { "example": "GET /videos/get_videos_status?job_id=job-abc123" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the job (e.g., `processing`, `completed`, `failed`). - **result_url** (string) - Optional - The URL to the processed video if the job is completed. #### Response Example ```json { "status": "completed", "result_url": "http://example.com/processed_video.mp4" } ``` ``` -------------------------------- ### Configure LLM Parameters and Process Prompts Source: https://docs.siliconflow.cn/features/function_calling This snippet demonstrates how to set up API parameters like top_p and stream, and how to iterate over a list of prompts to extract content from the API response. ```python top_p=0.95, stream=False, tools=tools) return response.choices[0].message.content prompts = [ "用中文回答:strawberry中有多少个r?", "用中文回答:9.11和9.9,哪个小?" ] for prompt in prompts: print(prompt) ``` -------------------------------- ### DeepSeek-OCR Prompt Examples Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision Examples of prompts that can be used with DeepSeek-OCR for various OCR-related tasks. ```APIDOC ### Prompt Examples for DeepSeek-OCR DeepSeek-OCR supports various prompts for different scenarios: - **Document to Markdown:** ` <|grounding|> Convert the document to markdown.` - **General OCR:** ` <|grounding|> OCR this image.` - **Layout-Free Extraction:** ` Free OCR.` - **Chart Parsing:** ` Parse the figure.` ``` -------------------------------- ### Qwen2.5-7B-Instruct Prompt Example Source: https://docs.siliconflow.cn/guides/fine-tune This snippet shows a basic prompt for the Qwen2.5-7B-Instruct model, specifically for a 'Zhi Shuo Xin Yu' (智说新语) fine-tuned version. It sets a system-level instruction for the model's persona. ```json { "prompt": "你是智说新语生成器" } ``` -------------------------------- ### Get Reference Audio List - API Source: https://docs.siliconflow.cn/api-reference/models/get-model-list Retrieves a list of all available reference audio files. This is a GET request. ```api GET /cn/api-reference/audio/voice-list ``` -------------------------------- ### LLM Prompting and Output Example Source: https://docs.siliconflow.cn/cn/userguide/guides/function-calling This example shows a typical interaction with an LLM. It defines a prompt for weather information in Beijing and then simulates the expected LLM output. This is useful for understanding prompt engineering and response formats. ```shellscript The weather in Beijing today is sunny with a temperature of 21.4°C. ``` -------------------------------- ### Initialize OpenAI Client for SiliconFlow Source: https://docs.siliconflow.cn/guides/fine-tune This snippet shows how to instantiate the OpenAI client with a custom base URL pointing to SiliconFlow and how to structure a message list for chat completion requests. ```python import OpenAI client = OpenAI( api_key="您的 APIKEY", # 从https://cloud.siliconflow.cn/account/ak获取 base_url="https://api.siliconflow.cn/v1" ) messages = [ {"role": "user", "content": "用当前语言解释微调模型流程"}, ] ``` -------------------------------- ### Usage Example: Visual Understanding Source: https://docs.siliconflow.cn/cn/userguide/capabilities/vision Provides an example of how to use the API for image analysis within a visual understanding context. ```APIDOC ## Usage Example: Visual Understanding ### Image Analysis ```json { "role": "user", "content": "Analyze this image.", "image_url": { "url": "https://example.com/image.jpg" } } ``` ``` -------------------------------- ### Start MindSearch Backend with SiliconFlow API Key (Shell) Source: https://docs.siliconflow.cn/llms-full.txt This shell command demonstrates how to start the MindSearch backend, specifying the use of SiliconFlow's API. It sets the SILICON_API_KEY environment variable to your copied API key and then launches the MindSearch application with a specified model format and search engine. ```shell # 指定硅基流动的 API Key export SILICON_API_KEY=上面流程中复制的密钥 # 启动 python -m mindsearch.app --lang en --model_format internlm_silicon --search_engine DuckDuckGoSearch ``` -------------------------------- ### Install OpenAI Python Library Source: https://docs.siliconflow.cn/llms-full.txt Installs the necessary OpenAI Python client library to enable communication with the SiliconFlow API. ```shell pip install --upgrade openai ``` -------------------------------- ### Model Output Comparison: Qwen2.5-7B-Instruct vs. Fine-tuned Source: https://docs.siliconflow.cn/guides/fine-tune This table compares the output of the base Qwen2.5-7B-Instruct model against its fine-tuned version for various inputs. It highlights differences in nuance, tone, and adherence to specific linguistic styles. ```markdown | 输入 | Qwen2.5-7B-Instruct 模型 | Qwen2.5-7B-Instruct 微调模型 | |---|---|---| | 五道口 | VLG,不过是知识的轻轨与资本的交汇站,文青与土豪在此擦肩而过,孰是求知的信徒,孰是逐利的信徒,全凭幸存者的微笑。 | 知识的殿堂与商业的洪流交织,学人的笔记与商人的谈资齐飞,地名犹在,荣光已非。 | | 新时代 | claimed to break旧 mold yet still clings to the stirring rhetoric of progress, like a fashion plate who ignores the evolution of fashion。 | 新时代的号角已吹响,然砥砺前行时,方显初心易失之难。 | | 创新 | 看似凤凰涅槃的奇迹,实则多数人不过是换汤不换药的换皮游戏。 | 标新立异本是勇气的象征,却在同质化的社会中成了猎奇的代名词。 | | 降维打击 | 所谓降维打击,实则是现代文明中的一种高级愚民术,用高深莫测的科技iscard,让普通人以为自己正生活在理性与进步之中,却不知已在智力与道德的低维空间中遭受碾压。。 | 高维智慧轻而易举地碾压低维凡尘,却不知低维众生早已习于在自己的平庸中寻觅慰藉,哪里还懂得高维打击的意义。 | ```