File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
MaIN.Core.IntegrationTests Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 1- using MaIN . Core . Hub ;
1+ using FuzzySharp ;
2+ using MaIN . Core . Hub ;
23using MaIN . Domain . Entities ;
34using MaIN . Domain . Models . Concrete ;
45
@@ -66,7 +67,7 @@ public async Task Should_AnswerGameFromImage_ChatWithVision()
6667
6768 var result = await AIHub . Chat ( )
6869 . WithModel < Llama3_2_3b > ( )
69- . WithMessage ( "What is the title of game?" )
70+ . WithMessage ( "What is the title of the game? Answer only this question. " )
7071 . WithMemoryParams ( new MemoryParams
7172 {
7273 AnswerTokens = 1000
@@ -77,7 +78,14 @@ public async Task Should_AnswerGameFromImage_ChatWithVision()
7778 Assert . True ( result . Done ) ;
7879 Assert . NotNull ( result . Message ) ;
7980 Assert . NotEmpty ( result . Message . Content ) ;
80- Assert . Contains ( "call of duty" , result . Message . Content . ToLower ( ) ) ;
81+ var ratio = Fuzz . PartialRatio ( "call of duty" , result . Message . Content . ToLowerInvariant ( ) ) ;
82+ Assert . True ( ratio > 50 ,
83+ $ """
84+ Fuzzy match failed!
85+ Expected > 50, but got { ratio } .
86+ Expexted: 'call of duty'
87+ Actual: '{ result . Message . Content } '
88+ """ ) ;
8189 }
8290
8391 [ Fact ( Skip = "Require powerful GPU" ) ]
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public class IntegrationTestBase : IDisposable
1313 public IntegrationTestBase ( )
1414 {
1515 _host = CreateHost ( ) ;
16+ _host . Services . UseMaIN ( ) ;
1617 _host . Start ( ) ;
1718
1819 _services = _host . Services ;
@@ -24,13 +25,14 @@ private IHost CreateHost()
2425 . ConfigureWebHostDefaults ( webBuilder =>
2526 {
2627 webBuilder
27- . UseUrls ( "http://localhost :0" ) // Random available port
28+ . UseUrls ( "http://127.0.0.1 :0" ) // Random available port
2829 . ConfigureServices ( ( context , services ) =>
2930 {
3031 services . AddMaIN ( context . Configuration ) ;
31-
32- var provider = services . BuildServiceProvider ( ) ;
33- provider . UseMaIN ( ) ;
32+ } )
33+ . Configure ( app =>
34+ {
35+
3436 } ) ;
3537 } ) ;
3638
Original file line number Diff line number Diff line change 88 </PropertyGroup >
99
1010 <ItemGroup >
11+ <PackageReference Include =" FuzzySharp" Version =" 2.0.2" />
1112 <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 18.0.1" />
1213 <PackageReference Include =" xunit" Version =" 2.9.3" />
1314 <PackageReference Include =" xunit.runner.visualstudio" Version =" 3.1.5" >
You can’t perform that action at this time.
0 commit comments