diff --git a/src/info-page.ts b/src/info-page.ts index 1bb9157..13f9d0a 100644 --- a/src/info-page.ts +++ b/src/info-page.ts @@ -190,7 +190,7 @@ function buildRecentImageSection() { `; } html += ``; - html += `

View all recent images

` + html += `

View all recent images

`; return html; } @@ -201,7 +201,9 @@ function escapeHtml(unsafe: string) { .replace(//g, ">") .replace(/"/g, """) - .replace(/'/g, "'"); + .replace(/'/g, "'") + .replace(/\[/g, "[") + .replace(/]/g, "]"); } function getExternalUrlForHuggingfaceSpaceId(spaceId: string) { diff --git a/src/proxy/middleware/request/preprocessors/validate-context-size.ts b/src/proxy/middleware/request/preprocessors/validate-context-size.ts index dd62212..0db25b3 100644 --- a/src/proxy/middleware/request/preprocessors/validate-context-size.ts +++ b/src/proxy/middleware/request/preprocessors/validate-context-size.ts @@ -54,6 +54,8 @@ export const validateContextSize: RequestPreprocessor = async (req) => { let modelMax: number; if (model.match(/gpt-3.5-turbo-16k/)) { modelMax = 16384; + } else if (model.match(/gpt-4-turbo(-\d{4}-\d{2}-\d{2})?$/)) { + modelMax = 131072; } else if (model.match(/gpt-4-turbo(-preview)?$/)) { modelMax = 131072; } else if (model.match(/gpt-4-(0125|1106)(-preview)?$/)) { diff --git a/src/proxy/openai.ts b/src/proxy/openai.ts index 70a87c5..462a993 100644 --- a/src/proxy/openai.ts +++ b/src/proxy/openai.ts @@ -28,10 +28,12 @@ import { // https://platform.openai.com/docs/models/overview export const KNOWN_OPENAI_MODELS = [ - "gpt-4-turbo-preview", - "gpt-4-0125-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", + "gpt-4-turbo", // alias for latest gpt4-turbo stable + "gpt-4-turbo-2024-04-09", // gpt4-turbo stable, with vision + "gpt-4-turbo-preview", // alias for latest turbo preview + "gpt-4-0125-preview", // gpt4-turbo preview 2 + "gpt-4-1106-preview", // gpt4-turbo preview 1 + "gpt-4-vision-preview", // gpt4-turbo preview 1 with vision "gpt-4", "gpt-4-0613", "gpt-4-0314", // EOL 2024-06-13 diff --git a/src/shared/models.ts b/src/shared/models.ts index 00c5351..14a7fc2 100644 --- a/src/shared/models.ts +++ b/src/shared/models.ts @@ -74,6 +74,7 @@ export const LLM_SERVICES = (( ] as const); export const OPENAI_MODEL_FAMILY_MAP: { [regex: string]: OpenAIModelFamily } = { + "^gpt-4-turbo(-\\d{4}-\\d{2}-\\d{2})?$": "gpt4-turbo", "^gpt-4-turbo(-preview)?$": "gpt4-turbo", "^gpt-4-(0125|1106)(-preview)?$": "gpt4-turbo", "^gpt-4(-\\d{4})?-vision(-preview)?$": "gpt4-turbo",