diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5484caa..e8efb99 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,14 +31,16 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: "Checkout"
- uses: actions/checkout@v3.0.2
+ uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET Core SDK"
- uses: actions/setup-dotnet@v3
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: '8.0.x'
+ dotnet-version: |
+ 8.0.x
+ 9.0.x
- name: "Dotnet Tool Restore"
run: dotnet tool restore
shell: pwsh
@@ -52,7 +54,7 @@ jobs:
run: dotnet cake --target=Pack
shell: pwsh
- name: "Publish Artefacts"
- uses: actions/upload-artifact@v3.1.0
+ uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}
path: "./Artefacts"
@@ -69,7 +71,7 @@ jobs:
runs-on: windows-latest
steps:
- name: "Download Artefact"
- uses: actions/download-artifact@v3.0.0
+ uses: actions/download-artifact@v4
with:
name: "windows-latest"
- name: "Dotnet NuGet Add Source"
@@ -89,7 +91,7 @@ jobs:
runs-on: windows-latest
steps:
- name: "Download Artefact"
- uses: actions/download-artifact@v3.0.0
+ uses: actions/download-artifact@v4
with:
name: "windows-latest"
- name: "Dotnet NuGet Push"
diff --git a/Directory.Build.props b/Directory.Build.props
index a6c705a..62256e4 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -25,10 +25,6 @@
https://github.com/tinonetic/anthropic.net/releases
-
-
-
-
-
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 912f5fb..39b94d8 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -4,23 +4,23 @@
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
diff --git a/Examples/AnthropicNetDemo/AnthropicNetDemo.csproj b/Examples/AnthropicNetDemo/AnthropicNetDemo.csproj
index 789f707..d31d251 100644
--- a/Examples/AnthropicNetDemo/AnthropicNetDemo.csproj
+++ b/Examples/AnthropicNetDemo/AnthropicNetDemo.csproj
@@ -9,9 +9,9 @@
-
-
-
+
+
+
diff --git a/Examples/AnthropicNetDemo/Program.cs b/Examples/AnthropicNetDemo/Program.cs
index 40911fb..c597c1a 100644
--- a/Examples/AnthropicNetDemo/Program.cs
+++ b/Examples/AnthropicNetDemo/Program.cs
@@ -53,7 +53,7 @@ public static async Task Main()
// Boiler plate code
var config = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
- .AddUserSecrets()
+ .AddUserSecrets()
.Build();
var host = new HostBuilder()
@@ -81,7 +81,7 @@ public static async Task Main()
// Sending the question & retrieving the response using Messages API
var messages = new List { Message.FromUser(question) };
- var messageRequest = new MessageRequest(AnthropicModels.Claude_3_Sonnet, messages);
+ var messageRequest = new MessageRequest(AnthropicModels.Claude3Sonnet, messages);
var messageResponse = await anthropicApiClient.MessageAsync(messageRequest);
// Extract text from the response
diff --git a/Source/Anthropic.Net/Anthropic.Net.csproj b/Source/Anthropic.Net/Anthropic.Net.csproj
index 5e708fd..a0132f3 100644
--- a/Source/Anthropic.Net/Anthropic.Net.csproj
+++ b/Source/Anthropic.Net/Anthropic.Net.csproj
@@ -10,20 +10,18 @@
Anthropic;Anthropic .NET SDK;Claude;Machine Learning;ML;AI;Artificial Intellegence;API;LLM
+
-
+
+
-
+
+
+
+
+
+
-
-
-
-
-
diff --git a/Source/Anthropic.Net/CompletionRequest.cs b/Source/Anthropic.Net/CompletionRequest.cs
index c955aad..761b16b 100644
--- a/Source/Anthropic.Net/CompletionRequest.cs
+++ b/Source/Anthropic.Net/CompletionRequest.cs
@@ -1,4 +1,5 @@
namespace Anthropic.Net;
+
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Anthropic.Net.Constants;
diff --git a/Source/Anthropic.Net/CompletionResponse.cs b/Source/Anthropic.Net/CompletionResponse.cs
index 37e8bfd..20e950a 100644
--- a/Source/Anthropic.Net/CompletionResponse.cs
+++ b/Source/Anthropic.Net/CompletionResponse.cs
@@ -1,4 +1,5 @@
namespace Anthropic.Net;
+
using System.Text.Json.Serialization;
///
diff --git a/Source/Anthropic.Net/Constants/AnthropicModels.cs b/Source/Anthropic.Net/Constants/AnthropicModels.cs
index b1ac02b..4c40c7c 100644
--- a/Source/Anthropic.Net/Constants/AnthropicModels.cs
+++ b/Source/Anthropic.Net/Constants/AnthropicModels.cs
@@ -44,20 +44,20 @@ public static class AnthropicModels
///
/// Claude 3 Haiku - Fastest and most compact model in the Claude 3 family.
///
- public const string Claude_3_Haiku = "claude-3-haiku-20240307";
+ public const string Claude3Haiku = "claude-3-haiku-20240307";
///
/// Claude 3 Sonnet - Balanced model for a wide range of tasks.
///
- public const string Claude_3_Sonnet = "claude-3-sonnet-20240229";
+ public const string Claude3Sonnet = "claude-3-sonnet-20240229";
///
/// Claude 3 Opus - Most powerful model in the Claude 3 family.
///
- public const string Claude_3_Opus = "claude-3-opus-20240229";
+ public const string Claude3Opus = "claude-3-opus-20240229";
///
/// Claude 3.5 Sonnet - Latest model with improved capabilities.
///
- public const string Claude_3_5_Sonnet = "claude-3-5-sonnet-20241022";
+ public const string Claude35Sonnet = "claude-3-5-sonnet-20241022";
}
diff --git a/Source/Anthropic.Net/IAnthropicApiClient.cs b/Source/Anthropic.Net/IAnthropicApiClient.cs
index 5cccb47..e8e7c41 100644
--- a/Source/Anthropic.Net/IAnthropicApiClient.cs
+++ b/Source/Anthropic.Net/IAnthropicApiClient.cs
@@ -1,4 +1,5 @@
namespace Anthropic.Net;
+
using System.Threading.Tasks;
using Anthropic.Net.Models.Messages;
diff --git a/Source/Anthropic.Net/Models/Messages/ContentBlock.cs b/Source/Anthropic.Net/Models/Messages/ContentBlock.cs
index 1d2a039..dd9963b 100644
--- a/Source/Anthropic.Net/Models/Messages/ContentBlock.cs
+++ b/Source/Anthropic.Net/Models/Messages/ContentBlock.cs
@@ -5,6 +5,9 @@ namespace Anthropic.Net.Models.Messages;
///
/// Base class for content blocks in messages.
///
+[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
+[JsonDerivedType(typeof(TextContentBlock), typeDiscriminator: "text")]
+[JsonDerivedType(typeof(ImageContentBlock), typeDiscriminator: "image")]
public abstract class ContentBlock
{
///
diff --git a/Tests/Anthropic.Net.Tests/Anthropic.Net.Test.csproj b/Tests/Anthropic.Net.Tests/Anthropic.Net.Test.csproj
index b92df47..29b40c8 100644
--- a/Tests/Anthropic.Net.Tests/Anthropic.Net.Test.csproj
+++ b/Tests/Anthropic.Net.Tests/Anthropic.Net.Test.csproj
@@ -4,18 +4,16 @@
net8.0
+
+
+
+
+
+
-
-
-
-
-
-
-
-
diff --git a/Tests/Anthropic.Net.Tests/ApiClientTests.cs b/Tests/Anthropic.Net.Tests/ApiClientTests.cs
index 4782869..14db254 100644
--- a/Tests/Anthropic.Net.Tests/ApiClientTests.cs
+++ b/Tests/Anthropic.Net.Tests/ApiClientTests.cs
@@ -71,7 +71,7 @@ public async Task TestMessageAsync_ValidRequestAsync()
// Act
var messages = new List { Message.FromUser("Hello, Claude!") };
- var response = await sut.MessageAsync(new MessageRequest(AnthropicModels.Claude_3_Sonnet, messages))
+ var response = await sut.MessageAsync(new MessageRequest(AnthropicModels.Claude3Sonnet, messages))
.ConfigureAwait(true);
// Assert
diff --git a/dotnet-tools.json b/dotnet-tools.json
index c8bb929..3f28733 100644
--- a/dotnet-tools.json
+++ b/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
- "version": "2.2.0",
+ "version": "4.0.0",
"commands": [
"dotnet-cake"
]