Skip to content

Commit

Permalink
Merge pull request #30 from feiyun0112/NETStandardVersion
Browse files Browse the repository at this point in the history
Change TargetFramework to netstandard2.0
  • Loading branch information
awaescher authored May 10, 2024
2 parents 4a3c57e + a74507a commit b4f3bbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/Diagnostics/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.

namespace System.Runtime.CompilerServices;

/// <summary>
/// Reserved to be used by the compiler for tracking metadata.
/// This class should not be used by developers in source code.
/// </summary>
internal static class IsExternalInit
{
}
10 changes: 5 additions & 5 deletions src/OllamaApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private async Task<TResponse> GetAsync<TResponse>(string endpoint, CancellationT
var response = await _client.GetAsync(endpoint, cancellationToken);
response.EnsureSuccessStatusCode();

var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
var responseBody = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<TResponse>(responseBody);
}

Expand All @@ -161,7 +161,7 @@ private async Task<TResponse> PostAsync<TRequest, TResponse>(string endpoint, TR
var response = await _client.PostAsync(endpoint, content, cancellationToken);
response.EnsureSuccessStatusCode();

var responseBody = await response.Content.ReadAsStringAsync(cancellationToken);
var responseBody = await response.Content.ReadAsStringAsync();

return JsonSerializer.Deserialize<TResponse>(responseBody);
}
Expand All @@ -181,7 +181,7 @@ private async Task StreamPostAsync<TRequest, TResponse>(string endpoint, TReques

private static async Task ProcessStreamedResponseAsync<TLine>(HttpResponseMessage response, IResponseStreamer<TLine> streamer, CancellationToken cancellationToken)
{
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);
using var stream = await response.Content.ReadAsStreamAsync();
using var reader = new StreamReader(stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
Expand All @@ -194,7 +194,7 @@ private static async Task ProcessStreamedResponseAsync<TLine>(HttpResponseMessag

private static async Task<ConversationContext> ProcessStreamedCompletionResponseAsync(HttpResponseMessage response, IResponseStreamer<GenerateCompletionResponseStream> streamer, CancellationToken cancellationToken)
{
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);
using var stream = await response.Content.ReadAsStreamAsync();
using var reader = new StreamReader(stream);

while (!reader.EndOfStream && !cancellationToken.IsCancellationRequested)
Expand All @@ -215,7 +215,7 @@ private static async Task<ConversationContext> ProcessStreamedCompletionResponse

private static async Task<IEnumerable<Message>> ProcessStreamedChatResponseAsync(ChatRequest chatRequest, HttpResponseMessage response, IResponseStreamer<ChatResponseStream> streamer, CancellationToken cancellationToken)
{
using var stream = await response.Content.ReadAsStreamAsync(cancellationToken);
using var stream = await response.Content.ReadAsStreamAsync();
using var reader = new StreamReader(stream);

ChatRole? responseRole = null;
Expand Down
8 changes: 7 additions & 1 deletion src/OllamaSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>API bindings for Ollama</Title>
<Copyright>Andreas Wäscher</Copyright>
Expand Down Expand Up @@ -31,4 +33,8 @@
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.2" />
</ItemGroup>
</Project>

0 comments on commit b4f3bbb

Please sign in to comment.