diff --git a/README.md b/README.md index 436b59e..5b2ec7a 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ When deploying the application, the following environment variables can be set: | OPENAI_API_HOST | `https://api.openai.com` | The base url, for Azure use `https://.openai.azure.com` | | OPENAI_API_TYPE | `openai` | The API type, options are `openai` or `azure` | | OPENAI_API_VERSION | `2023-03-15-preview` | Only applicable for Azure OpenAI | +| AZURE_DEPLOYMENT_ID | | Needed when Azure OpenAI, Ref [Azure OpenAI API](https://learn.microsoft.com/zh-cn/azure/cognitive-services/openai/reference#completions) | | OPENAI_ORGANIZATION | | Your OpenAI organization ID | | DEFAULT_MODEL | `gpt-3.5-turbo` | The default model to use on new conversations, for Azure use `gpt-35-turbo` | | DEFAULT_SYSTEM_PROMPT | [see here](utils/app/const.ts) | The default system prompt to use on new conversations | diff --git a/utils/app/const.ts b/utils/app/const.ts index eca6deb..dfdde5e 100644 --- a/utils/app/const.ts +++ b/utils/app/const.ts @@ -13,3 +13,6 @@ export const OPENAI_API_VERSION = export const OPENAI_ORGANIZATION = process.env.OPENAI_ORGANIZATION || ''; + +export const AZURE_DEPLOYMENT_ID = + process.env.AZURE_DEPLOYMENT_ID || ''; diff --git a/utils/server/index.ts b/utils/server/index.ts index bfa5408..41c4bdc 100644 --- a/utils/server/index.ts +++ b/utils/server/index.ts @@ -1,7 +1,7 @@ import { Message } from '@/types/chat'; import { OpenAIModel } from '@/types/openai'; -import { OPENAI_API_HOST, OPENAI_API_TYPE, OPENAI_API_VERSION, OPENAI_ORGANIZATION } from '../app/const'; +import { AZURE_DEPLOYMENT_ID, OPENAI_API_HOST, OPENAI_API_TYPE, OPENAI_API_VERSION, OPENAI_ORGANIZATION } from '../app/const'; import { ParsedEvent, @@ -31,7 +31,7 @@ export const OpenAIStream = async ( ) => { let url = `${OPENAI_API_HOST}/v1/chat/completions`; if (OPENAI_API_TYPE === 'azure') { - url = `${OPENAI_API_HOST}/openai/deployments/${model.id}/chat/completions?api-version=${OPENAI_API_VERSION}`; + url = `${OPENAI_API_HOST}/openai/deployments/${AZURE_DEPLOYMENT_ID}/chat/completions?api-version=${OPENAI_API_VERSION}`; } const res = await fetch(url, { headers: {