Skip to content

Commit 1efac6a

Browse files
authored
feat(llm - embed): Add support for Azure OpenAI (#1698)
* Add support for Azure OpenAI * fix: wrong default api_version Should be dashes instead of underscores. see: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference * fix: code styling applied "make check" changes * refactor: extend documentation * mention azopenai as available option and extras * add recommended section * include settings-azopenai.yaml configuration file * fix: documentation
1 parent 258d02d commit 1efac6a

File tree

9 files changed

+415
-6
lines changed

9 files changed

+415
-6
lines changed

fern/docs/pages/installation/installation.mdx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pyenv local 3.11
3030
PrivateGPT allows to customize the setup -from fully local to cloud based- by deciding the modules to use.
3131
Here are the different options available:
3232

33-
- LLM: "llama-cpp", "ollama", "sagemaker", "openai", "openailike"
34-
- Embeddings: "huggingface", "openai", "sagemaker"
33+
- LLM: "llama-cpp", "ollama", "sagemaker", "openai", "openailike", "azopenai"
34+
- Embeddings: "huggingface", "openai", "sagemaker", "azopenai"
3535
- Vector stores: "qdrant", "chroma", "postgres"
3636
- UI: whether or not to enable UI (Gradio) or just go with the API
3737

@@ -49,10 +49,12 @@ Where `<extra>` can be any of the following:
4949
- llms-sagemaker: adds support for Amazon Sagemaker LLM, requires Sagemaker inference endpoints
5050
- llms-openai: adds support for OpenAI LLM, requires OpenAI API key
5151
- llms-openai-like: adds support for 3rd party LLM providers that are compatible with OpenAI's API
52+
- llms-azopenai: adds support for Azure OpenAI LLM, requires Azure OpenAI inference endpoints
5253
- embeddings-ollama: adds support for Ollama Embeddings, requires Ollama running locally
5354
- embeddings-huggingface: adds support for local Embeddings using HuggingFace
5455
- embeddings-sagemaker: adds support for Amazon Sagemaker Embeddings, requires Sagemaker inference endpoints
5556
- embeddings-openai = adds support for OpenAI Embeddings, requires OpenAI API key
57+
- embeddings-azopenai = adds support for Azure OpenAI Embeddings, requires Azure OpenAI inference endpoints
5658
- vector-stores-qdrant: adds support for Qdrant vector store
5759
- vector-stores-chroma: adds support for Chroma DB vector store
5860
- vector-stores-postgres: adds support for Postgres vector store
@@ -160,6 +162,29 @@ PrivateGPT will use the already existing `settings-openai.yaml` settings file, w
160162

161163
The UI will be available at http://localhost:8001
162164

165+
### Non-Private, Azure OpenAI-powered test setup
166+
167+
If you want to test PrivateGPT with Azure OpenAI's LLM and Embeddings -taking into account your data is going to Azure OpenAI!- you can run the following command:
168+
169+
You need to have access to Azure OpenAI inference endpoints for the LLM and / or the embeddings, and have Azure OpenAI credentials properly configured.
170+
171+
Edit the `settings-azopenai.yaml` file to include the correct Azure OpenAI endpoints.
172+
173+
Then, install PrivateGPT with the following command:
174+
```bash
175+
poetry install --extras "ui llms-azopenai embeddings-azopenai vector-stores-qdrant"
176+
```
177+
178+
Once installed, you can run PrivateGPT.
179+
180+
```bash
181+
PGPT_PROFILES=azopenai make run
182+
```
183+
184+
PrivateGPT will use the already existing `settings-azopenai.yaml` settings file, which is already configured to use Azure OpenAI LLM and Embeddings endpoints, and Qdrant.
185+
186+
The UI will be available at http://localhost:8001
187+
163188
### Local, Llama-CPP powered setup
164189

165190
If you want to run PrivateGPT fully locally without relying on Ollama, you can run the following command:

fern/docs/pages/manual/llms.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,43 @@ to run an OpenAI compatible server. Then, you can run PrivateGPT using the `sett
9898

9999
`PGPT_PROFILES=vllm make run`
100100

101+
### Using Azure OpenAI
102+
103+
If you cannot run a local model (because you don't have a GPU, for example) or for testing purposes, you may
104+
decide to run PrivateGPT using Azure OpenAI as the LLM and Embeddings model.
105+
106+
In order to do so, create a profile `settings-azopenai.yaml` with the following contents:
107+
108+
```yaml
109+
llm:
110+
mode: azopenai
111+
112+
embedding:
113+
mode: azopenai
114+
115+
azopenai:
116+
api_key: <your_azopenai_api_key> # You could skip this configuration and use the AZ_OPENAI_API_KEY env var instead
117+
azure_endpoint: <your_azopenai_endpoint> # You could skip this configuration and use the AZ_OPENAI_ENDPOINT env var instead
118+
api_version: <api_version> # The API version to use. Default is "2023_05_15"
119+
embedding_deployment_name: <your_embedding_deployment_name> # You could skip this configuration and use the AZ_OPENAI_EMBEDDING_DEPLOYMENT_NAME env var instead
120+
embedding_model: <openai_embeddings_to_use> # Optional model to use. Default is "text-embedding-ada-002"
121+
llm_deployment_name: <your_model_deployment_name> # You could skip this configuration and use the AZ_OPENAI_LLM_DEPLOYMENT_NAME env var instead
122+
llm_model: <openai_model_to_use> # Optional model to use. Default is "gpt-35-turbo"
123+
```
124+
125+
And run PrivateGPT loading that profile you just created:
126+
127+
`PGPT_PROFILES=azopenai make run`
128+
129+
or
130+
131+
`PGPT_PROFILES=azopenai poetry run python -m private_gpt`
132+
133+
When the server is started it will print a log *Application startup complete*.
134+
Navigate to http://localhost:8001 to use the Gradio UI or to http://localhost:8001/docs (API section) to try the API.
135+
You'll notice the speed and quality of response is higher, given you are using Azure OpenAI's servers for the heavy
136+
computations.
137+
101138
### Using AWS Sagemaker
102139

103140
For a fully private & performant setup, you can choose to have both your LLM and Embeddings model deployed using Sagemaker.

0 commit comments

Comments
 (0)