forked from phoenix/litellm-mirror
docs(prefix.md): add prefix support to docs
This commit is contained in:
parent
d5abcb0945
commit
0ea056971c
6 changed files with 121 additions and 4 deletions
119
docs/my-website/docs/completion/prefix.md
Normal file
119
docs/my-website/docs/completion/prefix.md
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
# Pre-fix Assistant Messages
|
||||||
|
|
||||||
|
Supported by:
|
||||||
|
- Deepseek
|
||||||
|
- Mistral
|
||||||
|
- Anthropic
|
||||||
|
|
||||||
|
```python
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "..",
|
||||||
|
...
|
||||||
|
"prefix": true # 👈 KEY CHANGE
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value="sdk" label="SDK">
|
||||||
|
|
||||||
|
```python
|
||||||
|
from litellm import completion
|
||||||
|
import os
|
||||||
|
|
||||||
|
os.environ["DEEPSEEK_API_KEY"] = ""
|
||||||
|
|
||||||
|
response = completion(
|
||||||
|
model="deepseek/deepseek-chat",
|
||||||
|
messages=[
|
||||||
|
{"role": "user", "content": "Who won the world cup in 2022?"},
|
||||||
|
{"role": "assistant", "content": "Argentina", "prefix": True}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
print(response.choices[0].message.content)
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="proxy" label="PROXY">
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://0.0.0.0:4000/v1/chat/completions \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer $LITELLM_KEY" \
|
||||||
|
-d '{
|
||||||
|
"model": "deepseek/deepseek-chat",
|
||||||
|
"messages": [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": "Who won the world cup in 2022?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"role": "assistant",
|
||||||
|
"content": "Argentina", "prefix": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
|
**Expected Response**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
{
|
||||||
|
"id": "3b66124d79a708e10c603496b363574c",
|
||||||
|
"choices": [
|
||||||
|
{
|
||||||
|
"finish_reason": "stop",
|
||||||
|
"index": 0,
|
||||||
|
"message": {
|
||||||
|
"content": " won the FIFA World Cup in 2022.",
|
||||||
|
"role": "assistant",
|
||||||
|
"tool_calls": null,
|
||||||
|
"function_call": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"created": 1723323084,
|
||||||
|
"model": "deepseek/deepseek-chat",
|
||||||
|
"object": "chat.completion",
|
||||||
|
"system_fingerprint": "fp_7e0991cad4",
|
||||||
|
"usage": {
|
||||||
|
"completion_tokens": 12,
|
||||||
|
"prompt_tokens": 16,
|
||||||
|
"total_tokens": 28,
|
||||||
|
},
|
||||||
|
"service_tier": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check Model Support
|
||||||
|
|
||||||
|
Call `litellm.get_model_info` to check if a model/provider supports `response_format`.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<TabItem value="sdk" label="SDK">
|
||||||
|
|
||||||
|
```python
|
||||||
|
from litellm import get_model_info
|
||||||
|
|
||||||
|
params = get_model_info(model="deepseek/deepseek-chat")
|
||||||
|
|
||||||
|
assert params["supports_assistant_prefill"] is True
|
||||||
|
```
|
||||||
|
|
||||||
|
</TabItem>
|
||||||
|
<TabItem value="proxy" label="PROXY">
|
||||||
|
|
||||||
|
Call the `/model/info` endpoint to get a list of models + their supported params.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X GET 'http://0.0.0.0:4000/v1/model/info' \
|
||||||
|
-H 'Authorization: Bearer $LITELLM_KEY' \
|
||||||
|
```
|
||||||
|
</TabItem>
|
||||||
|
</Tabs>
|
|
@ -162,6 +162,7 @@ const sidebars = {
|
||||||
"completion/input",
|
"completion/input",
|
||||||
"completion/provider_specific_params",
|
"completion/provider_specific_params",
|
||||||
"completion/json_mode",
|
"completion/json_mode",
|
||||||
|
"completion/prefix",
|
||||||
"completion/drop_params",
|
"completion/drop_params",
|
||||||
"completion/prompt_formatting",
|
"completion/prompt_formatting",
|
||||||
"completion/output",
|
"completion/output",
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4585,7 +4585,7 @@ def get_llm_provider(
|
||||||
api_base = (
|
api_base = (
|
||||||
api_base
|
api_base
|
||||||
or get_secret("DEEPSEEK_API_BASE")
|
or get_secret("DEEPSEEK_API_BASE")
|
||||||
or "https://api.deepseek.com/v1"
|
or "https://api.deepseek.com/beta"
|
||||||
) # type: ignore
|
) # type: ignore
|
||||||
dynamic_api_key = api_key or get_secret("DEEPSEEK_API_KEY")
|
dynamic_api_key = api_key or get_secret("DEEPSEEK_API_KEY")
|
||||||
elif custom_llm_provider == "fireworks_ai":
|
elif custom_llm_provider == "fireworks_ai":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue