1. Use Cases

In prefix completion, the user provides the desired prefix information to let the model complete the rest of the content based on the provided prefix information. With this capability, the model can better follow instructions and meet the specific format requirements of certain user scenarios.

2. Usage

In the request, add

extra_body={"prefix":"希望的前缀内容"}

3. Supported Model List

Currently, the above parameters are supported by large language models.

Note: The supported models may change, please refer to this document for the latest list of supported models.

4. Usage Examples

Below is an example using the OpenAI library for prefix completion:

client = OpenAI(
    api_key="您的 APIKEY", # 从https://cloud.siliconflow.cn/account/ak获取
    base_url="https://api.siliconflow.cn/v1"
)
 
messages = [
    {"role": "user", "content": "Please write quick sort code"},
]

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V2.5",
    messages=messages,
    extra_body={"prefix":"```python\n"}
)

print(response.choices[0].message.content)