@@ -17,7 +17,7 @@ public ChatTests() : base()
1717 [ Fact ]
1818 public async Task Should_AnswerQuestion_BasicChat ( )
1919 {
20- var context = AIHub . Chat ( ) . WithModel ( Models . Local . Gemma2_2b ) ;
20+ var context = AIHub . Chat ( ) . WithModel ( Models . Local . Qwen2_5_0_5b ) ;
2121
2222 var result = await context
2323 . WithMessage ( "Where the hedgehog goes at night?" )
@@ -29,28 +29,38 @@ public async Task Should_AnswerQuestion_BasicChat()
2929 }
3030
3131 [ Fact ]
32- public async Task Should_AnswerDifferences_BetweenDocuments_ChatWithFiles ( )
32+ public async Task Should_AnswerFileSubject_ChatWithFiles ( )
3333 {
34- List < string > files = [ "./Files/Nicolaus_Copernicus.pdf" , "./Files/Galileo_Galilei.pdf" ] ;
34+ List < string > files = [ "./Files/Nicolaus_Copernicus.pdf" ] ;
3535
3636 var result = await AIHub . Chat ( )
37- . WithModel ( Models . Local . Gemma2_2b )
38- . WithMessage ( "You have 2 documents in memory. Whats the difference of work between Galileo and Copernicus?. Give answer based on the documents." )
37+ . WithModel ( Models . Local . Qwen2_5_0_5b )
38+ . WithMessage ( "Who is described in the file? Reply with ONLY their full name. No explanation, no punctuation. Example: Isaak Newton" )
39+ . WithMemoryParams ( new MemoryParams { AnswerTokens = 10 } )
3940 . WithFiles ( files )
4041 . CompleteAsync ( ) ;
4142
4243 Assert . True ( result . Done ) ;
4344 Assert . NotNull ( result . Message ) ;
4445 Assert . NotEmpty ( result . Message . Content ) ;
46+ var ratio = Fuzz . PartialRatio ( "nicolaus copernicus" , result . Message . Content . ToLowerInvariant ( ) ) ;
47+ Assert . True ( ratio > 50 ,
48+ $ """
49+ Fuzzy match failed!
50+ Expected > 50, but got { ratio } .
51+ Expected: 'nicolaus copernicus'
52+ Actual: '{ result . Message . Content } '
53+ """ ) ;
4554 }
4655
4756 [ Fact ]
4857 public async Task Should_AnswerQuestion_FromExistingChat ( )
4958 {
5059 var result = AIHub . Chat ( )
51- . WithModel ( Models . Local . Gemma2_2b ) ;
60+ . WithModel ( Models . Local . Qwen2_5_0_5b ) ;
5261
5362 await result . WithMessage ( "What do you think about math theories?" )
63+ . WithMemoryParams ( new MemoryParams { AnswerTokens = 10 } )
5464 . CompleteAsync ( ) ;
5565
5666 await result . WithMessage ( "And about physics?" )
@@ -71,10 +81,7 @@ public async Task Should_AnswerGameFromImage_ChatWithImagesWithText()
7181 var result = await AIHub . Chat ( )
7282 . WithModel ( Models . Local . Llama3_2_3b )
7383 . WithMessage ( "What is the title of the game? Answer in 3 words." )
74- . WithMemoryParams ( new MemoryParams
75- {
76- AnswerTokens = 1000
77- } )
84+ . WithMemoryParams ( new MemoryParams { AnswerTokens = 10 } )
7885 . WithFiles ( images )
7986 . CompleteAsync ( ) ;
8087
@@ -100,10 +107,7 @@ public async Task Should_AnswerAppleFromImage_ChatWithImagesWithVision()
100107 var result = await AIHub . Chat ( )
101108 . WithModel ( Models . Local . Gemma3_4b )
102109 . WithMessage ( "What is this fruit? Answer in one word." )
103- . WithMemoryParams ( new MemoryParams
104- {
105- AnswerTokens = 1000
106- } )
110+ . WithMemoryParams ( new MemoryParams { AnswerTokens = 10 } )
107111 . WithFiles ( images )
108112 . CompleteAsync ( ) ;
109113
@@ -144,9 +148,9 @@ public async Task Should_GenerateImage_BasedOnPrompt()
144148 }
145149
146150 [ Fact ]
147- public async Task Should_AnswerDifferences_BetweenDocuments_ChatWithFiles_UsingStreams ( )
151+ public async Task Should_AnswerFileSubject_ChatWithFiles_UsingStreams ( )
148152 {
149- List < string > files = [ "./Files/Nicolaus_Copernicus.pdf" , "./Files/Galileo_Galilei.pdf" ] ;
153+ List < string > files = [ "./Files/Nicolaus_Copernicus.pdf" ] ;
150154
151155 var fileStreams = new List < FileStream > ( ) ;
152156
@@ -166,14 +170,25 @@ public async Task Should_AnswerDifferences_BetweenDocuments_ChatWithFiles_UsingS
166170 fileStreams . Add ( fs ) ;
167171 }
168172
173+ var expectedAnswer = "nicolaus copernicus" ;
174+
169175 var result = await AIHub . Chat ( )
170- . WithModel ( Models . Local . Gemma2_2b )
171- . WithMessage ( "You have 2 documents in memory. Whats the difference of work between Galileo and Copernicus?. Give answer based on the documents." )
176+ . WithModel ( Models . Local . Qwen2_5_0_5b )
177+ . WithMessage ( "Who is described in the file? Reply with ONLY their full name. No explanation, no punctuation. Example: Isaak Newton" )
178+ . WithMemoryParams ( new MemoryParams { AnswerTokens = 10 } )
172179 . WithFiles ( fileStreams )
173180 . CompleteAsync ( ) ;
174181
175182 Assert . True ( result . Done ) ;
176183 Assert . NotNull ( result . Message ) ;
177184 Assert . NotEmpty ( result . Message . Content ) ;
185+ var ratio = Fuzz . PartialRatio ( expectedAnswer , result . Message . Content . ToLowerInvariant ( ) ) ;
186+ Assert . True ( ratio > 50 ,
187+ $ """
188+ Fuzzy match failed!
189+ Expected > 50, but got { ratio } .
190+ Expected: '{ expectedAnswer } '
191+ Actual: '{ result . Message . Content } '
192+ """ ) ;
178193 }
179194}
0 commit comments