adding model alias mapping to docs
This commit is contained in:
parent
442b3e43a5
commit
8015dc2927
@ -1,4 +1,4 @@
|
||||
# Input Format - completion()
|
||||
# Input Format
|
||||
The Input params are **exactly the same** as the
|
||||
<a href="https://platform.openai.com/docs/api-reference/chat/create" target="_blank" rel="noopener noreferrer">OpenAI Create chat completion</a>, and let you call Azure OpenAI, Anthropic, Cohere, Replicate, OpenRouter models in the same format.
|
||||
|
||||
|
||||
49
docs/my-website/docs/completion/model_alias.md
Normal file
49
docs/my-website/docs/completion/model_alias.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Model Alias
|
||||
|
||||
Model names can be long, and you might want to use more user-friendly names for your end-users - e.g. Calling it `GPT-3.5` when the model name is `gpt-3.5-turbo-16k`.
|
||||
|
||||
LiteLLM supports this by letting you pass in a model alias mapping.
|
||||
|
||||
# usage
|
||||
|
||||
### Relevant Code
|
||||
```
|
||||
model_alias_map = {
|
||||
"GPT-3.5": "gpt-3.5-turbo-16k",
|
||||
"llama2": "replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf"
|
||||
}
|
||||
|
||||
litellm.model_alias_map = model_alias_map
|
||||
```
|
||||
|
||||
### Complete Code
|
||||
```
|
||||
import litellm
|
||||
from litellm import completion
|
||||
|
||||
|
||||
## set ENV variables
|
||||
os.environ["OPENAI_API_KEY"] = "openai key"
|
||||
os.environ["REPLICATE_API_KEY"] = "cohere key"
|
||||
|
||||
## set model alias map
|
||||
model_alias_map = {
|
||||
"GPT-3.5": "gpt-3.5-turbo-16k",
|
||||
"llama2": "replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf"
|
||||
}
|
||||
|
||||
litellm.model_alias_map = model_alias_map
|
||||
|
||||
messages = [{ "content": "Hello, how are you?","role": "user"}]
|
||||
|
||||
# openai call
|
||||
response = completion(model="GPT-3.5", messages=messages)
|
||||
|
||||
# replicate call
|
||||
response = completion("llama2", messages)
|
||||
```
|
||||
|
||||
|
||||
# no-code
|
||||
|
||||
If you use litellm client, you can also do this without going into code. [Learn more]("https://docs.litellm.ai/docs/debugging/hosted_debugging")
|
||||
@ -1,4 +1,4 @@
|
||||
# Output Format - completion()
|
||||
# Output Format
|
||||
Here's the exact json output and type you can expect from all litellm `completion` calls for all models
|
||||
|
||||
```python
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# Reliability for completion()
|
||||
# Reliability
|
||||
|
||||
LiteLLM supports the following functions for reliability:
|
||||
* `completion_with_retries`: use tenacity retries
|
||||
|
||||
@ -22,7 +22,7 @@ const sidebars = {
|
||||
{
|
||||
type: "category",
|
||||
label: "Completion()",
|
||||
items: ["completion/input", "completion/output", "completion/reliable_completions", "completion/stream"],
|
||||
items: ["completion/input", "completion/output", "completion/model_alias", "completion/reliable_completions", "completion/stream"],
|
||||
},
|
||||
{
|
||||
type: "category",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user