Skip to content

Commit ca69bd1

Browse files
authored
Merge pull request #339 from awaescher/copilot/update-projects-to-dotnet10
Add .NET 10 multitargeting support
2 parents f6b1ea5 + fae5e09 commit ca69bd1

File tree

13 files changed

+36
-30
lines changed

13 files changed

+36
-30
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
dotnet-version: |
3838
8.0.x
3939
9.0.x
40+
10.0.x
4041
4142
- name: Restore dependencies
4243
run: dotnet restore OllamaSharp.slnx

Directory.Packages.props

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
7-
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="9.0.9" />
7+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.0" />
88
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.14.0" />
99
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
10-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.10.0" />
11-
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.10.0" />
12-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.10" />
13-
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.10" />
14-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
10+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="10.0.0" />
11+
<PackageVersion Include="Microsoft.Extensions.AI" Version="10.0.0" />
12+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
13+
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0" />
14+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1515
<PackageVersion Include="Moq" Version="4.20.72" />
16-
<PackageVersion Include="NUnit.Analyzers" Version="4.10.0" />
16+
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
1717
<PackageVersion Include="NUnit" Version="4.4.0" />
18-
<PackageVersion Include="NUnit3TestAdapter" Version="5.1.0" />
18+
<PackageVersion Include="NUnit3TestAdapter" Version="5.2.0" />
1919
<PackageVersion Include="Shouldly" Version="4.3.0" />
20-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.11" />
21-
<PackageVersion Include="Spectre.Console.ImageSharp" Version="0.51.1" />
22-
<PackageVersion Include="Spectre.Console" Version="0.51.1" />
20+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
21+
<PackageVersion Include="Spectre.Console" Version="0.53.0" />
22+
<PackageVersion Include="Spectre.Console.ImageSharp" Version="0.53.0" />
2323
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
2424
<PackageVersion Include="ModelContextProtocol" Version="0.2.0-preview.3" />
2525
</ItemGroup>

demo/OllamaApiConsole.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net9.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
</PropertyGroup>
88

demo/OllamaConsole.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ protected void WriteChatInstructionHint()
7575
{
7676
AnsiConsole.MarkupLine($"[{HintTextColor}]Enter [{AccentTextColor}]{START_NEW_COMMAND}[/] to start over or [{AccentTextColor}]{EXIT_COMMAND}[/] to leave.[/]");
7777
AnsiConsole.MarkupLine($"[{HintTextColor}]Begin with [{AccentTextColor}]{Markup.Escape(MULTILINE_OPEN.ToString())}[/] to start multiline input. Sumbmit it by ending with [{AccentTextColor}]{Markup.Escape(MULTILINE_CLOSE.ToString())}[/].[/]");
78-
AnsiConsole.MarkupLine($"[{HintTextColor}]Think mode is [{AccentTextColor}]{Think?.ToString().ToLower() ?? "(null)"}[/]. Type [{AccentTextColor}]{TOGGLETHINK_COMMAND}[/] to change.[/]");
78+
AnsiConsole.MarkupLine($"[{HintTextColor}]Think mode is [{AccentTextColor}]{Think?.ToString()?.ToLower() ?? "(null)"}[/]. Type [{AccentTextColor}]{TOGGLETHINK_COMMAND}[/] to change.[/]");
7979
}
8080

8181
internal void ToggleThink()
8282
{
8383
// null -> false -> true -> null -> ...
8484
Think = Think == null ? false : ((bool?)Think == false ? true : ((bool?)Think == true ? null : false));
85-
AnsiConsole.MarkupLine($"[{HintTextColor}]Think mode is [{AccentTextColor}]{Think?.ToString().ToLower() ?? "(null)"}[/].[/]");
85+
AnsiConsole.MarkupLine($"[{HintTextColor}]Think mode is [{AccentTextColor}]{Think?.ToString()?.ToLower() ?? "(null)"}[/].[/]");
8686
}
8787

8888
protected async Task<string> SelectModel(string prompt, string additionalInformation = "")

src/OllamaSharp.ModelContextProtocol/OllamaSharp.ModelContextProtocol.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
55
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
77
<Title>OllamaSharp.ModelContextProtocol</Title>

src/OllamaSharp/MicrosoftAi/AbstractionMapper.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,12 @@ public static ChatResponseUpdate ToChatResponseUpdate(ChatResponseStream? respon
344344
GetAIContentsFromMessage(response.Message);
345345

346346
if (response is ChatDoneResponseStream done)
347-
{
348-
contents.Add(new UsageContent(ParseOllamaChatResponseUsage(done)));
349-
350-
return new ChatResponseUpdate(ToAbstractionRole(done.Message.Role), contents)
347+
{
348+
var usage = ParseOllamaChatResponseUsage(done);
349+
if (usage is not null)
350+
contents.Add(new UsageContent(usage));
351+
352+
return new ChatResponseUpdate(ToAbstractionRole(done.Message.Role), contents)
351353
{
352354
CreatedAt = done.CreatedAt,
353355
FinishReason = done.DoneReason is null ? null : new ChatFinishReason(done.DoneReason),

src/OllamaSharp/Models/ErrorResponse.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace OllamaSharp.Models;
88
/// </summary>
99
public class ErrorResponse
1010
{
11+
/// <summary>
12+
/// The error message
13+
/// </summary>
1114
[JsonPropertyName(Application.Error)]
12-
public string Message { get; set; }
15+
public string Message { get; set; } = string.Empty;
1316
}

src/OllamaSharp/OllamaApiClient.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,8 @@ private StringContent GetJsonContent<TRequest>(TRequest ollamaRequest) where TRe
324324
var line = await reader.ReadLineAsync().ConfigureAwait(false) ?? "";
325325

326326
var error = JsonSerializer.Deserialize<ErrorResponse?>(line, IncomingJsonSerializerOptions);
327-
if ((error?.Message ?? null) is not null)
328-
{
329-
throw new ResponseError(error.Message);
330-
}
327+
if (!string.IsNullOrEmpty(error?.Message))
328+
throw new ResponseError(error!.Message);
331329

332330
yield return JsonSerializer
333331
.Deserialize<TLine?>(

src/OllamaSharp/OllamaSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0;net10.0</TargetFrameworks>
55
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
77
<Title>OllamaSharp</Title>

src/OllamaSharp/Tools/DefaultToolInvoker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public async Task<ToolResult> InvokeAsync(Message.ToolCall toolCall, IEnumerable
3434
else if (tool is IAsyncInvokableTool ai)
3535
toolResult = await ai.InvokeMethodAsync(normalizedArguments).ConfigureAwait(false);
3636

37-
return new ToolResult(Tool: tool, ToolCall: toolCall, Result: toolResult);
37+
return new ToolResult(Tool: tool!, ToolCall: toolCall!, Result: toolResult);
3838
}
3939
}

0 commit comments

Comments
 (0)