Skip to content

Commit

Permalink
Merge pull request #4 from tghamm/feature/v1.1.0
Browse files Browse the repository at this point in the history
Exposes anthropic-version, corrects a few SamplingParameter types
  • Loading branch information
tghamm authored Jul 16, 2023
2 parents edd1bd8 + a0c82b8 commit 6dc5164
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Anthropic.SDK.Tests/Completions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public async Task TestClaudeCompletion()
{
MaxTokensToSample = 512,
Prompt = prompt,
Temperature = 0.0f,
Temperature = 0.0m,
StopSequences = new[] { "\n\nHuman:" },
Stream = false,
Model = "claude-1.3"
Model = "claude-2.0"
};

var response = await client.Completions.GetClaudeCompletionAsync(parameters);
Expand All @@ -36,10 +36,10 @@ public async Task TestClaudeStreamingCompletion()
{
MaxTokensToSample = 512,
Prompt = prompt,
Temperature = 0.0f,
Temperature = 0.0m,
StopSequences = new[] { "\n\nHuman:" },
Stream = true,
Model = "claude-1.3"
Model = "claude-2.0"
};

await foreach (var res in client.Completions.StreamClaudeCompletionAsync(parameters))
Expand Down
8 changes: 4 additions & 4 deletions Anthropic.SDK/Anthropic.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<PackageTags>Claude, AI, ML, API, Anthropic</PackageTags>
<Title>Claude API</Title>
<PackageReleaseNotes>
Initial Release.
Exposes anthropic-version, corrects a few SamplingParameter variable types.
</PackageReleaseNotes>
<PackageId>Anthropic.SDK</PackageId>
<Version>1.0.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Version>1.1.0</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
Expand Down
5 changes: 5 additions & 0 deletions Anthropic.SDK/AnthropicClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class AnthropicClient
/// </summary>
public string ApiVersion { get; set; } = "v1";

/// <summary>
/// Version of the Anthropic API
/// </summary>
public string AnthropicVersion { get; set; } = "2023-06-01";

/// <summary>
/// The API authentication information to use for API calls
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Anthropic.SDK/Completions/SamplingParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class SamplingParameters
public string Prompt { get; set; }

[JsonPropertyName("temperature")]
public double? Temperature { get; set; }
public decimal? Temperature { get; set; }

[JsonPropertyName("max_tokens_to_sample")]
public int MaxTokensToSample { get; set; }
Expand All @@ -20,7 +20,7 @@ public class SamplingParameters
public int? TopK { get; set; }

[JsonPropertyName("top_p")]
public float? TopP { get; set; }
public decimal? TopP { get; set; }

[JsonPropertyName("metadata")]
public dynamic Metadata { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Anthropic.SDK/EndpointBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected HttpClient GetClient()
var client = clientFactory != null ? clientFactory.CreateClient() : new HttpClient();

client.DefaultRequestHeaders.Add("x-api-key", Client.Auth.ApiKey);
client.DefaultRequestHeaders.Add("anthropic-version", "2023-06-01");
client.DefaultRequestHeaders.Add("anthropic-version", Client.AnthropicVersion);
client.DefaultRequestHeaders.Add("User-Agent", UserAgent);

return client;
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ var parameters = new SamplingParameters()
{
MaxTokensToSample = 512,
Prompt = prompt,
Temperature = 0.0f,
Temperature = 0.0m,
StopSequences = new[] { "\n\nHuman:" },
Stream = false,
Model = "claude-1.3"
Model = "claude-2.0"
};

var response = await client.Completions.GetClaudeCompletionAsync(parameters);
Expand All @@ -69,10 +69,10 @@ var parameters = new SamplingParameters()
{
MaxTokensToSample = 512,
Prompt = prompt,
Temperature = 0.0f,
Temperature = 0.0m,
StopSequences = new[] { "\n\nHuman:" },
Stream = true,
Model = "claude-1.3"
Model = "claude-2.0"
};

await foreach (var res in client.Completions.StreamClaudeCompletionAsync(parameters))
Expand Down

0 comments on commit 6dc5164

Please sign in to comment.