Skip to content

Commit

Permalink
Merge pull request #14 from tghamm/feature/v1.3.0
Browse files Browse the repository at this point in the history
Bump for 1.3.0 / Claude 2.1 Basic Support
  • Loading branch information
tghamm authored Nov 21, 2023
2 parents 9411ae3 + e816e62 commit 3acc7ab
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
7 changes: 4 additions & 3 deletions Anthropic.SDK.Tests/Completions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ public class Completions
public async Task TestClaudeCompletion()
{
var client = new AnthropicClient();
var prompt = AnthropicSignals.HumanSignal + "Write me a sonnet about Joe Biden." +
AnthropicSignals.AssistantSignal;
var prompt =
$@"You are an expert at date information. Please return your response in JSON only.Return a JSON object like {{ ""date"": ""08/01/2023"" }}
{AnthropicSignals.HumanSignal} What is the date the USA gained Independence? {AnthropicSignals.AssistantSignal}";
var parameters = new SamplingParameters()
{
MaxTokensToSample = 512,
Prompt = prompt,
Temperature = 0.0m,
StopSequences = new[] { AnthropicSignals.HumanSignal },
Stream = false,
Model = AnthropicModels.Claude_v2
Model = AnthropicModels.Claude_v2_1
};

var response = await client.Completions.GetClaudeCompletionAsync(parameters);
Expand Down
6 changes: 3 additions & 3 deletions Anthropic.SDK/Anthropic.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
Adds token counter extension method helper.
</PackageReleaseNotes>
<PackageId>Anthropic.SDK</PackageId>
<Version>1.2.0</Version>
<AssemblyVersion>1.2.0.0</AssemblyVersion>
<FileVersion>1.2.0.0</FileVersion>
<Version>1.3.0</Version>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<FileVersion>1.3.0.0</FileVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
Expand Down
5 changes: 5 additions & 0 deletions Anthropic.SDK/Constants/AnthropicModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public static class AnthropicModels
/// </summary>
public const string Claude_v2 = "claude-2";

/// <summary>
/// Claude V2.1 latest full version.
/// </summary>
public const string Claude_v2_1 = "claude-2.1";

/// <summary>
/// Claude V2.0 latest full version.
/// </summary>
Expand Down
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Anthropic.SDK is an unofficial C# client designed for interacting with the Claud

## Installation

Install Anthropic.SDK via the [NuGet](https://www.nuget.org/) package manager:
Install Anthropic.SDK via the [NuGet](https://www.nuget.org/packages/Anthropic.SDK) package manager:

```bash
PM> Install-Package Anthropic.SDK
Expand All @@ -41,29 +41,27 @@ To start using the Claude AI API, simply create an instance of the `AnthropicCli

### Non-Streaming Call

Here's an example of a non-streaming call to the Claude AI API:
Here's an example of a non-streaming call to the Claude AI API (with a System Prompt to the new Claude 2.1 model):

```csharp
var client = new AnthropicClient();
var prompt = AnthropicSignals.HumanSignal + "Write me a sonnet about Joe Biden." +
AnthropicSignals.AssistantSignal;

var prompt =
$@"You are an expert at date information. Please return your response in JSON only.Return a JSON object like {{ ""date"": ""08/01/2023"" }}
{AnthropicSignals.HumanSignal} What is the date the USA gained Independence? {AnthropicSignals.AssistantSignal}";
var parameters = new SamplingParameters()
{
// required
Model = AnthropicModels.Claude_v2_0
Prompt = prompt,
MaxTokensToSample = 512,

//optional
Temperature = 1,
Top_k = 1,
Top_p = 1
Prompt = prompt,
Temperature = 0.0m,
StopSequences = new[] { AnthropicSignals.HumanSignal },
Stream = false
Stream = false,
Model = AnthropicModels.Claude_v2_1
};

var response = await client.Completions.GetClaudeCompletionAsync(parameters);
Console.WriteLine(response.Completion);
Console.WriteLine(
$@"Tokens Used: Input - {prompt.GetClaudeTokenCount()}. Output - {response.Completion.GetClaudeTokenCount()}.");
```

### Streaming Call
Expand Down Expand Up @@ -103,14 +101,14 @@ var prompt = AnthropicSignals.HumanSignal + "Write me a sonnet about Joe Biden."
var parameters = new SamplingParameters()
{
// required
Model = AnthropicModels.Claude_v2_0
Model = AnthropicModels.Claude_v2_1
Prompt = prompt,
MaxTokensToSample = 512,

//optional
Temperature = 1,
Top_k = 1,
Top_p = 1
TopK = 1,
TopP = 1
StopSequences = new[] { AnthropicSignals.HumanSignal },
Stream = false
};
Expand Down

0 comments on commit 3acc7ab

Please sign in to comment.