update chat model filters for openai ()

This commit is contained in:
Timothy Carambat 2024-12-11 08:55:10 -08:00 committed by GitHub
parent a0c5d898f0
commit a69997a715
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions
server/utils
AiProviders/openAi
helpers

View file

@ -62,7 +62,9 @@ class OpenAiLLM {
// we don't want to hit the OpenAI api every chat because it will get spammed
// and introduce latency for no reason.
async isValidChatCompletionModel(modelName = "") {
const isPreset = modelName.toLowerCase().includes("gpt");
const isPreset =
modelName.toLowerCase().includes("gpt") ||
modelName.toLowerCase().includes("o1");
if (isPreset) return true;
const model = await this.openai.models

View file

@ -141,9 +141,17 @@ async function openAiModels(apiKey = null) {
});
const gpts = allModels
.filter((model) => model.id.startsWith("gpt") || model.id.startsWith("o1"))
.filter(
(model) => !model.id.includes("vision") && !model.id.includes("instruct")
(model) =>
(model.id.includes("gpt") && !model.id.startsWith("ft:")) ||
model.id.includes("o1")
)
.filter(
(model) =>
!model.id.includes("vision") &&
!model.id.includes("instruct") &&
!model.id.includes("audio") &&
!model.id.includes("realtime")
)
.map((model) => {
return {