mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
fix: improve type safety for max_completion_tokens params
Remove Record<string, unknown> type annotation to let TypeScript infer the params object type, preserving type checking on all properties. Cast to ChatCompletionCreateParamsNonStreaming at the create() call site to accommodate the SDK's missing max_completion_tokens type. Add unit test for reasoning model detection regex. Signed-off-by: majiayu000 <1835304752@qq.com>
This commit is contained in:
26
test/unit/openAi.test.ts
Normal file
26
test/unit/openAi.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// Test the reasoning model detection regex used in OpenAiEngine.
|
||||
// Integration test with the engine is not possible because mistral.ts
|
||||
// uses require() which is unavailable in the ESM test environment.
|
||||
const REASONING_MODEL_RE = /^(o[1-9]|gpt-5)/;
|
||||
|
||||
describe('OpenAiEngine reasoning model detection', () => {
|
||||
it.each([
|
||||
['o1', true],
|
||||
['o1-preview', true],
|
||||
['o1-mini', true],
|
||||
['o3', true],
|
||||
['o3-mini', true],
|
||||
['o4-mini', true],
|
||||
['gpt-5', true],
|
||||
['gpt-5-nano', true],
|
||||
['gpt-4o', false],
|
||||
['gpt-4o-mini', false],
|
||||
['gpt-4', false],
|
||||
['gpt-3.5-turbo', false]
|
||||
])(
|
||||
'model "%s" isReasoning=%s',
|
||||
(model, expected) => {
|
||||
expect(REASONING_MODEL_RE.test(model)).toBe(expected);
|
||||
}
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user