Skip to content

Commit

Permalink
docs: Updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 20, 2023
1 parent c08bb53 commit 1a5cdfe
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ var response = await api.CompleteAsync(new CreateCompletionRequest
Max_tokens_to_sample = 250,
});
Console.WriteLine(response.Completion);

// or use history syntax
var response = await api.CompleteAsync(new CreateCompletionRequest
{
Model = ModelIds.ClaudeInstant,
Prompt = new[]
{
"What's the weather like today?".AsHumanMessage(),
"Sure! Could you please provide me with your location?".AsAssistantMessage(),
"Dubai, UAE".AsHumanMessage(),
}.AsPrompt(),
Max_tokens_to_sample = 300,
});
```

## Support
Expand Down
27 changes: 26 additions & 1 deletion src/tests/Anthropic.IntegrationTests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Anthropic.IntegrationTests;
public class GeneralTests
{
[TestMethod]
public async Task ListModels()
public async Task Complete()
{
var apiKey =
Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") ??
Expand All @@ -22,4 +22,29 @@ public async Task ListModels()
response.Completion.Should().NotBeNullOrEmpty();
response.Stop_reason.Should().Be(CreateCompletionResponseStop_reason.Stop_sequence);
}

[TestMethod]
public async Task CompleteHistory()
{
var apiKey =
Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY") ??
throw new AssertInconclusiveException("ANTHROPIC_API_KEY environment variable is not found.");

using var client = new HttpClient();
var api = new AnthropicApi(apiKey, client);
var response = await api.CompleteAsync(new CreateCompletionRequest
{
Model = ModelIds.ClaudeInstant,
Prompt = new []
{
"What's the weather like today?".AsHumanMessage(),
"Sure! Could you please provide me with your location?".AsAssistantMessage(),
"Dubai, UAE".AsHumanMessage(),
}.AsPrompt(),
Max_tokens_to_sample = 300,
});
response.Model.Should().Be(ModelIds.ClaudeInstant);
response.Completion.Should().NotBeNullOrEmpty();
response.Stop_reason.Should().Be(CreateCompletionResponseStop_reason.Stop_sequence);
}
}

0 comments on commit 1a5cdfe

Please sign in to comment.