|
@@ -17,11 +17,39 @@ import { completionTuning } from '@/lib/ai'
|
|
|
const config = (provider: string, model: string) => ({ provider, apiKey: 'key', model })
|
|
const config = (provider: string, model: string) => ({ provider, apiKey: 'key', model })
|
|
|
|
|
|
|
|
describe('completionTuning', () => {
|
|
describe('completionTuning', () => {
|
|
|
- it('keeps max_tokens and temperature for the anthropic endpoint', () => {
|
|
|
|
|
- expect(completionTuning(config('anthropic', 'claude-sonnet-4-6'), 2000, 0.7)).toEqual({
|
|
|
|
|
- max_tokens: 2000,
|
|
|
|
|
- temperature: 0.7,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ it('keeps max_tokens and temperature for the Claude models that take one', () => {
|
|
|
|
|
+ for (const model of [
|
|
|
|
|
+ 'claude-sonnet-4-6',
|
|
|
|
|
+ 'claude-haiku-4-5',
|
|
|
|
|
+ 'claude-haiku-4-5-20251001',
|
|
|
|
|
+ 'claude-opus-4-1-20250805',
|
|
|
|
|
+ 'claude-sonnet-4-20250514',
|
|
|
|
|
+ 'claude-3-5-sonnet-20241022',
|
|
|
|
|
+ ]) {
|
|
|
|
|
+ expect(completionTuning(config('anthropic', model), 2000, 0.7), model).toEqual({
|
|
|
|
|
+ max_tokens: 2000,
|
|
|
|
|
+ temperature: 0.7,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('sends no temperature to newer Claude models, which answer it with a 400', () => {
|
|
|
|
|
+ // Reproduced on claude-haiku-5-5: "temperature is deprecated for this model",
|
|
|
|
|
+ // which failed registration scans and Ask AI.
|
|
|
|
|
+ for (const model of [
|
|
|
|
|
+ 'claude-haiku-5-5',
|
|
|
|
|
+ 'claude-sonnet-5-5',
|
|
|
|
|
+ 'claude-opus-5-5',
|
|
|
|
|
+ 'claude-opus-4-7',
|
|
|
|
|
+ 'claude-opus-4-8',
|
|
|
|
|
+ 'claude-fable-5-1',
|
|
|
|
|
+ 'claude-sonnet-6',
|
|
|
|
|
+ ]) {
|
|
|
|
|
+ const tuning = completionTuning(config('anthropic', model), 2000, 0.7)
|
|
|
|
|
+ expect(tuning, model).not.toHaveProperty('temperature')
|
|
|
|
|
+ // They think inside the same cap, so the answer gets headroom on top.
|
|
|
|
|
+ expect(tuning.max_tokens, model).toBeGreaterThan(2000)
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('keeps the classic parameters for an OpenAI-compatible server', () => {
|
|
it('keeps the classic parameters for an OpenAI-compatible server', () => {
|