adding model alias mapping to docs

This commit is contained in:
Krrish Dholakia 2023-08-30 07:59:42 -07:00
parent 442b3e43a5
commit 8015dc2927
5 changed files with 53 additions and 4 deletions

View File

@ -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.

View 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")

View File

@ -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

View File

@ -1,4 +1,4 @@
# Reliability for completion()
# Reliability
LiteLLM supports the following functions for reliability:
* `completion_with_retries`: use tenacity retries

View File

@ -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",