Commit
Trim debate questions
commit
3d9f8a6
2 changed files with +40 and −1
Jump to a changed file
- src/core/config.test.ts +39 −0
- src/core/schemas.ts +1 −1
added src/core/config.test.ts +39 −0
| @@ -0,0 +1,39 @@ | ||
| 1 | +import { describe, expect, it } from 'vitest'; | |
| 2 | +import { parseDebateConfig } from './config'; | |
| 3 | + | |
| 4 | +const validInput = { | |
| 5 | + question: 'Should we ship this change?', | |
| 6 | + models: ['openai/gpt-4o', 'anthropic/claude-3.5-sonnet', 'google/gemini-pro-1.5'], | |
| 7 | + chairmanModel: 'x-ai/grok-2-1212', | |
| 8 | +}; | |
| 9 | + | |
| 10 | +describe('parseDebateConfig', () => { | |
| 11 | + it('trims the question before returning the resolved config', () => { | |
| 12 | + const config = parseDebateConfig({ | |
| 13 | + ...validInput, | |
| 14 | + question: ' Should we ship this change? ', | |
| 15 | + }); | |
| 16 | + | |
| 17 | + expect(config.question).toBe('Should we ship this change?'); | |
| 18 | + }); | |
| 19 | + | |
| 20 | + it('rejects questions that contain only whitespace', () => { | |
| 21 | + expect(() => | |
| 22 | + parseDebateConfig({ | |
| 23 | + ...validInput, | |
| 24 | + question: ' ', | |
| 25 | + }), | |
| 26 | + ).toThrow(); | |
| 27 | + }); | |
| 28 | + | |
| 29 | + it('fills the optional debate settings with defaults', () => { | |
| 30 | + const config = parseDebateConfig(validInput); | |
| 31 | + | |
| 32 | + expect(config).toMatchObject({ | |
| 33 | + maxRounds: 3, | |
| 34 | + convergenceThreshold: 85, | |
| 35 | + temperature: 0.7, | |
| 36 | + perModelTimeoutMs: 90_000, | |
| 37 | + }); | |
| 38 | + }); | |
| 39 | +}); |
modified src/core/schemas.ts +1 −1
| @@ -103,7 +103,7 @@export const modelSlugSchema = z | ||
| 103 | 103 | |
| 104 | 104 | export const debateConfigInputSchema = z |
| 105 | 105 | .object({ |
| 106 | - question: z.string().min(3).max(8000), | |
| 106 | + question: z.string().trim().min(3).max(8000), | |
| 107 | 107 | models: z.array(modelSlugSchema).min(3).max(6), |
| 108 | 108 | chairmanModel: modelSlugSchema, |
| 109 | 109 | convergenceModel: modelSlugSchema.optional(), |