Skip to content

Commit 80f3189

Browse files
authored
Update language_models.md (#8250)
Added more clarity on how to initialize Azure OpenAI models. I also added tips on how to debug initializing external models. With these new changes, users can more easily get started and implement Azure Open AI models. Here are some clarifications I added: - I clearly added that the parameters names need to be saved as environment variables. If the user prefers to directly pass the parameters in the code, then I added an updated example. - I added that if users run into errors they should look at the LiteLLM documentation to confirm if the initialization protocol is correct.
1 parent a15c42c commit 80f3189

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/docs/learn/programming/language_models.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,16 @@ dspy.configure(lm=lm)
8686
```
8787

8888
=== "Other providers"
89-
In DSPy, you can use any of the dozens of [LLM providers supported by LiteLLM](https://docs.litellm.ai/docs/providers). Simply follow their instructions for which `{PROVIDER}_API_KEY` to set and how to write pass the `{provider_name}/{model_name}` to the constructor.
89+
In DSPy, you can use any of the dozens of [LLM providers supported by LiteLLM](https://docs.litellm.ai/docs/providers). Simply follow their instructions for which `{PROVIDER}_API_KEY` to set and how to write pass the `{provider_name}/{model_name}` to the constructor.
9090

9191
Some examples:
9292

9393
- `anyscale/mistralai/Mistral-7B-Instruct-v0.1`, with `ANYSCALE_API_KEY`
9494
- `together_ai/togethercomputer/llama-2-70b-chat`, with `TOGETHERAI_API_KEY`
9595
- `sagemaker/<your-endpoint-name>`, with `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION_NAME`
96-
- `azure/<your_deployment_name>`, with `AZURE_API_KEY`, `AZURE_API_BASE`, `AZURE_API_VERSION`, and the optional `AZURE_AD_TOKEN` and `AZURE_API_TYPE`
96+
- `azure/<your_deployment_name>`, with `AZURE_API_KEY`, `AZURE_API_BASE`, `AZURE_API_VERSION`, and the optional `AZURE_AD_TOKEN` and `AZURE_API_TYPE` as environment variables. If you are initiating external models without setting environment variables, use the following:
97+
`lm = dspy.LM('azure/<your_deployment_name>', api_key = 'AZURE_API_KEY' , api_base = 'AZURE_API_BASE', api_version = 'AZURE_API_VERSION')`
98+
9799

98100
99101
If your provider offers an OpenAI-compatible endpoint, just add an `openai/` prefix to your full model name.
@@ -103,6 +105,7 @@ dspy.configure(lm=lm)
103105
lm = dspy.LM('openai/your-model-name', api_key='PROVIDER_API_KEY', api_base='YOUR_PROVIDER_URL')
104106
dspy.configure(lm=lm)
105107
```
108+
If you run into errors, please refer to the [LiteLLM Docs](https://docs.litellm.ai/docs/providers) to verify if you are using the same variable names/following the right procedure.
106109

107110
## Calling the LM directly.
108111

0 commit comments

Comments
 (0)