-
Notifications
You must be signed in to change notification settings - Fork 59.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5883 from code-october/fix/model-leak
fix model leak issue
- Loading branch information
Showing
11 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { isModelNotavailableInServer } from "../app/utils/model"; | ||
|
||
describe("isModelNotavailableInServer", () => { | ||
test("test model will return false, which means the model is available", () => { | ||
const customModels = ""; | ||
const modelName = "gpt-4"; | ||
const providerNames = "OpenAI"; | ||
const result = isModelNotavailableInServer(customModels, modelName, providerNames); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test("test model will return true when model is not available in custom models", () => { | ||
const customModels = "-all,gpt-4o-mini"; | ||
const modelName = "gpt-4"; | ||
const providerNames = "OpenAI"; | ||
const result = isModelNotavailableInServer(customModels, modelName, providerNames); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test("should respect DISABLE_GPT4 setting", () => { | ||
process.env.DISABLE_GPT4 = "1"; | ||
const result = isModelNotavailableInServer("", "gpt-4", "OpenAI"); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test("should handle empty provider names", () => { | ||
const result = isModelNotavailableInServer("-all,gpt-4", "gpt-4", ""); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test("should be case insensitive for model names", () => { | ||
const result = isModelNotavailableInServer("-all,GPT-4", "gpt-4", "OpenAI"); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test("support passing multiple providers, model unavailable on one of the providers will return true", () => { | ||
const customModels = "-all,gpt-4@Google"; | ||
const modelName = "gpt-4"; | ||
const providerNames = ["OpenAI", "Azure"]; | ||
const result = isModelNotavailableInServer(customModels, modelName, providerNames); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
test("support passing multiple providers, model available on one of the providers will return false", () => { | ||
const customModels = "-all,gpt-4@Google"; | ||
const modelName = "gpt-4"; | ||
const providerNames = ["OpenAI", "Google"]; | ||
const result = isModelNotavailableInServer(customModels, modelName, providerNames); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
test("test custom model without setting provider", () => { | ||
const customModels = "-all,mistral-large"; | ||
const modelName = "mistral-large"; | ||
const providerNames = modelName; | ||
const result = isModelNotavailableInServer(customModels, modelName, providerNames); | ||
expect(result).toBe(false); | ||
}); | ||
}) |