Skip to content

Commit

Permalink
✨ feat: support latest openai model (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Nov 7, 2023
1 parent b092596 commit 46386dc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"modern-screenshot": "^4",
"nanoid": "^5",
"next": "^13.5.3",
"openai": "^4.10.0",
"openai": "~4.15.0",
"polished": "^4",
"posthog-js": "^1",
"query-string": "^8",
Expand Down
9 changes: 3 additions & 6 deletions src/const/llm.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { LanguageModel } from '@/types/llm';

/**
* A white list of language models that are allowed to display and be used in the app.
*/
Expand All @@ -9,9 +11,4 @@ export const LanguageModelWhiteList = [
'gpt-4-32k',
];

export const DEFAULT_OPENAI_MODEL_LIST = [
'gpt-3.5-turbo',
'gpt-3.5-turbo-16k',
'gpt-4',
'gpt-4-32k',
];
export const DEFAULT_OPENAI_MODEL_LIST: string[] = Object.values(LanguageModel);
8 changes: 6 additions & 2 deletions src/const/modelTokens.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { LanguageModel } from '@/types/llm';

// refs to: https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo
export const ModelTokens: Record<LanguageModel, number> = {
[LanguageModel.GPT3_5]: 4096,
[LanguageModel.GPT3_5_16K]: 4096 * 4,
[LanguageModel.GPT3_5_1106]: 16_385,
[LanguageModel.GPT3_5_16K]: 16_385,
[LanguageModel.GPT4]: 8196,
[LanguageModel.GPT4_32K]: 8196 * 4,
[LanguageModel.GPT4_PREVIEW]: 128_000,
[LanguageModel.GPT4_VISION_PREVIEW]: 128_000,
[LanguageModel.GPT4_32K]: 32_768,
};
3 changes: 3 additions & 0 deletions src/types/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ export enum LanguageModel {
* GPT 3.5 Turbo
*/
GPT3_5 = 'gpt-3.5-turbo',
GPT3_5_1106 = 'gpt-3.5-turbo-1106',
GPT3_5_16K = 'gpt-3.5-turbo-16k',
/**
* GPT 4
*/
GPT4 = 'gpt-4',
GPT4_32K = 'gpt-4-32k',
GPT4_PREVIEW = 'gpt-4-1106-preview',
GPT4_VISION_PREVIEW = 'gpt-4-vision-preview',
}

// 语言模型的设置参数
Expand Down

0 comments on commit 46386dc

Please sign in to comment.