-
Notifications
You must be signed in to change notification settings - Fork 59.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: runtime configuration of vision-capable models #5919
Changes from 6 commits
a433d16
74c4711
ed8c358
210b29b
149d732
ea1329f
a127ae1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { isVisionModel } from "../app/utils"; | ||
|
||
describe("isVisionModel", () => { | ||
const originalEnv = process.env; | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
process.env = { ...originalEnv }; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env = originalEnv; | ||
}); | ||
|
||
test("should identify vision models using regex patterns", () => { | ||
const visionModels = [ | ||
"gpt-4-vision", | ||
"claude-3-opus", | ||
"gemini-1.5-pro", | ||
"gemini-2.0", | ||
"gemini-exp-vision", | ||
"learnlm-vision", | ||
"qwen-vl-max", | ||
"qwen2-vl-max", | ||
"gpt-4-turbo", | ||
"dall-e-3", | ||
]; | ||
|
||
visionModels.forEach((model) => { | ||
expect(isVisionModel(model)).toBe(true); | ||
}); | ||
}); | ||
|
||
test("should exclude specific models", () => { | ||
expect(isVisionModel("claude-3-5-haiku-20241022")).toBe(false); | ||
}); | ||
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Enhance exclusion testing with more patterns and documentation. The current test is too specific. Consider:
-test("should exclude specific models", () => {
- expect(isVisionModel("claude-3-5-haiku-20241022")).toBe(false);
-});
+test.each([
+ // Models excluded due to specific version constraints
+ ["claude-3-5-haiku-20241022", "Haiku variant without vision capabilities"],
+ // Add more excluded models with reasons
+])("should exclude %s (%s)", (model, reason) => {
+ expect(isVisionModel(model)).toBe(false);
+});
|
||
|
||
test("should not identify non-vision models", () => { | ||
const nonVisionModels = [ | ||
"gpt-3.5-turbo", | ||
"gpt-4-turbo-preview", | ||
"claude-2", | ||
"regular-model", | ||
]; | ||
|
||
nonVisionModels.forEach((model) => { | ||
expect(isVisionModel(model)).toBe(false); | ||
}); | ||
}); | ||
|
||
test("should identify models from VISION_MODELS env var", () => { | ||
process.env.VISION_MODELS = "custom-vision-model,another-vision-model"; | ||
|
||
expect(isVisionModel("custom-vision-model")).toBe(true); | ||
expect(isVisionModel("another-vision-model")).toBe(true); | ||
expect(isVisionModel("unrelated-model")).toBe(false); | ||
}); | ||
|
||
test("should handle empty or missing VISION_MODELS", () => { | ||
process.env.VISION_MODELS = ""; | ||
expect(isVisionModel("unrelated-model")).toBe(false); | ||
|
||
delete process.env.VISION_MODELS; | ||
expect(isVisionModel("unrelated-model")).toBe(false); | ||
expect(isVisionModel("gpt-4-vision")).toBe(true); | ||
}); | ||
}); | ||
Comment on lines
+1
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Add missing edge case tests. Consider adding tests for the following edge cases:
+ test.each([
+ ["", "empty string"],
+ [null, "null input"],
+ [undefined, "undefined input"],
+ ["GPT-4-VISION", "uppercase input"],
+ ["gpt-4-vision!", "special characters"],
+ ])("should handle edge case: %s (%s)", (input, description) => {
+ expect(() => isVisionModel(input)).not.toThrow();
+ });
π§° Toolsπͺ Biome (1.9.4)[error] 63-63: Avoid the delete operator which can impact performance. Unsafe fix: Use an undefined assignment instead. (lint/performance/noDelete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variable name mismatch with PR objectives.
The PR objectives mention
NEXT_PUBLIC_VISION_MODELS
, but the code usesVISION_MODELS
. This inconsistency should be resolved.π Committable suggestion