Merge pull request #4674 from leo4life2/main

support gpt-4o
This commit is contained in:
fred-bf 2024-05-14 14:36:23 +08:00 committed by GitHub
commit 9faab960f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

@ -127,6 +127,8 @@ export const KnowledgeCutOffDate: Record<string, string> = {
"gpt-4-turbo": "2023-12", "gpt-4-turbo": "2023-12",
"gpt-4-turbo-2024-04-09": "2023-12", "gpt-4-turbo-2024-04-09": "2023-12",
"gpt-4-turbo-preview": "2023-12", "gpt-4-turbo-preview": "2023-12",
"gpt-4o": "2023-10",
"gpt-4o-2024-05-13": "2023-10",
"gpt-4-vision-preview": "2023-04", "gpt-4-vision-preview": "2023-04",
// After improvements, // After improvements,
// it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously. // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously.
@ -144,8 +146,10 @@ const openaiModels = [
"gpt-4-32k-0613", "gpt-4-32k-0613",
"gpt-4-turbo", "gpt-4-turbo",
"gpt-4-turbo-preview", "gpt-4-turbo-preview",
"gpt-4o",
"gpt-4o-2024-05-13",
"gpt-4-vision-preview", "gpt-4-vision-preview",
"gpt-4-turbo-2024-04-09", "gpt-4-turbo-2024-04-09"
]; ];
const googleModels = [ const googleModels = [

View File

@ -290,16 +290,17 @@ export function getMessageImages(message: RequestMessage): string[] {
} }
export function isVisionModel(model: string) { export function isVisionModel(model: string) {
// Note: This is a better way using the TypeScript feature instead of `&&` or `||` (ts v5.5.0-dev.20240314 I've been using)
const visionKeywords = [ const visionKeywords = [
"vision", "vision",
"claude-3", "claude-3",
"gemini-1.5-pro", "gemini-1.5-pro",
"gpt-4-turbo",
"gpt-4o",
]; ];
const isGpt4TurboPreview = model === "gpt-4-turbo-preview";
const isGpt4Turbo = model.includes("gpt-4-turbo") && !model.includes("preview"); return (
visionKeywords.some((keyword) => model.includes(keyword)) &&
return visionKeywords.some((keyword) => model.includes(keyword)) || isGpt4Turbo; !isGpt4TurboPreview
);
} }