@@ -34,32 +34,44 @@ describe('tahoiya/arbitraryAibot', () => {
3434 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "さよならプラスティックワールド"}' ) )
3535 . mockResolvedValueOnce ( mockContent ( '{"isCorrect": false}' ) ) ;
3636
37- const result = await getArbitraryAIAnswer ( '実在するPerfumeのシングルは?' , 'ポリリズム' , false ) ;
37+ const result = await getArbitraryAIAnswer ( '実在するPerfumeのシングルは?' , 'ポリリズム' ) ;
3838
3939 expect ( result ) . toBe ( 'さよならプラスティックワールド' ) ;
4040 expect ( openai . chat . completions . create ) . toHaveBeenCalledTimes ( 2 ) ;
4141 } ) ;
4242
43- it ( 'always instructs the model not to answer correctly, regardless of isMimicryAllowed ' , async ( ) => {
43+ it ( 'always instructs the model not to answer correctly' , async ( ) => {
4444 jest . mocked ( openai . chat . completions . create )
4545 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答"}' ) )
4646 . mockResolvedValueOnce ( mockContent ( '{"isCorrect": false}' ) ) ;
4747
48- await getArbitraryAIAnswer ( '質問' , '正解' , true ) ;
48+ await getArbitraryAIAnswer ( '質問' , '正解' ) ;
4949
5050 const [ [ generationCall ] ] = jest . mocked ( openai . chat . completions . create ) . mock . calls ;
5151 const prompt = generationCall . messages [ 0 ] . content as string ;
5252 expect ( prompt ) . toContain ( '質問に対して正解となるような回答をしてはいけません' ) ;
5353 } ) ;
5454
55+ it ( 'instructs the judge to also treat alternative correct answers as correct' , async ( ) => {
56+ jest . mocked ( openai . chat . completions . create )
57+ . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答"}' ) )
58+ . mockResolvedValueOnce ( mockContent ( '{"isCorrect": false}' ) ) ;
59+
60+ await getArbitraryAIAnswer ( '質問' , '正解' ) ;
61+
62+ const [ , [ judgeCall ] ] = jest . mocked ( openai . chat . completions . create ) . mock . calls ;
63+ const prompt = judgeCall . messages [ 0 ] . content as string ;
64+ expect ( prompt ) . toContain ( '別解' ) ;
65+ } ) ;
66+
5567 it ( 'regenerates up to 2 times when judged as correct, and returns the answer once judged incorrect' , async ( ) => {
5668 jest . mocked ( openai . chat . completions . create )
5769 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答1"}' ) )
5870 . mockResolvedValueOnce ( mockContent ( '{"isCorrect": true}' ) )
5971 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答2"}' ) )
6072 . mockResolvedValueOnce ( mockContent ( '{"isCorrect": false}' ) ) ;
6173
62- const result = await getArbitraryAIAnswer ( '質問' , '正解' , false ) ;
74+ const result = await getArbitraryAIAnswer ( '質問' , '正解' ) ;
6375
6476 expect ( result ) . toBe ( '誤答2' ) ;
6577 expect ( openai . chat . completions . create ) . toHaveBeenCalledTimes ( 4 ) ;
@@ -74,7 +86,7 @@ describe('tahoiya/arbitraryAibot', () => {
7486 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答3"}' ) )
7587 . mockResolvedValueOnce ( mockContent ( '{"isCorrect": true}' ) ) ;
7688
77- const result = await getArbitraryAIAnswer ( '質問' , '正解' , false ) ;
89+ const result = await getArbitraryAIAnswer ( '質問' , '正解' ) ;
7890
7991 expect ( result ) . toBeNull ( ) ;
8092 expect ( openai . chat . completions . create ) . toHaveBeenCalledTimes ( 6 ) ;
@@ -83,7 +95,7 @@ describe('tahoiya/arbitraryAibot', () => {
8395 it ( 'returns null and does not throw when the generation call fails' , async ( ) => {
8496 jest . mocked ( openai . chat . completions . create ) . mockRejectedValueOnce ( new Error ( 'API error' ) ) ;
8597
86- const result = await getArbitraryAIAnswer ( '質問' , '正解' , false ) ;
98+ const result = await getArbitraryAIAnswer ( '質問' , '正解' ) ;
8799
88100 expect ( result ) . toBeNull ( ) ;
89101 } ) ;
@@ -93,15 +105,15 @@ describe('tahoiya/arbitraryAibot', () => {
93105 . mockResolvedValueOnce ( mockContent ( '{"decoyAnswer": "誤答"}' ) )
94106 . mockRejectedValueOnce ( new Error ( 'API error' ) ) ;
95107
96- const result = await getArbitraryAIAnswer ( '質問' , '正解' , false ) ;
108+ const result = await getArbitraryAIAnswer ( '質問' , '正解' ) ;
97109
98110 expect ( result ) . toBeNull ( ) ;
99111 } ) ;
100112
101113 it ( 'returns null when the response does not contain valid JSON' , async ( ) => {
102114 jest . mocked ( openai . chat . completions . create ) . mockResolvedValueOnce ( mockContent ( '申し訳ありませんが回答できません' ) ) ;
103115
104- const result = await getArbitraryAIAnswer ( '質問' , '正解' , false ) ;
116+ const result = await getArbitraryAIAnswer ( '質問' , '正解' ) ;
105117
106118 expect ( result ) . toBeNull ( ) ;
107119 } ) ;
0 commit comments