fix: issues/498 (#499)

This commit is contained in:
牛强 2023-04-12 01:20:10 +08:00 committed by GitHub
parent 8f8aac05ef
commit 6d53ee7d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -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://<endpoint>.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 |

View File

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

View File

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