fix: issues/498 (#499)
This commit is contained in:
		
							parent
							
								
									8f8aac05ef
								
							
						
					
					
						commit
						6d53ee7d12
					
				|  | @ -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_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_TYPE       | `openai`                       | The API type, options are `openai` or `azure`           | | ||||||
| | OPENAI_API_VERSION    | `2023-03-15-preview`           | Only applicable for Azure OpenAI                        | | | 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                             | | | 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_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   | | | DEFAULT_SYSTEM_PROMPT | [see here](utils/app/const.ts) | The default system prompt to use on new conversations   | | ||||||
|  |  | ||||||
|  | @ -13,3 +13,6 @@ export const OPENAI_API_VERSION = | ||||||
| 
 | 
 | ||||||
| export const OPENAI_ORGANIZATION = | export const OPENAI_ORGANIZATION = | ||||||
|   process.env.OPENAI_ORGANIZATION || ''; |   process.env.OPENAI_ORGANIZATION || ''; | ||||||
|  | 
 | ||||||
|  | export const AZURE_DEPLOYMENT_ID = | ||||||
|  |   process.env.AZURE_DEPLOYMENT_ID || ''; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import { Message } from '@/types/chat'; | import { Message } from '@/types/chat'; | ||||||
| import { OpenAIModel } from '@/types/openai'; | 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 { | import { | ||||||
|   ParsedEvent, |   ParsedEvent, | ||||||
|  | @ -31,7 +31,7 @@ export const OpenAIStream = async ( | ||||||
| ) => { | ) => { | ||||||
|   let url = `${OPENAI_API_HOST}/v1/chat/completions`; |   let url = `${OPENAI_API_HOST}/v1/chat/completions`; | ||||||
|   if (OPENAI_API_TYPE === 'azure') { |   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, { |   const res = await fetch(url, { | ||||||
|     headers: { |     headers: { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue