docs: documentation for v0.1.0 [skip ci]

This commit is contained in:
Stevan Freeborn committed 2024-09-06 15:18:34 +00:00
1 parent 16b4373fca
commit 87f363e7cd
3 files changed
+34 -34

No files matched your search

+27 -27
View File
@@ -164,9 +164,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -422,9 +422,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -481,9 +481,9 @@ var finalResponse = await client.CreateMessageAsync(new MessageRequest(
if (finalResponse.IsSuccess is false) if (finalResponse.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", finalResponse.Error.Error.Type); Console.WriteLine("Error Type: {0}", finalResponse.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", finalResponse.Error.Error.Message); Console.WriteLine("Error Message: {0}", finalResponse.Error.Error.Message);
return; return;
} }
@@ -583,9 +583,9 @@ var finalResponse = await client.CreateMessageAsync(new MessageRequest(
if (finalResponse.IsSuccess is false) if (finalResponse.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", finalResponse.Error.Error.Type); Console.WriteLine("Error Type: {0}", finalResponse.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", finalResponse.Error.Error.Message); Console.WriteLine("Error Message: {0}", finalResponse.Error.Error.Message);
return; return;
} }
@@ -620,9 +620,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -657,9 +657,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -710,9 +710,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -746,9 +746,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
@@ -793,9 +793,9 @@ var response = await client.CreateMessageAsync(new MessageRequest(
if (response.IsSuccess is false) if (response.IsSuccess is false)
{ {
Console.WriteLine($"Failed to create message"); Console.WriteLine("Failed to create message");
Console.WriteLine($"Error Type: {0}", response.Error.Error.Type); Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
Console.WriteLine($"Error Message: {0}", response.Error.Error.Message); Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
return; return;
} }
+1 -1
View File
@@ -332,6 +332,6 @@
"index.html": { "index.html": {
"href": "index.html", "href": "index.html",
"title": "AnthropicClient | AnthropicClient", "title": "AnthropicClient | AnthropicClient",
"keywords": "AnthropicClient This library for the Anthropic API is meant to simplify development in C# for Anthropic users. Note This is an unofficial SDK for the Anthropic API. It was not built in consultation with Anthropic or any member of their organization. This SDK was developed independently using existing libraries and the Anthropic API documentation as the starting point with the intention of making development of integrations done in C# with Anthropic quicker and more convenient. Note This client library is heavily inspired by the Anthropic.SDK library. I chose to create a new library because I wanted to handle streaming and tool calling differently as well as have control over the client library as I plan to use it to build a connector for SemanticKernel. However if you are looking for a client library the Anthropic.SDK is a great place to start. 📝 Issues If you encounter any issues while using this library please open an issue here. 📜 License This library is licensed under the MIT License and is free to use and modify. 📝 Contributing If you would like to contribute to this library please open a pull request here. 🛠️ Dependencies Microsoft.Bcl.AsyncInterfaces Used to support async interfaces when streaming messages System.Text.Json Used for JSON serialization and deserialization 💾 Installation Install the package from NuGet using the following command: dotnet add package AnthropicClient 🔑 API Key In order to use the Anthropic API you will need an API key. You can get one by signing up at Anthropic. Please keep your API key secure and do not share it with others. Be mindful of where you store your API key and do not commit it to a public repository. 👨🏻‍💻 Start Coding AnthropicApiClient The most common way to use the SDK is to create an AnthropicApiClient instance and call its methods. Its constructor requires two parameters: apiKey - your Anthropic API key httpClient - an HttpClient instance. You can configure and customize the HttpClient instance as needed. This library however will perform the necessary configuration to work with the Anthropic API. Such as setting the base address and adding the proper headers. Note This library does not manage the lifecycle of the HttpClient instance. You should create and manage the lifecycle of the HttpClient instance in your application. It is best practice to read the API key from a secure location such as a configuration file or environment variable. For example using the appsettings.json file: { \"AnthropicApiKey\": \"YOUR_API\" } Example constructing an AnthropicApiClient instance: using AnthropicClient; using Microsoft.Extensions.Configuration; var configuration = new ConfigurationBuilder() .AddJsonFile(\"appsettings.json\") .Build(); var apiKey = configuration[\"AnthropicApiKey\"]; var client = new AnthropicApiClient(apiKey, new HttpClient()); IAnthropicApiClient The library does expose an interface IAnthropicApiClient that can be used for dependency injection and testing. The interface is implemented by the AnthropicApiClient class. Full API Documentation This library was developed to make using the Anthropic API easier within a .NET application. If you are looking for the full API documentation you can find it at Anthropic API Documentation. Usage The primary use case for working with the Anthropic API is to create a message in response to a request that includes one or more other messages. The created message can then be received either as a complete response or a stream of events. This can be used to create a conversation between the caller and Anthropic's AI models and/or to use Anthropic's AI models to perform a task. Note The following examples assume that you have already created an instance of the AnthropicApiClient class named client. You can also find these snippets in the examples directory. Create a message The AnthropicApiClient exposes a single method named CreateMessageAsync that can be used to create a message. The method requires a MessageRequest or a StreamMessageRequest instance as a parameter. The MessageRequest class is used to create a message whose response is not streamed and the StreamMessageRequest class is used to create a message whose response is streamed. The MessageRequest instance's properties can be set to configure how the message is created. Non-Streaming using AnthropicClient; using AnthropicClient.Models; var response = await client.CreateMessageAsync(new MessageRequest( AnthropicModels.Claude3Haiku, [ new( MessageRole.User, [new TextContent(\"Please write a haiku about the ocean.\")] ) ] )); if (response.IsSuccess is false) { Console.WriteLine($\"Failed to create message\"); Console.WriteLine($\"Error Type: {0}\", response.Error.Error.Type); Console.WriteLine($\"Error Message: {0}\", response.Error.Error.Message); return; } foreach (var content in response.Value.Content) { switch (content) { case TextContent textContent: Console.WriteLine(textContent.Text); break; } } Streaming Line truncated "keywords": "AnthropicClient This library for the Anthropic API is meant to simplify development in C# for Anthropic users. Note This is an unofficial SDK for the Anthropic API. It was not built in consultation with Anthropic or any member of their organization. This SDK was developed independently using existing libraries and the Anthropic API documentation as the starting point with the intention of making development of integrations done in C# with Anthropic quicker and more convenient. Note This client library is heavily inspired by the Anthropic.SDK library. I chose to create a new library because I wanted to handle streaming and tool calling differently as well as have control over the client library as I plan to use it to build a connector for SemanticKernel. However if you are looking for a client library the Anthropic.SDK is a great place to start. 📝 Issues If you encounter any issues while using this library please open an issue here. 📜 License This library is licensed under the MIT License and is free to use and modify. 📝 Contributing If you would like to contribute to this library please open a pull request here. 🛠️ Dependencies Microsoft.Bcl.AsyncInterfaces Used to support async interfaces when streaming messages System.Text.Json Used for JSON serialization and deserialization 💾 Installation Install the package from NuGet using the following command: dotnet add package AnthropicClient 🔑 API Key In order to use the Anthropic API you will need an API key. You can get one by signing up at Anthropic. Please keep your API key secure and do not share it with others. Be mindful of where you store your API key and do not commit it to a public repository. 👨🏻‍💻 Start Coding AnthropicApiClient The most common way to use the SDK is to create an AnthropicApiClient instance and call its methods. Its constructor requires two parameters: apiKey - your Anthropic API key httpClient - an HttpClient instance. You can configure and customize the HttpClient instance as needed. This library however will perform the necessary configuration to work with the Anthropic API. Such as setting the base address and adding the proper headers. Note This library does not manage the lifecycle of the HttpClient instance. You should create and manage the lifecycle of the HttpClient instance in your application. It is best practice to read the API key from a secure location such as a configuration file or environment variable. For example using the appsettings.json file: { \"AnthropicApiKey\": \"YOUR_API\" } Example constructing an AnthropicApiClient instance: using AnthropicClient; using Microsoft.Extensions.Configuration; var configuration = new ConfigurationBuilder() .AddJsonFile(\"appsettings.json\") .Build(); var apiKey = configuration[\"AnthropicApiKey\"]; var client = new AnthropicApiClient(apiKey, new HttpClient()); IAnthropicApiClient The library does expose an interface IAnthropicApiClient that can be used for dependency injection and testing. The interface is implemented by the AnthropicApiClient class. Full API Documentation This library was developed to make using the Anthropic API easier within a .NET application. If you are looking for the full API documentation you can find it at Anthropic API Documentation. Usage The primary use case for working with the Anthropic API is to create a message in response to a request that includes one or more other messages. The created message can then be received either as a complete response or a stream of events. This can be used to create a conversation between the caller and Anthropic's AI models and/or to use Anthropic's AI models to perform a task. Note The following examples assume that you have already created an instance of the AnthropicApiClient class named client. You can also find these snippets in the examples directory. Create a message The AnthropicApiClient exposes a single method named CreateMessageAsync that can be used to create a message. The method requires a MessageRequest or a StreamMessageRequest instance as a parameter. The MessageRequest class is used to create a message whose response is not streamed and the StreamMessageRequest class is used to create a message whose response is streamed. The MessageRequest instance's properties can be set to configure how the message is created. Non-Streaming using AnthropicClient; using AnthropicClient.Models; var response = await client.CreateMessageAsync(new MessageRequest( AnthropicModels.Claude3Haiku, [ new( MessageRole.User, [new TextContent(\"Please write a haiku about the ocean.\")] ) ] )); if (response.IsSuccess is false) { Console.WriteLine(\"Failed to create message\"); Console.WriteLine(\"Error Type: {0}\", response.Error.Error.Type); Console.WriteLine(\"Error Message: {0}\", response.Error.Error.Message); return; } foreach (var content in response.Value.Content) { switch (content) { case TextContent textContent: Console.WriteLine(textContent.Text); break; } } Streaming AntLine truncated
} }
} }
+6 -6
View File
@@ -674,11 +674,11 @@
"type": "Toc", "type": "Toc",
"source_relative_path": "api/toc.yml", "source_relative_path": "api/toc.yml",
"output": { "output": {
".json": {
"relative_path": "api/toc.json"
},
".html": { ".html": {
"relative_path": "api/toc.html" "relative_path": "api/toc.html"
},
".json": {
"relative_path": "api/toc.json"
} }
}, },
"version": "" "version": ""
@@ -697,11 +697,11 @@
"type": "Toc", "type": "Toc",
"source_relative_path": "toc.yml", "source_relative_path": "toc.yml",
"output": { "output": {
".json": {
"relative_path": "toc.json"
},
".html": { ".html": {
"relative_path": "toc.html" "relative_path": "toc.html"
},
".json": {
"relative_path": "toc.json"
} }
}, },
"version": "" "version": ""