File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
src/Libraries/Microsoft.Extensions.AI.Ollama Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 44 <RootNamespace >Microsoft.Extensions.AI</RootNamespace >
55 <Description >Implementation of generative AI abstractions for Ollama.</Description >
66 <Workstream >AI</Workstream >
7- <!-- This package needs to stay referencing .NET 9 versions of its dependencies -->
8- <ForceLatestDotnetVersions >true</ForceLatestDotnetVersions >
97 </PropertyGroup >
108
119 <PropertyGroup >
Original file line number Diff line number Diff line change 44using System ;
55using System . Collections . Generic ;
66using System . Globalization ;
7+ using System . IO ;
78using System . Linq ;
89using System . Net . Http ;
910using System . Net . Http . Json ;
@@ -114,12 +115,14 @@ public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAs
114115#endif
115116 . ConfigureAwait ( false ) ;
116117
117- await foreach ( OllamaChatResponse ? chunk in JsonSerializer . DeserializeAsyncEnumerable (
118- httpResponseStream ,
119- JsonContext . Default . OllamaChatResponse ,
120- topLevelValues : true ,
121- cancellationToken ) . ConfigureAwait ( false ) )
118+ using var streamReader = new StreamReader ( httpResponseStream ) ;
119+ #if NET
120+ while ( ( await streamReader . ReadLineAsync ( cancellationToken ) . ConfigureAwait ( false ) ) is { } line )
121+ #else
122+ while ( ( await streamReader . ReadLineAsync ( ) . ConfigureAwait ( false ) ) is { } line )
123+ #endif
122124 {
125+ var chunk = JsonSerializer . Deserialize ( line , JsonContext . Default . OllamaChatResponse ) ;
123126 if ( chunk is null )
124127 {
125128 continue ;
You can’t perform that action at this time.
0 commit comments