Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8a3d6c6cd | ||
|
|
26e5d297bb | ||
|
|
fc2932f3c5 | ||
|
|
ee9dbcf647 | ||
|
|
07cadf17af | ||
|
|
2794c52c2a | ||
|
|
56b3a53a2a | ||
|
|
7ec931dda5 | ||
|
|
a3ac1001f6 | ||
|
|
c11600c770 | ||
|
|
180a090195 | ||
|
|
ca2ecdcfc7 | ||
|
|
876c6f571c | ||
|
|
299af3b759 | ||
|
|
3034544ca4 | ||
|
|
c56adf394c | ||
|
|
0a6d89bd77 | ||
|
|
c5f3c5eca5 | ||
|
|
f8e01bf487 | ||
|
|
779a5ca281 | ||
|
|
854e4642ab | ||
|
|
15f5ad49e7 | ||
|
|
5e247a3c3a | ||
|
|
9548754d6c | ||
|
|
fe39f10382 |
@@ -971,3 +971,193 @@ foreach (var content in response.Value.Content)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Message Batches
|
||||
|
||||
Anthropic provides a feature called [Message Batches](https://docs.anthropic.com/en/docs/build-with-claude/message-batches) that allows you to send multiple messages in a single request. This feature is covered in depth in [Anthropic's API Documentation](https://docs.anthropic.com/en/docs/build-with-claude/message-batches).
|
||||
|
||||
#### Create a message batch
|
||||
|
||||
You can create a message batch that will consist of one or more requests to create messages.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var request = new MessageBatchRequest([
|
||||
new(
|
||||
Guid.NewGuid().ToString(),
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var response = await client.CreateMessageBatchAsync(request);
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to create message batch");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Message Batch Id: {0}", response.Value.Id);
|
||||
```
|
||||
|
||||
#### Get a message batch
|
||||
|
||||
You can retrieve a message batch by its id.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.GetMessageBatchAsync("batch-id");
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to get message batch");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Message Batch Id: {0}", response.Value.Id);
|
||||
```
|
||||
|
||||
#### Get a message batch results
|
||||
|
||||
You can retrieve the results of a message batch by its id. The results are returned as an `IAsyncEnumerable` collection so that they can be streamed and processed as they are received.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.GetMessageBatchResultsAsync("batch-id");
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to get message batch results");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
await foreach (var item in response.Value)
|
||||
{
|
||||
Console.WriteLine("Item Custom Id: {0}", result.CustomId);
|
||||
|
||||
switch (item.Result)
|
||||
{
|
||||
case SucceededMessageBatchResult successResult:
|
||||
foreach (var content in successResult.Message.Content)
|
||||
{
|
||||
if (content is TextContent textContent)
|
||||
{
|
||||
Console.WriteLine("Message Batch Result: {0}", textContent.Text);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Message Batch Result: {0}", item.Result.Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### List message batches
|
||||
|
||||
You can retrieve a page of message batches.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.ListMessageBatchesAsync();
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to list message batches");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var batch in response.Value.Data)
|
||||
{
|
||||
Console.WriteLine("Message Batch Id: {0}", batch.Id);
|
||||
}
|
||||
```
|
||||
|
||||
#### List all message batches
|
||||
|
||||
You can also retrieve all the pages of message batches without having to implement pagination yourself. This is done by returning an `IAsyncEnumerable` collection that can be streamed and processed as the pages are received.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var pageResponses = client.ListAllMessageBatchesAsync();
|
||||
|
||||
await foreach (var response in pageResponses)
|
||||
{
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to list message batches");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var batch in response.Value.Data)
|
||||
{
|
||||
Console.WriteLine("Message Batch Id: {0}", batch.Id);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Cancel a message batch
|
||||
|
||||
You can cancel a message batch by its id.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.CancelMessageBatchAsync("batch-id");
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to cancel message batch");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Message Batch Id: {0}", response.Value.Id);
|
||||
Console.WriteLine("Message Batch Status: {0}", response.Value.ProcessingStatus);
|
||||
```
|
||||
|
||||
#### Delete a message batch
|
||||
|
||||
You can delete a message batch that is no longer being processed by its id.
|
||||
|
||||
```csharp
|
||||
using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.DeleteMessageBatchAsync("batch-id");
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to delete message batch");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Message Batch Id: {0}", response.Value.Id);
|
||||
```
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_AnthropicApiClient" data-uid="AnthropicClient.AnthropicApiClient" class="text-break">
|
||||
Class AnthropicApiClient <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L39"><i class="bi bi-code-slash"></i></a>
|
||||
Class AnthropicApiClient <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L62"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
@@ -163,7 +163,7 @@ Class AnthropicApiClient <a class="header-action link-secondary" title="View so
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient__ctor_System_String_System_Net_Http_HttpClient_" data-uid="AnthropicClient.AnthropicApiClient.#ctor(System.String,System.Net.Http.HttpClient)">
|
||||
AnthropicApiClient(string, HttpClient)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L61"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L85"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="AnthropicClient.AnthropicApiClient.html">AnthropicApiClient</a> class.</p>
|
||||
@@ -209,7 +209,7 @@ Class AnthropicApiClient <a class="header-action link-secondary" title="View so
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_CountMessageTokensAsync_AnthropicClient_Models_CountMessageTokensRequest_" data-uid="AnthropicClient.AnthropicApiClient.CountMessageTokensAsync(AnthropicClient.Models.CountMessageTokensRequest)">
|
||||
CountMessageTokensAsync(CountMessageTokensRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L267"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L291"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Counts the tokens in a message asynchronously.</p>
|
||||
@@ -248,7 +248,7 @@ Class AnthropicApiClient <a class="header-action link-secondary" title="View so
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_CreateMessageAsync_AnthropicClient_Models_MessageRequest_" data-uid="AnthropicClient.AnthropicApiClient.CreateMessageAsync(AnthropicClient.Models.MessageRequest)">
|
||||
CreateMessageAsync(MessageRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L80"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L104"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Creates a message asynchronously.</p>
|
||||
@@ -287,7 +287,7 @@ Class AnthropicApiClient <a class="header-action link-secondary" title="View so
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_CreateMessageAsync_AnthropicClient_Models_StreamMessageRequest_" data-uid="AnthropicClient.AnthropicApiClient.CreateMessageAsync(AnthropicClient.Models.StreamMessageRequest)">
|
||||
CreateMessageAsync(StreamMessageRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L103"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L127"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Creates a message asynchronously and streams the response.</p>
|
||||
@@ -322,11 +322,128 @@ Class AnthropicApiClient <a class="header-action link-secondary" title="View so
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_AnthropicApiClient_GetModelAsync_" data-uid="AnthropicClient.AnthropicApiClient.GetModelAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_GetModelAsync_System_String_" data-uid="AnthropicClient.AnthropicApiClient.GetModelAsync(System.String)">
|
||||
GetModelAsync(string)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L363"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Gets a model by its ID asynchronously.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>modelId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd><p>The ID of the model to get.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>></dt>
|
||||
<dd><p>A task that represents the asynchronous operation. The task result contains the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_AnthropicApiClient_ListAllModelsAsync_" data-uid="AnthropicClient.AnthropicApiClient.ListAllModelsAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_ListAllModelsAsync_System_Int32_" data-uid="AnthropicClient.AnthropicApiClient.ListAllModelsAsync(System.Int32)">
|
||||
ListAllModelsAsync(int)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L327"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Lists the models asynchronously</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public IAsyncEnumerable<AnthropicResult<Page<AnthropicModel>>> ListAllModelsAsync(int limit = 20)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>limit</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
|
||||
<dd><p>The maximum number of models to return in each page.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1">IAsyncEnumerable</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.Page-1.html">Page</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>>></dt>
|
||||
<dd><p>An asynchronous enumerable that yields the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_AnthropicApiClient_ListModelsAsync_" data-uid="AnthropicClient.AnthropicApiClient.ListModelsAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_AnthropicApiClient_ListModelsAsync_AnthropicClient_Models_PagingRequest_" data-uid="AnthropicClient.AnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)">
|
||||
ListModelsAsync(PagingRequest?)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L308"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Lists the models asynchronously.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public Task<AnthropicResult<Page<AnthropicModel>>> ListModelsAsync(PagingRequest? request = null)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>request</code> <a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a></dt>
|
||||
<dd><p>The paging request to use for listing the models.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.Page-1.html">Page</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>>></dt>
|
||||
<dd><p>A task that represents the asynchronous operation. The task result contains the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L39" class="edit-link">Edit this page</a>
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L62" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_IAnthropicApiClient" data-uid="AnthropicClient.IAnthropicApiClient" class="text-break">
|
||||
Interface IAnthropicApiClient <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L14"><i class="bi bi-code-slash"></i></a>
|
||||
Interface IAnthropicApiClient <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L15"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
@@ -125,7 +125,7 @@ Interface IAnthropicApiClient <a class="header-action link-secondary" title="Vi
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_CountMessageTokensAsync_AnthropicClient_Models_CountMessageTokensRequest_" data-uid="AnthropicClient.IAnthropicApiClient.CountMessageTokensAsync(AnthropicClient.Models.CountMessageTokensRequest)">
|
||||
CountMessageTokensAsync(CountMessageTokensRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L35"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L36"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Counts the tokens in a message asynchronously.</p>
|
||||
@@ -164,7 +164,7 @@ Interface IAnthropicApiClient <a class="header-action link-secondary" title="Vi
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_CreateMessageAsync_AnthropicClient_Models_MessageRequest_" data-uid="AnthropicClient.IAnthropicApiClient.CreateMessageAsync(AnthropicClient.Models.MessageRequest)">
|
||||
CreateMessageAsync(MessageRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L21"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L22"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Creates a message asynchronously.</p>
|
||||
@@ -203,7 +203,7 @@ Interface IAnthropicApiClient <a class="header-action link-secondary" title="Vi
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_CreateMessageAsync_AnthropicClient_Models_StreamMessageRequest_" data-uid="AnthropicClient.IAnthropicApiClient.CreateMessageAsync(AnthropicClient.Models.StreamMessageRequest)">
|
||||
CreateMessageAsync(StreamMessageRequest)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L28"><i class="bi bi-code-slash"></i></a>
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L29"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Creates a message asynchronously and streams the response.</p>
|
||||
@@ -238,11 +238,128 @@ Interface IAnthropicApiClient <a class="header-action link-secondary" title="Vi
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_IAnthropicApiClient_GetModelAsync_" data-uid="AnthropicClient.IAnthropicApiClient.GetModelAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_GetModelAsync_System_String_" data-uid="AnthropicClient.IAnthropicApiClient.GetModelAsync(System.String)">
|
||||
GetModelAsync(string)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L58"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Gets a model by its ID asynchronously.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>modelId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd><p>The ID of the model to get.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>></dt>
|
||||
<dd><p>A task that represents the asynchronous operation. The task result contains the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_IAnthropicApiClient_ListAllModelsAsync_" data-uid="AnthropicClient.IAnthropicApiClient.ListAllModelsAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_ListAllModelsAsync_System_Int32_" data-uid="AnthropicClient.IAnthropicApiClient.ListAllModelsAsync(System.Int32)">
|
||||
ListAllModelsAsync(int)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L51"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Lists the models asynchronously</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">IAsyncEnumerable<AnthropicResult<Page<AnthropicModel>>> ListAllModelsAsync(int limit = 20)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>limit</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
|
||||
<dd><p>The maximum number of models to return in each page.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1">IAsyncEnumerable</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.Page-1.html">Page</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>>></dt>
|
||||
<dd><p>An asynchronous enumerable that yields the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_IAnthropicApiClient_ListModelsAsync_" data-uid="AnthropicClient.IAnthropicApiClient.ListModelsAsync*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_IAnthropicApiClient_ListModelsAsync_AnthropicClient_Models_PagingRequest_" data-uid="AnthropicClient.IAnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)">
|
||||
ListModelsAsync(PagingRequest?)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L43"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Lists the models asynchronously.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">Task<AnthropicResult<Page<AnthropicModel>>> ListModelsAsync(PagingRequest? request = null)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>request</code> <a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a></dt>
|
||||
<dd><p>The paging request to use for listing the models.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1">Task</a><<a class="xref" href="AnthropicResult-1.html">AnthropicResult</a><<a class="xref" href="AnthropicClient.Models.Page-1.html">Page</a><<a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>>>></dt>
|
||||
<dd><p>A task that represents the asynchronous operation. The task result contains the response as an <a class="xref" href="AnthropicResult-1.html">AnthropicResult<T></a> where T is <a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a> where T is <a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L14" class="edit-link">Edit this page</a>
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/AnthropicApiClient.cs/#L15" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,311 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Class AnthropicModel | AnthropicClient </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Class AnthropicModel | AnthropicClient ">
|
||||
|
||||
<meta name="description" content="Represents an Anthropic model.">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../public/main.css">
|
||||
<meta name="docfx:navrel" content="../toc.html">
|
||||
<meta name="docfx:tocrel" content="toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../">
|
||||
|
||||
|
||||
<meta name="docfx:docurl" content="https://github.com/StevanFreeborn/anthropic-client/new/main/apiSpec/new?filename=AnthropicClient_Models_AnthropicModel.md&value=---%0Auid%3A%20AnthropicClient.Models.AnthropicModel%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../index.html">
|
||||
<img id="logo" class="svg" src="../logo.svg" alt="AnthropicClient">
|
||||
AnthropicClient
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="AnthropicClient.Models.AnthropicModel">
|
||||
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_Models_AnthropicModel" data-uid="AnthropicClient.Models.AnthropicModel" class="text-break">
|
||||
Class AnthropicModel <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L8"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
<dl><dt>Namespace</dt><dd><a class="xref" href="AnthropicClient.html">AnthropicClient</a>.<a class="xref" href="AnthropicClient.Models.html">Models</a></dd></dl>
|
||||
<dl><dt>Assembly</dt><dd>AnthropicClient.dll</dd></dl>
|
||||
</div>
|
||||
|
||||
<div class="markdown summary"><p>Represents an Anthropic model.</p>
|
||||
</div>
|
||||
<div class="markdown conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public class AnthropicModel</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritance">
|
||||
<dt>Inheritance</dt>
|
||||
<dd>
|
||||
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
||||
<div><span class="xref">AnthropicModel</span></div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritedMembers">
|
||||
<dt>Inherited Members</dt>
|
||||
<dd>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="properties">Properties
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_AnthropicModel_CreatedAt_" data-uid="AnthropicClient.Models.AnthropicModel.CreatedAt*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_AnthropicModel_CreatedAt" data-uid="AnthropicClient.Models.AnthropicModel.CreatedAt">
|
||||
CreatedAt
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L29"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The created date of the model.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.datetimeoffset">DateTimeOffset</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_AnthropicModel_DisplayName_" data-uid="AnthropicClient.Models.AnthropicModel.DisplayName*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_AnthropicModel_DisplayName" data-uid="AnthropicClient.Models.AnthropicModel.DisplayName">
|
||||
DisplayName
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L23"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The display name of the model.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("display_name")]
|
||||
public string DisplayName { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_AnthropicModel_Id_" data-uid="AnthropicClient.Models.AnthropicModel.Id*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_AnthropicModel_Id" data-uid="AnthropicClient.Models.AnthropicModel.Id">
|
||||
Id
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L18"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The id of the model.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public string Id { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_AnthropicModel_Type_" data-uid="AnthropicClient.Models.AnthropicModel.Type*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_AnthropicModel_Type" data-uid="AnthropicClient.Models.AnthropicModel.Type">
|
||||
Type
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L13"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The type of the model.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public string Type { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/AnthropicModel.cs/#L8" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,228 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Class Page<T> | AnthropicClient </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Class Page<T> | AnthropicClient ">
|
||||
|
||||
<meta name="description" content="Represents a page with data.">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../public/main.css">
|
||||
<meta name="docfx:navrel" content="../toc.html">
|
||||
<meta name="docfx:tocrel" content="toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../">
|
||||
|
||||
|
||||
<meta name="docfx:docurl" content="https://github.com/StevanFreeborn/anthropic-client/new/main/apiSpec/new?filename=AnthropicClient_Models_Page_1.md&value=---%0Auid%3A%20AnthropicClient.Models.Page%601%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../index.html">
|
||||
<img id="logo" class="svg" src="../logo.svg" alt="AnthropicClient">
|
||||
AnthropicClient
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="AnthropicClient.Models.Page`1">
|
||||
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_Models_Page_1" data-uid="AnthropicClient.Models.Page`1" class="text-break">
|
||||
Class Page<T> <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L32"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
<dl><dt>Namespace</dt><dd><a class="xref" href="AnthropicClient.html">AnthropicClient</a>.<a class="xref" href="AnthropicClient.Models.html">Models</a></dd></dl>
|
||||
<dl><dt>Assembly</dt><dd>AnthropicClient.dll</dd></dl>
|
||||
</div>
|
||||
|
||||
<div class="markdown summary"><p>Represents a page with data.</p>
|
||||
</div>
|
||||
<div class="markdown conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public class Page<T> : Page</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Type Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>T</code></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
<dl class="typelist inheritance">
|
||||
<dt>Inheritance</dt>
|
||||
<dd>
|
||||
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
||||
<div><a class="xref" href="AnthropicClient.Models.Page.html">Page</a></div>
|
||||
<div><span class="xref">Page<T></span></div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritedMembers">
|
||||
<dt>Inherited Members</dt>
|
||||
<dd>
|
||||
<div>
|
||||
<a class="xref" href="AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_FirstId">Page.FirstId</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_LastId">Page.LastId</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_HasMore">Page.HasMore</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="properties">Properties
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_Page_1_Data_" data-uid="AnthropicClient.Models.Page`1.Data*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_Page_1_Data" data-uid="AnthropicClient.Models.Page`1.Data">
|
||||
Data
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L37"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The data in the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public T[] Data { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt>T[]</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L32" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,286 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Class Page | AnthropicClient </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Class Page | AnthropicClient ">
|
||||
|
||||
<meta name="description" content="Represents a page.">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../public/main.css">
|
||||
<meta name="docfx:navrel" content="../toc.html">
|
||||
<meta name="docfx:tocrel" content="toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../">
|
||||
|
||||
|
||||
<meta name="docfx:docurl" content="https://github.com/StevanFreeborn/anthropic-client/new/main/apiSpec/new?filename=AnthropicClient_Models_Page.md&value=---%0Auid%3A%20AnthropicClient.Models.Page%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../index.html">
|
||||
<img id="logo" class="svg" src="../logo.svg" alt="AnthropicClient">
|
||||
AnthropicClient
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="AnthropicClient.Models.Page">
|
||||
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_Models_Page" data-uid="AnthropicClient.Models.Page" class="text-break">
|
||||
Class Page <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L8"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
<dl><dt>Namespace</dt><dd><a class="xref" href="AnthropicClient.html">AnthropicClient</a>.<a class="xref" href="AnthropicClient.Models.html">Models</a></dd></dl>
|
||||
<dl><dt>Assembly</dt><dd>AnthropicClient.dll</dd></dl>
|
||||
</div>
|
||||
|
||||
<div class="markdown summary"><p>Represents a page.</p>
|
||||
</div>
|
||||
<div class="markdown conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public class Page</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritance">
|
||||
<dt>Inheritance</dt>
|
||||
<dd>
|
||||
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
||||
<div><span class="xref">Page</span></div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
<dl class="typelist derived">
|
||||
<dt>Derived</dt>
|
||||
<dd>
|
||||
<div><a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a></div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<dl class="typelist inheritedMembers">
|
||||
<dt>Inherited Members</dt>
|
||||
<dd>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="properties">Properties
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_Page_FirstId_" data-uid="AnthropicClient.Models.Page.FirstId*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_Page_FirstId" data-uid="AnthropicClient.Models.Page.FirstId">
|
||||
FirstId
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L13"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The id of the first item in the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("first_id")]
|
||||
public string? FirstId { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_Page_HasMore_" data-uid="AnthropicClient.Models.Page.HasMore*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_Page_HasMore" data-uid="AnthropicClient.Models.Page.HasMore">
|
||||
HasMore
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L25"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Indicates whether there is more data to be retrieved.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("has_more")]
|
||||
public bool HasMore { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_Page_LastId_" data-uid="AnthropicClient.Models.Page.LastId*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_Page_LastId" data-uid="AnthropicClient.Models.Page.LastId">
|
||||
LastId
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L19"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The id of the last item in the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("last_id")]
|
||||
public string? LastId { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/Page.cs/#L8" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,368 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Class PagingRequest | AnthropicClient </title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" content="Class PagingRequest | AnthropicClient ">
|
||||
|
||||
<meta name="description" content="Represents a request to page through a collection of items.">
|
||||
<link rel="icon" href="../favicon.ico">
|
||||
<link rel="stylesheet" href="../public/docfx.min.css">
|
||||
<link rel="stylesheet" href="../public/main.css">
|
||||
<meta name="docfx:navrel" content="../toc.html">
|
||||
<meta name="docfx:tocrel" content="toc.html">
|
||||
|
||||
<meta name="docfx:rel" content="../">
|
||||
|
||||
|
||||
<meta name="docfx:docurl" content="https://github.com/StevanFreeborn/anthropic-client/new/main/apiSpec/new?filename=AnthropicClient_Models_PagingRequest.md&value=---%0Auid%3A%20AnthropicClient.Models.PagingRequest%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">
|
||||
<meta name="loc:inThisArticle" content="In this article">
|
||||
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
||||
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
||||
<meta name="loc:tocFilter" content="Filter by title">
|
||||
<meta name="loc:nextArticle" content="Next">
|
||||
<meta name="loc:prevArticle" content="Previous">
|
||||
<meta name="loc:themeLight" content="Light">
|
||||
<meta name="loc:themeDark" content="Dark">
|
||||
<meta name="loc:themeAuto" content="Auto">
|
||||
<meta name="loc:changeTheme" content="Change theme">
|
||||
<meta name="loc:copy" content="Copy">
|
||||
<meta name="loc:downloadPdf" content="Download PDF">
|
||||
|
||||
<script type="module" src="./../public/docfx.min.js"></script>
|
||||
|
||||
<script>
|
||||
const theme = localStorage.getItem('theme') || 'auto'
|
||||
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
||||
<header class="bg-body border-bottom">
|
||||
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
||||
<div class="container-xxl flex-nowrap">
|
||||
<a class="navbar-brand" href="../index.html">
|
||||
<img id="logo" class="svg" src="../logo.svg" alt="AnthropicClient">
|
||||
AnthropicClient
|
||||
</a>
|
||||
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="bi bi-three-dots"></i>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navpanel">
|
||||
<div id="navbar">
|
||||
<form class="search" role="search" id="search">
|
||||
<i class="bi bi-search"></i>
|
||||
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-xxl">
|
||||
<div class="toc-offcanvas">
|
||||
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
||||
<div class="offcanvas-header">
|
||||
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body">
|
||||
<nav class="toc" id="toc"></nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="actionbar">
|
||||
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
||||
<i class="bi bi-list"></i>
|
||||
</button>
|
||||
|
||||
<nav id="breadcrumb"></nav>
|
||||
</div>
|
||||
|
||||
<article data-uid="AnthropicClient.Models.PagingRequest">
|
||||
|
||||
|
||||
|
||||
<h1 id="AnthropicClient_Models_PagingRequest" data-uid="AnthropicClient.Models.PagingRequest" class="text-break">
|
||||
Class PagingRequest <a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L8"><i class="bi bi-code-slash"></i></a>
|
||||
</h1>
|
||||
|
||||
<div class="facts text-secondary">
|
||||
<dl><dt>Namespace</dt><dd><a class="xref" href="AnthropicClient.html">AnthropicClient</a>.<a class="xref" href="AnthropicClient.Models.html">Models</a></dd></dl>
|
||||
<dl><dt>Assembly</dt><dd>AnthropicClient.dll</dd></dl>
|
||||
</div>
|
||||
|
||||
<div class="markdown summary"><p>Represents a request to page through a collection of items.</p>
|
||||
</div>
|
||||
<div class="markdown conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public class PagingRequest</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritance">
|
||||
<dt>Inheritance</dt>
|
||||
<dd>
|
||||
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
||||
<div><span class="xref">PagingRequest</span></div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<dl class="typelist inheritedMembers">
|
||||
<dt>Inherited Members</dt>
|
||||
<dd>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
||||
</div>
|
||||
<div>
|
||||
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="constructors">Constructors
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_PagingRequest__ctor_" data-uid="AnthropicClient.Models.PagingRequest.#ctor*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_PagingRequest__ctor_System_String_System_String_System_Int32_" data-uid="AnthropicClient.Models.PagingRequest.#ctor(System.String,System.String,System.Int32)">
|
||||
PagingRequest(string, string, int)
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L40"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a> class.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public PagingRequest(string beforeId = "", string afterId = "", int limit = 20)</code></pre>
|
||||
</div>
|
||||
|
||||
<h4 class="section">Parameters</h4>
|
||||
<dl class="parameters">
|
||||
<dt><code>beforeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd><p>The ID of the item before which to start the page.</p>
|
||||
</dd>
|
||||
<dt><code>afterId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd><p>The ID of the item after which to start the page.</p>
|
||||
</dd>
|
||||
<dt><code>limit</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
|
||||
<dd><p>The maximum number of items to return in the page.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Exceptions</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentexception">ArgumentException</a></dt>
|
||||
<dd><p>Thrown when both <code class="paramref">beforeId</code> and <code class="paramref">afterId</code> are specified.</p>
|
||||
</dd>
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception">ArgumentOutOfRangeException</a></dt>
|
||||
<dd><p>Thrown when <code class="paramref">limit</code> is less than 1 or greater than 1000.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="properties">Properties
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_PagingRequest_AfterId_" data-uid="AnthropicClient.Models.PagingRequest.AfterId*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_PagingRequest_AfterId" data-uid="AnthropicClient.Models.PagingRequest.AfterId">
|
||||
AfterId
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L23"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The ID of the item after which to start the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("after_id")]
|
||||
public string AfterId { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_PagingRequest_BeforeId_" data-uid="AnthropicClient.Models.PagingRequest.BeforeId*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_PagingRequest_BeforeId" data-uid="AnthropicClient.Models.PagingRequest.BeforeId">
|
||||
BeforeId
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L17"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The ID of the item before which to start the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">[JsonPropertyName("before_id")]
|
||||
public string BeforeId { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_PagingRequest_Limit_" data-uid="AnthropicClient.Models.PagingRequest.Limit*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_PagingRequest_Limit" data-uid="AnthropicClient.Models.PagingRequest.Limit">
|
||||
Limit
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L29"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>The maximum number of items to return in the page.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public int Limit { get; init; }</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="section">Property Value</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h2 class="section" id="methods">Methods
|
||||
</h2>
|
||||
|
||||
|
||||
<a id="AnthropicClient_Models_PagingRequest_ToQueryParameters_" data-uid="AnthropicClient.Models.PagingRequest.ToQueryParameters*"></a>
|
||||
|
||||
<h3 id="AnthropicClient_Models_PagingRequest_ToQueryParameters" data-uid="AnthropicClient.Models.PagingRequest.ToQueryParameters">
|
||||
ToQueryParameters()
|
||||
<a class="header-action link-secondary" title="View source" href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L65"><i class="bi bi-code-slash"></i></a>
|
||||
</h3>
|
||||
|
||||
<div class="markdown level1 summary"><p>Converts the <a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a> to a query string.</p>
|
||||
</div>
|
||||
<div class="markdown level1 conceptual"></div>
|
||||
|
||||
<div class="codewrapper">
|
||||
<pre><code class="lang-csharp hljs">public string ToQueryParameters()</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
<h4 class="section">Returns</h4>
|
||||
<dl class="parameters">
|
||||
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
||||
<dd><p>The query string representation of the <a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
<div class="contribution d-print-none">
|
||||
<a href="https://github.com/StevanFreeborn/anthropic-client/blob/main/src/AnthropicClient/Models/PagingRequest.cs/#L8" class="edit-link">Edit this page</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="affix">
|
||||
<nav id="affix"></nav>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<div class="container-xxl search-results" id="search-results"></div>
|
||||
|
||||
<footer class="border-top text-secondary">
|
||||
<div class="container-xxl">
|
||||
<div class="flex-fill">
|
||||
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -112,6 +112,11 @@ Classes
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.AnthropicHeaders.html">AnthropicHeaders</a></dt>
|
||||
<dd><p>Represents headers included in Anthropic API responses.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.AnthropicModel.html">AnthropicModel</a></dt>
|
||||
<dd><p>Represents an Anthropic model.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
@@ -332,6 +337,21 @@ Classes
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.OverloadedError.html">OverloadedError</a></dt>
|
||||
<dd><p>Represents an overloaded error.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.Page.html">Page</a></dt>
|
||||
<dd><p>Represents a page.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.Page-1.html">Page<T></a></dt>
|
||||
<dd><p>Represents a page with data.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
<dt><a class="xref" href="AnthropicClient.Models.PagingRequest.html">PagingRequest</a></dt>
|
||||
<dd><p>Represents a request to page through a collection of items.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="jumplist">
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.AnthropicHeaders.html" name="" title="AnthropicHeaders">AnthropicHeaders</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.AnthropicModel.html" name="" title="AnthropicModel">AnthropicModel</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.AnthropicModels.html" name="" title="AnthropicModels">AnthropicModels</a>
|
||||
</li>
|
||||
@@ -177,6 +180,15 @@
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.OverloadedError.html" name="" title="OverloadedError">OverloadedError</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.Page.html" name="" title="Page">Page</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.Page-1.html" name="" title="Page<T>">Page<T></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.PagingRequest.html" name="" title="PagingRequest">PagingRequest</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="AnthropicClient.Models.PermissionError.html" name="" title="PermissionError">PermissionError</a>
|
||||
</li>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -171,6 +171,62 @@ if (response.IsFailure)
|
||||
|
||||
Console.WriteLine("Token Count: {0}", response.Value.InputTokens);
|
||||
</code></pre>
|
||||
<h3 id="list-models">List Models</h3>
|
||||
<p>The <code>AnthropicApiClient</code> exposes a method named <code>ListModelsAsync</code> that can be used to list the available models. The method takes an optional <code>PagingRequest</code> instance as a parameter.</p>
|
||||
<pre><code class="lang-csharp">using AnthropicClient;
|
||||
|
||||
var response = await client.ListModelsAsync();
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to list models");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var model in response.Value.Data)
|
||||
{
|
||||
Console.WriteLine("Model Id: {0}", model.Id);
|
||||
Console.WriteLine("Model Name: {0}", model.DisplayName);
|
||||
}
|
||||
</code></pre>
|
||||
<p>Using the <code>PagingRequest</code> instance allows you to specify the number of models to return and the page of models to return.</p>
|
||||
<pre><code class="lang-csharp">using AnthropicClient;
|
||||
using AnthropicClient.Models;
|
||||
|
||||
var response = await client.ListModelsAsync(new PagingRequest(afterId: "claude-3-5-sonnet-20241022", limit: 2));
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to list models");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var model in response.Value.Data)
|
||||
{
|
||||
Console.WriteLine("Model Id: {0}", model.Id);
|
||||
Console.WriteLine("Model Name: {0}", model.DisplayName);
|
||||
}
|
||||
</code></pre>
|
||||
<h3 id="get-model">Get Model</h3>
|
||||
<p>The <code>AnthropicApiClient</code> exposes a method named <code>GetModelAsync</code> that can be used to get a model by its id.</p>
|
||||
<pre><code class="lang-csharp">using AnthropicClient;
|
||||
|
||||
var response = await client.GetModelAsync("claude-3-5-sonnet-20241022");
|
||||
|
||||
if (response.IsFailure)
|
||||
{
|
||||
Console.WriteLine("Failed to get model");
|
||||
Console.WriteLine("Error Type: {0}", response.Error.Error.Type);
|
||||
Console.WriteLine("Error Message: {0}", response.Error.Error.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Model Id: {0}", response.Value.Id);
|
||||
</code></pre>
|
||||
<h3 id="create-a-message">Create a message</h3>
|
||||
<p>The <code>AnthropicApiClient</code> exposes a method named <code>CreateMessageAsync</code> that can be used to create a message. The method requires a <code>MessageRequest</code> or a <code>StreamMessageRequest</code> instance as a parameter. The <code>MessageRequest</code> class is used to create a message whose response is not streamed and the <code>StreamMessageRequest</code> class is used to create a message whose response is streamed. The <code>MessageRequest</code> instance's properties can be set to configure how the message is created.</p>
|
||||
<h4 id="non-streaming">Non-Streaming</h4>
|
||||
|
||||
+24
-4
File diff suppressed because one or more lines are too long
@@ -70,6 +70,16 @@
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.AnthropicModel.yml",
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "api/AnthropicClient.Models.AnthropicModel.html"
|
||||
}
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.AnthropicModels.yml",
|
||||
@@ -520,6 +530,36 @@
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.Page-1.yml",
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "api/AnthropicClient.Models.Page-1.html"
|
||||
}
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.Page.yml",
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "api/AnthropicClient.Models.Page.html"
|
||||
}
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.PagingRequest.yml",
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "api/AnthropicClient.Models.PagingRequest.html"
|
||||
}
|
||||
},
|
||||
"version": ""
|
||||
},
|
||||
{
|
||||
"type": "ManagedReference",
|
||||
"source_relative_path": "api/AnthropicClient.Models.PermissionError.yml",
|
||||
|
||||
@@ -64,6 +64,54 @@ references:
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.AnthropicApiClient.CreateMessageAsync
|
||||
nameWithType: AnthropicApiClient.CreateMessageAsync
|
||||
- uid: AnthropicClient.AnthropicApiClient.GetModelAsync(System.String)
|
||||
name: GetModelAsync(string)
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_GetModelAsync_System_String_
|
||||
commentId: M:AnthropicClient.AnthropicApiClient.GetModelAsync(System.String)
|
||||
name.vb: GetModelAsync(String)
|
||||
fullName: AnthropicClient.AnthropicApiClient.GetModelAsync(string)
|
||||
fullName.vb: AnthropicClient.AnthropicApiClient.GetModelAsync(String)
|
||||
nameWithType: AnthropicApiClient.GetModelAsync(string)
|
||||
nameWithType.vb: AnthropicApiClient.GetModelAsync(String)
|
||||
- uid: AnthropicClient.AnthropicApiClient.GetModelAsync*
|
||||
name: GetModelAsync
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_GetModelAsync_
|
||||
commentId: Overload:AnthropicClient.AnthropicApiClient.GetModelAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.AnthropicApiClient.GetModelAsync
|
||||
nameWithType: AnthropicApiClient.GetModelAsync
|
||||
- uid: AnthropicClient.AnthropicApiClient.ListAllModelsAsync(System.Int32)
|
||||
name: ListAllModelsAsync(int)
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_ListAllModelsAsync_System_Int32_
|
||||
commentId: M:AnthropicClient.AnthropicApiClient.ListAllModelsAsync(System.Int32)
|
||||
name.vb: ListAllModelsAsync(Integer)
|
||||
fullName: AnthropicClient.AnthropicApiClient.ListAllModelsAsync(int)
|
||||
fullName.vb: AnthropicClient.AnthropicApiClient.ListAllModelsAsync(Integer)
|
||||
nameWithType: AnthropicApiClient.ListAllModelsAsync(int)
|
||||
nameWithType.vb: AnthropicApiClient.ListAllModelsAsync(Integer)
|
||||
- uid: AnthropicClient.AnthropicApiClient.ListAllModelsAsync*
|
||||
name: ListAllModelsAsync
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_ListAllModelsAsync_
|
||||
commentId: Overload:AnthropicClient.AnthropicApiClient.ListAllModelsAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.AnthropicApiClient.ListAllModelsAsync
|
||||
nameWithType: AnthropicApiClient.ListAllModelsAsync
|
||||
- uid: AnthropicClient.AnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
name: ListModelsAsync(PagingRequest?)
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_ListModelsAsync_AnthropicClient_Models_PagingRequest_
|
||||
commentId: M:AnthropicClient.AnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
name.vb: ListModelsAsync(PagingRequest)
|
||||
fullName: AnthropicClient.AnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest?)
|
||||
fullName.vb: AnthropicClient.AnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
nameWithType: AnthropicApiClient.ListModelsAsync(PagingRequest?)
|
||||
nameWithType.vb: AnthropicApiClient.ListModelsAsync(PagingRequest)
|
||||
- uid: AnthropicClient.AnthropicApiClient.ListModelsAsync*
|
||||
name: ListModelsAsync
|
||||
href: api/AnthropicClient.AnthropicApiClient.html#AnthropicClient_AnthropicApiClient_ListModelsAsync_
|
||||
commentId: Overload:AnthropicClient.AnthropicApiClient.ListModelsAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.AnthropicApiClient.ListModelsAsync
|
||||
nameWithType: AnthropicApiClient.ListModelsAsync
|
||||
- uid: AnthropicClient.IAnthropicApiClient
|
||||
name: IAnthropicApiClient
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html
|
||||
@@ -102,6 +150,54 @@ references:
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.IAnthropicApiClient.CreateMessageAsync
|
||||
nameWithType: IAnthropicApiClient.CreateMessageAsync
|
||||
- uid: AnthropicClient.IAnthropicApiClient.GetModelAsync(System.String)
|
||||
name: GetModelAsync(string)
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_GetModelAsync_System_String_
|
||||
commentId: M:AnthropicClient.IAnthropicApiClient.GetModelAsync(System.String)
|
||||
name.vb: GetModelAsync(String)
|
||||
fullName: AnthropicClient.IAnthropicApiClient.GetModelAsync(string)
|
||||
fullName.vb: AnthropicClient.IAnthropicApiClient.GetModelAsync(String)
|
||||
nameWithType: IAnthropicApiClient.GetModelAsync(string)
|
||||
nameWithType.vb: IAnthropicApiClient.GetModelAsync(String)
|
||||
- uid: AnthropicClient.IAnthropicApiClient.GetModelAsync*
|
||||
name: GetModelAsync
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_GetModelAsync_
|
||||
commentId: Overload:AnthropicClient.IAnthropicApiClient.GetModelAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.IAnthropicApiClient.GetModelAsync
|
||||
nameWithType: IAnthropicApiClient.GetModelAsync
|
||||
- uid: AnthropicClient.IAnthropicApiClient.ListAllModelsAsync(System.Int32)
|
||||
name: ListAllModelsAsync(int)
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_ListAllModelsAsync_System_Int32_
|
||||
commentId: M:AnthropicClient.IAnthropicApiClient.ListAllModelsAsync(System.Int32)
|
||||
name.vb: ListAllModelsAsync(Integer)
|
||||
fullName: AnthropicClient.IAnthropicApiClient.ListAllModelsAsync(int)
|
||||
fullName.vb: AnthropicClient.IAnthropicApiClient.ListAllModelsAsync(Integer)
|
||||
nameWithType: IAnthropicApiClient.ListAllModelsAsync(int)
|
||||
nameWithType.vb: IAnthropicApiClient.ListAllModelsAsync(Integer)
|
||||
- uid: AnthropicClient.IAnthropicApiClient.ListAllModelsAsync*
|
||||
name: ListAllModelsAsync
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_ListAllModelsAsync_
|
||||
commentId: Overload:AnthropicClient.IAnthropicApiClient.ListAllModelsAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.IAnthropicApiClient.ListAllModelsAsync
|
||||
nameWithType: IAnthropicApiClient.ListAllModelsAsync
|
||||
- uid: AnthropicClient.IAnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
name: ListModelsAsync(PagingRequest?)
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_ListModelsAsync_AnthropicClient_Models_PagingRequest_
|
||||
commentId: M:AnthropicClient.IAnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
name.vb: ListModelsAsync(PagingRequest)
|
||||
fullName: AnthropicClient.IAnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest?)
|
||||
fullName.vb: AnthropicClient.IAnthropicApiClient.ListModelsAsync(AnthropicClient.Models.PagingRequest)
|
||||
nameWithType: IAnthropicApiClient.ListModelsAsync(PagingRequest?)
|
||||
nameWithType.vb: IAnthropicApiClient.ListModelsAsync(PagingRequest)
|
||||
- uid: AnthropicClient.IAnthropicApiClient.ListModelsAsync*
|
||||
name: ListModelsAsync
|
||||
href: api/AnthropicClient.IAnthropicApiClient.html#AnthropicClient_IAnthropicApiClient_ListModelsAsync_
|
||||
commentId: Overload:AnthropicClient.IAnthropicApiClient.ListModelsAsync
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.IAnthropicApiClient.ListModelsAsync
|
||||
nameWithType: IAnthropicApiClient.ListModelsAsync
|
||||
- uid: AnthropicClient.Models
|
||||
name: AnthropicClient.Models
|
||||
href: api/AnthropicClient.Models.html
|
||||
@@ -371,6 +467,64 @@ references:
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.AnthropicHeaders.RetryAfter
|
||||
nameWithType: AnthropicHeaders.RetryAfter
|
||||
- uid: AnthropicClient.Models.AnthropicModel
|
||||
name: AnthropicModel
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html
|
||||
commentId: T:AnthropicClient.Models.AnthropicModel
|
||||
fullName: AnthropicClient.Models.AnthropicModel
|
||||
nameWithType: AnthropicModel
|
||||
- uid: AnthropicClient.Models.AnthropicModel.CreatedAt
|
||||
name: CreatedAt
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_CreatedAt
|
||||
commentId: P:AnthropicClient.Models.AnthropicModel.CreatedAt
|
||||
fullName: AnthropicClient.Models.AnthropicModel.CreatedAt
|
||||
nameWithType: AnthropicModel.CreatedAt
|
||||
- uid: AnthropicClient.Models.AnthropicModel.CreatedAt*
|
||||
name: CreatedAt
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_CreatedAt_
|
||||
commentId: Overload:AnthropicClient.Models.AnthropicModel.CreatedAt
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.AnthropicModel.CreatedAt
|
||||
nameWithType: AnthropicModel.CreatedAt
|
||||
- uid: AnthropicClient.Models.AnthropicModel.DisplayName
|
||||
name: DisplayName
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_DisplayName
|
||||
commentId: P:AnthropicClient.Models.AnthropicModel.DisplayName
|
||||
fullName: AnthropicClient.Models.AnthropicModel.DisplayName
|
||||
nameWithType: AnthropicModel.DisplayName
|
||||
- uid: AnthropicClient.Models.AnthropicModel.DisplayName*
|
||||
name: DisplayName
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_DisplayName_
|
||||
commentId: Overload:AnthropicClient.Models.AnthropicModel.DisplayName
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.AnthropicModel.DisplayName
|
||||
nameWithType: AnthropicModel.DisplayName
|
||||
- uid: AnthropicClient.Models.AnthropicModel.Id
|
||||
name: Id
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_Id
|
||||
commentId: P:AnthropicClient.Models.AnthropicModel.Id
|
||||
fullName: AnthropicClient.Models.AnthropicModel.Id
|
||||
nameWithType: AnthropicModel.Id
|
||||
- uid: AnthropicClient.Models.AnthropicModel.Id*
|
||||
name: Id
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_Id_
|
||||
commentId: Overload:AnthropicClient.Models.AnthropicModel.Id
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.AnthropicModel.Id
|
||||
nameWithType: AnthropicModel.Id
|
||||
- uid: AnthropicClient.Models.AnthropicModel.Type
|
||||
name: Type
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_Type
|
||||
commentId: P:AnthropicClient.Models.AnthropicModel.Type
|
||||
fullName: AnthropicClient.Models.AnthropicModel.Type
|
||||
nameWithType: AnthropicModel.Type
|
||||
- uid: AnthropicClient.Models.AnthropicModel.Type*
|
||||
name: Type
|
||||
href: api/AnthropicClient.Models.AnthropicModel.html#AnthropicClient_Models_AnthropicModel_Type_
|
||||
commentId: Overload:AnthropicClient.Models.AnthropicModel.Type
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.AnthropicModel.Type
|
||||
nameWithType: AnthropicModel.Type
|
||||
- uid: AnthropicClient.Models.AnthropicModels
|
||||
name: AnthropicModels
|
||||
href: api/AnthropicClient.Models.AnthropicModels.html
|
||||
@@ -2553,6 +2707,154 @@ references:
|
||||
fullName.vb: AnthropicClient.Models.OverloadedError.New
|
||||
nameWithType: OverloadedError.OverloadedError
|
||||
nameWithType.vb: OverloadedError.New
|
||||
- uid: AnthropicClient.Models.Page
|
||||
name: Page
|
||||
href: api/AnthropicClient.Models.Page.html
|
||||
commentId: T:AnthropicClient.Models.Page
|
||||
fullName: AnthropicClient.Models.Page
|
||||
nameWithType: Page
|
||||
- uid: AnthropicClient.Models.Page.FirstId
|
||||
name: FirstId
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_FirstId
|
||||
commentId: P:AnthropicClient.Models.Page.FirstId
|
||||
fullName: AnthropicClient.Models.Page.FirstId
|
||||
nameWithType: Page.FirstId
|
||||
- uid: AnthropicClient.Models.Page.FirstId*
|
||||
name: FirstId
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_FirstId_
|
||||
commentId: Overload:AnthropicClient.Models.Page.FirstId
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.Page.FirstId
|
||||
nameWithType: Page.FirstId
|
||||
- uid: AnthropicClient.Models.Page.HasMore
|
||||
name: HasMore
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_HasMore
|
||||
commentId: P:AnthropicClient.Models.Page.HasMore
|
||||
fullName: AnthropicClient.Models.Page.HasMore
|
||||
nameWithType: Page.HasMore
|
||||
- uid: AnthropicClient.Models.Page.HasMore*
|
||||
name: HasMore
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_HasMore_
|
||||
commentId: Overload:AnthropicClient.Models.Page.HasMore
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.Page.HasMore
|
||||
nameWithType: Page.HasMore
|
||||
- uid: AnthropicClient.Models.Page.LastId
|
||||
name: LastId
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_LastId
|
||||
commentId: P:AnthropicClient.Models.Page.LastId
|
||||
fullName: AnthropicClient.Models.Page.LastId
|
||||
nameWithType: Page.LastId
|
||||
- uid: AnthropicClient.Models.Page.LastId*
|
||||
name: LastId
|
||||
href: api/AnthropicClient.Models.Page.html#AnthropicClient_Models_Page_LastId_
|
||||
commentId: Overload:AnthropicClient.Models.Page.LastId
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.Page.LastId
|
||||
nameWithType: Page.LastId
|
||||
- uid: AnthropicClient.Models.Page`1
|
||||
name: Page<T>
|
||||
href: api/AnthropicClient.Models.Page-1.html
|
||||
commentId: T:AnthropicClient.Models.Page`1
|
||||
name.vb: Page(Of T)
|
||||
fullName: AnthropicClient.Models.Page<T>
|
||||
fullName.vb: AnthropicClient.Models.Page(Of T)
|
||||
nameWithType: Page<T>
|
||||
nameWithType.vb: Page(Of T)
|
||||
- uid: AnthropicClient.Models.Page`1.Data
|
||||
name: Data
|
||||
href: api/AnthropicClient.Models.Page-1.html#AnthropicClient_Models_Page_1_Data
|
||||
commentId: P:AnthropicClient.Models.Page`1.Data
|
||||
fullName: AnthropicClient.Models.Page<T>.Data
|
||||
fullName.vb: AnthropicClient.Models.Page(Of T).Data
|
||||
nameWithType: Page<T>.Data
|
||||
nameWithType.vb: Page(Of T).Data
|
||||
- uid: AnthropicClient.Models.Page`1.Data*
|
||||
name: Data
|
||||
href: api/AnthropicClient.Models.Page-1.html#AnthropicClient_Models_Page_1_Data_
|
||||
commentId: Overload:AnthropicClient.Models.Page`1.Data
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.Page<T>.Data
|
||||
fullName.vb: AnthropicClient.Models.Page(Of T).Data
|
||||
nameWithType: Page<T>.Data
|
||||
nameWithType.vb: Page(Of T).Data
|
||||
- uid: AnthropicClient.Models.PagingRequest
|
||||
name: PagingRequest
|
||||
href: api/AnthropicClient.Models.PagingRequest.html
|
||||
commentId: T:AnthropicClient.Models.PagingRequest
|
||||
fullName: AnthropicClient.Models.PagingRequest
|
||||
nameWithType: PagingRequest
|
||||
- uid: AnthropicClient.Models.PagingRequest.#ctor(System.String,System.String,System.Int32)
|
||||
name: PagingRequest(string, string, int)
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest__ctor_System_String_System_String_System_Int32_
|
||||
commentId: M:AnthropicClient.Models.PagingRequest.#ctor(System.String,System.String,System.Int32)
|
||||
name.vb: New(String, String, Integer)
|
||||
fullName: AnthropicClient.Models.PagingRequest.PagingRequest(string, string, int)
|
||||
fullName.vb: AnthropicClient.Models.PagingRequest.New(String, String, Integer)
|
||||
nameWithType: PagingRequest.PagingRequest(string, string, int)
|
||||
nameWithType.vb: PagingRequest.New(String, String, Integer)
|
||||
- uid: AnthropicClient.Models.PagingRequest.#ctor*
|
||||
name: PagingRequest
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest__ctor_
|
||||
commentId: Overload:AnthropicClient.Models.PagingRequest.#ctor
|
||||
isSpec: "True"
|
||||
name.vb: New
|
||||
fullName: AnthropicClient.Models.PagingRequest.PagingRequest
|
||||
fullName.vb: AnthropicClient.Models.PagingRequest.New
|
||||
nameWithType: PagingRequest.PagingRequest
|
||||
nameWithType.vb: PagingRequest.New
|
||||
- uid: AnthropicClient.Models.PagingRequest.AfterId
|
||||
name: AfterId
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_AfterId
|
||||
commentId: P:AnthropicClient.Models.PagingRequest.AfterId
|
||||
fullName: AnthropicClient.Models.PagingRequest.AfterId
|
||||
nameWithType: PagingRequest.AfterId
|
||||
- uid: AnthropicClient.Models.PagingRequest.AfterId*
|
||||
name: AfterId
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_AfterId_
|
||||
commentId: Overload:AnthropicClient.Models.PagingRequest.AfterId
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.PagingRequest.AfterId
|
||||
nameWithType: PagingRequest.AfterId
|
||||
- uid: AnthropicClient.Models.PagingRequest.BeforeId
|
||||
name: BeforeId
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_BeforeId
|
||||
commentId: P:AnthropicClient.Models.PagingRequest.BeforeId
|
||||
fullName: AnthropicClient.Models.PagingRequest.BeforeId
|
||||
nameWithType: PagingRequest.BeforeId
|
||||
- uid: AnthropicClient.Models.PagingRequest.BeforeId*
|
||||
name: BeforeId
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_BeforeId_
|
||||
commentId: Overload:AnthropicClient.Models.PagingRequest.BeforeId
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.PagingRequest.BeforeId
|
||||
nameWithType: PagingRequest.BeforeId
|
||||
- uid: AnthropicClient.Models.PagingRequest.Limit
|
||||
name: Limit
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_Limit
|
||||
commentId: P:AnthropicClient.Models.PagingRequest.Limit
|
||||
fullName: AnthropicClient.Models.PagingRequest.Limit
|
||||
nameWithType: PagingRequest.Limit
|
||||
- uid: AnthropicClient.Models.PagingRequest.Limit*
|
||||
name: Limit
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_Limit_
|
||||
commentId: Overload:AnthropicClient.Models.PagingRequest.Limit
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.PagingRequest.Limit
|
||||
nameWithType: PagingRequest.Limit
|
||||
- uid: AnthropicClient.Models.PagingRequest.ToQueryParameters
|
||||
name: ToQueryParameters()
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_ToQueryParameters
|
||||
commentId: M:AnthropicClient.Models.PagingRequest.ToQueryParameters
|
||||
fullName: AnthropicClient.Models.PagingRequest.ToQueryParameters()
|
||||
nameWithType: PagingRequest.ToQueryParameters()
|
||||
- uid: AnthropicClient.Models.PagingRequest.ToQueryParameters*
|
||||
name: ToQueryParameters
|
||||
href: api/AnthropicClient.Models.PagingRequest.html#AnthropicClient_Models_PagingRequest_ToQueryParameters_
|
||||
commentId: Overload:AnthropicClient.Models.PagingRequest.ToQueryParameters
|
||||
isSpec: "True"
|
||||
fullName: AnthropicClient.Models.PagingRequest.ToQueryParameters
|
||||
nameWithType: PagingRequest.ToQueryParameters
|
||||
- uid: AnthropicClient.Models.PermissionError
|
||||
name: PermissionError
|
||||
href: api/AnthropicClient.Models.PermissionError.html
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using AnthropicClient.Json;
|
||||
using AnthropicClient.Models;
|
||||
@@ -9,62 +8,14 @@ using AnthropicClient.Utils;
|
||||
|
||||
namespace AnthropicClient;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a client for interacting with the Anthropic API.
|
||||
/// </summary>
|
||||
public interface IAnthropicApiClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The message request to create.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/>.</returns>
|
||||
Task<AnthropicResult<MessageResponse>> CreateMessageAsync(MessageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a message asynchronously and streams the response.
|
||||
/// </summary>
|
||||
/// <param name="request">The message request to create.</param>
|
||||
/// <returns>An asynchronous enumerable that yields the response event by event.</returns>
|
||||
IAsyncEnumerable<AnthropicEvent> CreateMessageAsync(StreamMessageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Counts the tokens in a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The count message tokens request.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="TokenCountResponse"/>.</returns>
|
||||
Task<AnthropicResult<TokenCountResponse>> CountMessageTokensAsync(CountMessageTokensRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the models asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The paging request to use for listing the models.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
Task<AnthropicResult<Page<AnthropicModel>>> ListModelsAsync(PagingRequest? request = null);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the models asynchronously
|
||||
/// </summary>
|
||||
/// <param name="limit">The maximum number of models to return in each page.</param>
|
||||
/// <returns>An asynchronous enumerable that yields the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
///
|
||||
IAsyncEnumerable<AnthropicResult<Page<AnthropicModel>>> ListAllModelsAsync(int limit = 20);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a model by its ID asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="modelId">The ID of the model to get.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IAnthropicApiClient"/>
|
||||
public class AnthropicApiClient : IAnthropicApiClient
|
||||
{
|
||||
private const string BaseUrl = "https://api.anthropic.com/v1/";
|
||||
private const string ApiKeyHeader = "x-api-key";
|
||||
private const string MessagesEndpoint = "messages";
|
||||
private const string CountTokensEndpoint = "messages/count_tokens";
|
||||
private string CountTokensEndpoint => $"{MessagesEndpoint}/count_tokens";
|
||||
private string MessageBatchesEndpoint => $"{MessagesEndpoint}/batches";
|
||||
private const string ModelsEndpoint = "models";
|
||||
private const string JsonContentType = "application/json";
|
||||
private const string EventPrefix = "event:";
|
||||
@@ -288,20 +239,90 @@ public class AnthropicApiClient : IAnthropicApiClient
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<TokenCountResponse>> CountMessageTokensAsync(CountMessageTokensRequest request)
|
||||
public async Task<AnthropicResult<MessageBatchResponse>> CreateMessageBatchAsync(MessageBatchRequest request)
|
||||
{
|
||||
var response = await SendRequestAsync(CountTokensEndpoint, request);
|
||||
var response = await SendRequestAsync(MessageBatchesEndpoint, request);
|
||||
return await CreateResultAsync<MessageBatchResponse>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<MessageBatchResponse>> GetMessageBatchAsync(string batchId)
|
||||
{
|
||||
var response = await SendRequestAsync($"{MessageBatchesEndpoint}/{batchId}");
|
||||
return await CreateResultAsync<MessageBatchResponse>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<Page<MessageBatchResponse>>> ListMessageBatchesAsync(PagingRequest? request = null)
|
||||
{
|
||||
var pagingRequest = request ?? new PagingRequest();
|
||||
var endpoint = $"{MessageBatchesEndpoint}?{pagingRequest.ToQueryParameters()}";
|
||||
var response = await SendRequestAsync(endpoint);
|
||||
return await CreateResultAsync<Page<MessageBatchResponse>>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async IAsyncEnumerable<AnthropicResult<Page<MessageBatchResponse>>> ListAllMessageBatchesAsync(int limit = 20)
|
||||
{
|
||||
await foreach (var result in GetAllPagesAsync<MessageBatchResponse>(MessageBatchesEndpoint, limit))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<MessageBatchResponse>> CancelMessageBatchAsync(string batchId)
|
||||
{
|
||||
var endpoint = $"{MessageBatchesEndpoint}/{batchId}/cancel";
|
||||
var response = await SendRequestAsync(endpoint, HttpMethod.Post);
|
||||
return await CreateResultAsync<MessageBatchResponse>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<MessageBatchDeleteResponse>> DeleteMessageBatchAsync(string batchId)
|
||||
{
|
||||
var endpoint = $"{MessageBatchesEndpoint}/{batchId}";
|
||||
var response = await SendRequestAsync(endpoint, HttpMethod.Delete);
|
||||
return await CreateResultAsync<MessageBatchDeleteResponse>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<IAsyncEnumerable<MessageBatchResultItem>>> GetMessageBatchResultsAsync(string batchId)
|
||||
{
|
||||
var response = await SendRequestAsync($"{MessageBatchesEndpoint}/{batchId}/results");
|
||||
var anthropicHeaders = new AnthropicHeaders(response.Headers);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode is false)
|
||||
{
|
||||
var error = Deserialize<AnthropicError>(responseContent) ?? new AnthropicError();
|
||||
return AnthropicResult<TokenCountResponse>.Failure(error, anthropicHeaders);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var error = Deserialize<AnthropicError>(content) ?? new AnthropicError();
|
||||
return AnthropicResult<IAsyncEnumerable<MessageBatchResultItem>>.Failure(error, anthropicHeaders);
|
||||
}
|
||||
|
||||
var msgResponse = Deserialize<TokenCountResponse>(responseContent) ?? new TokenCountResponse();
|
||||
return AnthropicResult<TokenCountResponse>.Success(msgResponse, anthropicHeaders);
|
||||
return AnthropicResult<IAsyncEnumerable<MessageBatchResultItem>>.Success(ReadResultsAsync(), anthropicHeaders);
|
||||
|
||||
async IAsyncEnumerable<MessageBatchResultItem> ReadResultsAsync()
|
||||
{
|
||||
using var responseContent = await response.Content.ReadAsStreamAsync();
|
||||
using var streamReader = new StreamReader(responseContent);
|
||||
|
||||
var line = await streamReader.ReadLineAsync();
|
||||
|
||||
while (line is not null)
|
||||
{
|
||||
var resultItem = Deserialize<MessageBatchResultItem>(line) ?? new MessageBatchResultItem();
|
||||
yield return resultItem;
|
||||
|
||||
line = await streamReader.ReadLineAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<TokenCountResponse>> CountMessageTokensAsync(CountMessageTokensRequest request)
|
||||
{
|
||||
var response = await SendRequestAsync(CountTokensEndpoint, request);
|
||||
return await CreateResultAsync<TokenCountResponse>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -310,24 +331,30 @@ public class AnthropicApiClient : IAnthropicApiClient
|
||||
var pagingRequest = request ?? new PagingRequest();
|
||||
var endpoint = $"{ModelsEndpoint}?{pagingRequest.ToQueryParameters()}";
|
||||
var response = await SendRequestAsync(endpoint);
|
||||
var anthropicHeaders = new AnthropicHeaders(response.Headers);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode is false)
|
||||
{
|
||||
var error = Deserialize<AnthropicError>(responseContent) ?? new AnthropicError();
|
||||
return AnthropicResult<Page<AnthropicModel>>.Failure(error, anthropicHeaders);
|
||||
}
|
||||
|
||||
var page = Deserialize<Page<AnthropicModel>>(responseContent) ?? new Page<AnthropicModel>();
|
||||
return AnthropicResult<Page<AnthropicModel>>.Success(page, anthropicHeaders);
|
||||
return await CreateResultAsync<Page<AnthropicModel>>(response);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async IAsyncEnumerable<AnthropicResult<Page<AnthropicModel>>> ListAllModelsAsync(int limit = 20)
|
||||
{
|
||||
await foreach (var result in GetAllPagesAsync<AnthropicModel>(ModelsEndpoint, limit))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId)
|
||||
{
|
||||
var endpoint = $"{ModelsEndpoint}/{modelId}";
|
||||
var response = await SendRequestAsync(endpoint);
|
||||
return await CreateResultAsync<AnthropicModel>(response);
|
||||
}
|
||||
|
||||
private async IAsyncEnumerable<AnthropicResult<Page<T>>> GetAllPagesAsync<T>(string endpoint, int limit = 20)
|
||||
{
|
||||
var pagingRequest = new PagingRequest(limit: limit);
|
||||
string Endpoint() => $"{ModelsEndpoint}?{pagingRequest.ToQueryParameters()}";
|
||||
string Endpoint() => $"{endpoint}?{pagingRequest.ToQueryParameters()}";
|
||||
bool hasMore;
|
||||
|
||||
do
|
||||
@@ -339,11 +366,11 @@ public class AnthropicApiClient : IAnthropicApiClient
|
||||
if (response.IsSuccessStatusCode is false)
|
||||
{
|
||||
var error = Deserialize<AnthropicError>(responseContent) ?? new AnthropicError();
|
||||
yield return AnthropicResult<Page<AnthropicModel>>.Failure(error, anthropicHeaders);
|
||||
yield return AnthropicResult<Page<T>>.Failure(error, anthropicHeaders);
|
||||
yield break;
|
||||
}
|
||||
|
||||
var page = Deserialize<Page<AnthropicModel>>(responseContent) ?? new Page<AnthropicModel>();
|
||||
var page = Deserialize<Page<T>>(responseContent) ?? new Page<T>();
|
||||
|
||||
if (page.HasMore && page.LastId is not null)
|
||||
{
|
||||
@@ -355,28 +382,10 @@ public class AnthropicApiClient : IAnthropicApiClient
|
||||
hasMore = false;
|
||||
}
|
||||
|
||||
yield return AnthropicResult<Page<AnthropicModel>>.Success(page, anthropicHeaders);
|
||||
yield return AnthropicResult<Page<T>>.Success(page, anthropicHeaders);
|
||||
} while (hasMore);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId)
|
||||
{
|
||||
var endpoint = $"{ModelsEndpoint}/{modelId}";
|
||||
var response = await SendRequestAsync(endpoint);
|
||||
var anthropicHeaders = new AnthropicHeaders(response.Headers);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode is false)
|
||||
{
|
||||
var error = Deserialize<AnthropicError>(responseContent) ?? new AnthropicError();
|
||||
return AnthropicResult<AnthropicModel>.Failure(error, anthropicHeaders);
|
||||
}
|
||||
|
||||
var model = Deserialize<AnthropicModel>(responseContent) ?? new AnthropicModel();
|
||||
return AnthropicResult<AnthropicModel>.Success(model, anthropicHeaders);
|
||||
}
|
||||
|
||||
private ToolCall? GetToolCall(MessageResponse response, List<Tool> tools)
|
||||
{
|
||||
var toolUse = response.Content.OfType<ToolUseContent>().FirstOrDefault();
|
||||
@@ -396,9 +405,25 @@ public class AnthropicApiClient : IAnthropicApiClient
|
||||
return new ToolCall(tool, toolUse);
|
||||
}
|
||||
|
||||
private async Task<HttpResponseMessage> SendRequestAsync(string endpoint)
|
||||
private async Task<AnthropicResult<T>> CreateResultAsync<T>(HttpResponseMessage response) where T : new()
|
||||
{
|
||||
return await _httpClient.GetAsync(endpoint);
|
||||
var anthropicHeaders = new AnthropicHeaders(response.Headers);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode is false)
|
||||
{
|
||||
var error = Deserialize<AnthropicError>(responseContent) ?? new AnthropicError();
|
||||
return AnthropicResult<T>.Failure(error, anthropicHeaders);
|
||||
}
|
||||
|
||||
var model = Deserialize<T>(responseContent) ?? new T();
|
||||
return AnthropicResult<T>.Success(model, anthropicHeaders);
|
||||
}
|
||||
|
||||
private async Task<HttpResponseMessage> SendRequestAsync(string endpoint, HttpMethod? method = null)
|
||||
{
|
||||
var request = new HttpRequestMessage(method ?? HttpMethod.Get, endpoint);
|
||||
return await _httpClient.SendAsync(request);
|
||||
}
|
||||
|
||||
private async Task<HttpResponseMessage> SendRequestAsync<T>(string endpoint, T request)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>AnthropicClient</PackageId>
|
||||
<Version>0.5.0</Version>
|
||||
<Version>0.6.0</Version>
|
||||
<Authors>Stevan Freeborn</Authors>
|
||||
<Description>Anthropic Client Library</Description>
|
||||
<PackageProjectUrl>https://anthropicclient.stevanfreeborn.com/</PackageProjectUrl>
|
||||
|
||||
@@ -2,6 +2,26 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.
|
||||
|
||||
<a name="0.6.0"></a>
|
||||
## [0.6.0](https://www.github.com/StevanFreeborn/anthropic-client/releases/tag/v0.6.0) (2025-01-15)
|
||||
|
||||
### Features
|
||||
|
||||
* add CancelMessageBatchAsync method and corresponding tests ([c11600c](https://www.github.com/StevanFreeborn/anthropic-client/commit/c11600c77040eebfab4df1153d07774357d87ce2))
|
||||
* add class for representing batch statuses ([f8e01bf](https://www.github.com/StevanFreeborn/anthropic-client/commit/f8e01bf4878e07f823d524408ed59a2232960a7b))
|
||||
* add DeleteMessageBatchAsync method and MessageBatchDeleteResponse model with tests ([56b3a53](https://www.github.com/StevanFreeborn/anthropic-client/commit/56b3a53a2a31070693351525379b6a675b068496))
|
||||
* add ListAllMessageBatchesAsync method and corresponding tests ([180a090](https://www.github.com/StevanFreeborn/anthropic-client/commit/180a0901959b88b27981f063b0be7a267a141802))
|
||||
* implement CreateMessageBatchAsync method ([9548754](https://www.github.com/StevanFreeborn/anthropic-client/commit/9548754d6cab73d21c7b7a28264374e79dcb8bab))
|
||||
* implement GetMessageBatchAsync method ([c5f3c5e](https://www.github.com/StevanFreeborn/anthropic-client/commit/c5f3c5eca549a89ac6b8197b833767c0ca4465c5))
|
||||
* implement GetMessageBatchResultsAsync method ([c56adf3](https://www.github.com/StevanFreeborn/anthropic-client/commit/c56adf394c62aca10c89f1d8650635cefe248d50))
|
||||
* implement ListMessageBatchesAsync method ([ca2ecdc](https://www.github.com/StevanFreeborn/anthropic-client/commit/ca2ecdcfc79a5ff96c22eb564e7fc8be22e82a6f))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* default nullable properties to actually datetimeoffset min value when new'd up ([0a6d89b](https://www.github.com/StevanFreeborn/anthropic-client/commit/0a6d89bd77e165a0ae63dacd9f854bd49ba817ce))
|
||||
* make correct properties nullable ([15f5ad4](https://www.github.com/StevanFreeborn/anthropic-client/commit/15f5ad49e7f41215c3b089cdfe3873182223ce2d))
|
||||
* use proper count tokens endpoint ([5e247a3](https://www.github.com/StevanFreeborn/anthropic-client/commit/5e247a3c3afb9a3dad954eaa5890de106ae2edb9))
|
||||
|
||||
<a name="0.5.0"></a>
|
||||
## [0.5.0](https://www.github.com/StevanFreeborn/anthropic-client/releases/tag/v0.5.0) (2025-01-06)
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
using AnthropicClient.Models;
|
||||
|
||||
namespace AnthropicClient;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a client for interacting with the Anthropic API.
|
||||
/// </summary>
|
||||
public interface IAnthropicApiClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The message request to create.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/>.</returns>
|
||||
Task<AnthropicResult<MessageResponse>> CreateMessageAsync(MessageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a message asynchronously and streams the response.
|
||||
/// </summary>
|
||||
/// <param name="request">The message request to create.</param>
|
||||
/// <returns>An asynchronous enumerable that yields the response event by event.</returns>
|
||||
IAsyncEnumerable<AnthropicEvent> CreateMessageAsync(StreamMessageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a batch of messages asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The message batch request to create.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="MessageBatchResponse"/>.</returns>
|
||||
Task<AnthropicResult<MessageBatchResponse>> CreateMessageBatchAsync(MessageBatchRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a message batch asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="batchId">The ID of the message batch to get.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="MessageBatchResponse"/>.</returns>
|
||||
Task<AnthropicResult<MessageBatchResponse>> GetMessageBatchAsync(string batchId);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the message batches asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The paging request to use for listing the message batches.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="MessageBatchResponse"/>.</returns>
|
||||
Task<AnthropicResult<Page<MessageBatchResponse>>> ListMessageBatchesAsync(PagingRequest? request = null);
|
||||
|
||||
/// <summary>
|
||||
/// Lists all message batches asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="limit">The maximum number of message batches to return in each page.</param>
|
||||
/// <returns>An asynchronous enumerable that yields the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="MessageBatchResponse"/>.</returns>
|
||||
IAsyncEnumerable<AnthropicResult<Page<MessageBatchResponse>>> ListAllMessageBatchesAsync(int limit = 20);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a message batch asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="batchId">The ID of the message batch to cancel.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="MessageBatchResponse"/>.</returns>
|
||||
Task<AnthropicResult<MessageBatchResponse>> CancelMessageBatchAsync(string batchId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a message batch asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="batchId">The ID of the message batch to delete.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="MessageBatchDeleteResponse"/>.</returns>
|
||||
Task<AnthropicResult<MessageBatchDeleteResponse>> DeleteMessageBatchAsync(string batchId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the results of a message batch asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="batchId">The ID of the message batch to get the results for.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="IAsyncEnumerable{T}"/> where T is <see cref="MessageBatchResultItem"/>.</returns>
|
||||
Task<AnthropicResult<IAsyncEnumerable<MessageBatchResultItem>>> GetMessageBatchResultsAsync(string batchId);
|
||||
|
||||
/// <summary>
|
||||
/// Counts the tokens in a message asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The count message tokens request.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="TokenCountResponse"/>.</returns>
|
||||
Task<AnthropicResult<TokenCountResponse>> CountMessageTokensAsync(CountMessageTokensRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the models asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="request">The paging request to use for listing the models.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
Task<AnthropicResult<Page<AnthropicModel>>> ListModelsAsync(PagingRequest? request = null);
|
||||
|
||||
/// <summary>
|
||||
/// Lists the models asynchronously
|
||||
/// </summary>
|
||||
/// <param name="limit">The maximum number of models to return in each page.</param>
|
||||
/// <returns>An asynchronous enumerable that yields the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="Page{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
///
|
||||
IAsyncEnumerable<AnthropicResult<Page<AnthropicModel>>> ListAllModelsAsync(int limit = 20);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a model by its ID asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="modelId">The ID of the model to get.</param>
|
||||
/// <returns>A task that represents the asynchronous operation. The task result contains the response as an <see cref="AnthropicResult{T}"/> where T is <see cref="AnthropicModel"/>.</returns>
|
||||
Task<AnthropicResult<AnthropicModel>> GetModelAsync(string modelId);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ static class JsonSerializationOptions
|
||||
new EventDataConverter(),
|
||||
new ContentDeltaConverter(),
|
||||
new JsonStringEnumConverter(),
|
||||
new MessageBatchResultConverter(),
|
||||
},
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using AnthropicClient.Models;
|
||||
|
||||
namespace AnthropicClient.Json;
|
||||
|
||||
class MessageBatchResultConverter : JsonConverter<MessageBatchResult>
|
||||
{
|
||||
public override MessageBatchResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
using var jsonDocument = JsonDocument.ParseValue(ref reader);
|
||||
var root = jsonDocument.RootElement;
|
||||
var type = root.GetProperty("type").GetString();
|
||||
return type switch
|
||||
{
|
||||
MessageBatchResultType.Succeeded => JsonSerializer.Deserialize<SucceededMessageBatchResult>(root.GetRawText(), options)!,
|
||||
MessageBatchResultType.Errored => JsonSerializer.Deserialize<ErroredMessageBatchResult>(root.GetRawText(), options)!,
|
||||
MessageBatchResultType.Canceled => JsonSerializer.Deserialize<CanceledMessageBatchResult>(root.GetRawText(), options)!,
|
||||
MessageBatchResultType.Expired => JsonSerializer.Deserialize<ExpiredMessageBatchResult>(root.GetRawText(), options)!,
|
||||
_ => throw new JsonException($"Unknown message batch result type: {type}")
|
||||
};
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, MessageBatchResult value, JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value, value.GetType(), options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result that was cancelled.
|
||||
/// </summary>
|
||||
public class CanceledMessageBatchResult : MessageBatchResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CanceledMessageBatchResult"/> class.
|
||||
/// </summary>
|
||||
public CanceledMessageBatchResult() : base(MessageBatchResultType.Canceled)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result that contains an error response.
|
||||
/// </summary>
|
||||
public class ErroredMessageBatchResult : MessageBatchResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the error of the message batch result.
|
||||
/// </summary>
|
||||
public AnthropicError Error { get; init; } = new AnthropicError();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ErroredMessageBatchResult"/> class.
|
||||
/// </summary>
|
||||
public ErroredMessageBatchResult() : base(MessageBatchResultType.Errored)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result that has expired.
|
||||
/// </summary>
|
||||
public class ExpiredMessageBatchResult : MessageBatchResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExpiredMessageBatchResult"/> class.
|
||||
/// </summary>
|
||||
public ExpiredMessageBatchResult() : base(MessageBatchResultType.Expired)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch delete response.
|
||||
/// </summary>
|
||||
public class MessageBatchDeleteResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the ID of the message batch that was deleted.
|
||||
/// </summary>
|
||||
public string Id { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the message batch response.
|
||||
/// </summary>
|
||||
public string Type { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to create a batch of messages.
|
||||
/// </summary>
|
||||
public class MessageBatchRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the requests to create messages.
|
||||
/// </summary>
|
||||
public List<MessageBatchRequestItem> Requests { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MessageBatchRequest"/> class.
|
||||
/// </summary>
|
||||
/// <param name="requests">The requests to create messages.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="requests"/> is empty.</exception>
|
||||
/// <returns>An instance of the <see cref="MessageBatchRequest"/> class.</returns>
|
||||
public MessageBatchRequest(List<MessageBatchRequestItem> requests)
|
||||
{
|
||||
if (requests.Count == 0)
|
||||
{
|
||||
throw new ArgumentException($"{nameof(requests)} must not be empty.", nameof(requests));
|
||||
}
|
||||
|
||||
Requests = requests;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using AnthropicClient.Utils;
|
||||
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an item in a batch of messages.
|
||||
/// </summary>
|
||||
public class MessageBatchRequestItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the custom identifier for the message.
|
||||
/// </summary>
|
||||
[JsonPropertyName("custom_id")]
|
||||
public string CustomId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the message request parameters.
|
||||
/// </summary>
|
||||
public MessageRequest Params { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MessageBatchRequestItem"/> class.
|
||||
/// </summary>
|
||||
/// <param name="customId">The custom identifier for the message.</param>
|
||||
/// <param name="messageRequest">The message request parameters.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="customId"/> is null or whitespace.</exception>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="messageRequest"/> is null.</exception>
|
||||
/// <returns>An instance of the <see cref="MessageBatchRequestItem"/> class.</returns>
|
||||
public MessageBatchRequestItem(string customId, MessageRequest messageRequest)
|
||||
{
|
||||
ArgumentValidator.ThrowIfNullOrWhitespace(customId, nameof(customId));
|
||||
ArgumentValidator.ThrowIfNull(messageRequest, nameof(messageRequest));
|
||||
|
||||
CustomId = customId;
|
||||
Params = messageRequest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response to a batch of messages.
|
||||
/// </summary>
|
||||
public class MessageBatchResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the identifier of the batch.
|
||||
/// </summary>
|
||||
public string Id { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of the batch.
|
||||
/// </summary>
|
||||
public string Type { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the processing status of the batch.
|
||||
/// </summary>
|
||||
[JsonPropertyName("processing_status")]
|
||||
public string ProcessingStatus { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the counts of requests in the batch.
|
||||
/// </summary>
|
||||
[JsonPropertyName("request_counts")]
|
||||
public MessageBatchRequestCounts RequestCounts { get; init; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the batch ended.
|
||||
/// </summary>
|
||||
[JsonPropertyName("ended_at")]
|
||||
public DateTimeOffset? EndedAt { get; init; } = DateTimeOffset.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the batch was created.
|
||||
/// </summary>
|
||||
[JsonPropertyName("created_at")]
|
||||
public DateTimeOffset CreatedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the batch expires.
|
||||
/// </summary>
|
||||
[JsonPropertyName("expires_at")]
|
||||
public DateTimeOffset ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the batch was archived.
|
||||
/// </summary>
|
||||
[JsonPropertyName("archived_at")]
|
||||
public DateTimeOffset? ArchivedAt { get; init; } = DateTimeOffset.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date and time when the batch cancellation was initiated.
|
||||
/// </summary>
|
||||
[JsonPropertyName("cancel_initiated_at")]
|
||||
public DateTimeOffset? CancelInitiatedAt { get; init; } = DateTimeOffset.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the URL to the results of the batch.
|
||||
/// </summary>
|
||||
[JsonPropertyName("results_url")]
|
||||
public string? ResultsUrl { get; init; } = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the counts of requests in a batch of messages.
|
||||
/// </summary>
|
||||
public class MessageBatchRequestCounts
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the number of requests in the batch that are processing.
|
||||
/// </summary>
|
||||
public int Processing { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of requests in the batch that succeeded.
|
||||
/// </summary>
|
||||
public int Succeeded { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of requests in the batch that errored.
|
||||
/// </summary>
|
||||
public int Errored { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of requests in the batch that were cancelled.
|
||||
/// </summary>
|
||||
public int Canceled { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of requests in the batch that expired.
|
||||
/// </summary>
|
||||
public int Expired { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using AnthropicClient.Utils;
|
||||
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result.
|
||||
/// </summary>
|
||||
public abstract class MessageBatchResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the type of the message batch result.
|
||||
/// </summary>
|
||||
public string Type { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MessageBatchResult"/> class.
|
||||
/// </summary>
|
||||
/// <param name="type">The type of the message batch result.</param>
|
||||
/// <returns>An instance of the <see cref="MessageBatchResult"/> class.</returns>
|
||||
public MessageBatchResult(string type)
|
||||
{
|
||||
ArgumentValidator.ThrowIfNullOrWhitespace(type, nameof(type));
|
||||
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result item.
|
||||
/// </summary>
|
||||
public class MessageBatchResultItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the custom ID of the message batch result item.
|
||||
/// </summary>
|
||||
[JsonPropertyName("custom_id")]
|
||||
public string CustomId { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result of the message batch result item.
|
||||
/// </summary>
|
||||
public MessageBatchResult Result { get; init; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the types of message batch results.
|
||||
/// </summary>
|
||||
public static class MessageBatchResultType
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a succeeded message batch result.
|
||||
/// </summary>
|
||||
public const string Succeeded = "succeeded";
|
||||
|
||||
/// <summary>
|
||||
/// Represents an errored message batch result.
|
||||
/// </summary>
|
||||
public const string Errored = "errored";
|
||||
|
||||
/// <summary>
|
||||
/// Represents a canceled message batch result.
|
||||
/// </summary>
|
||||
public const string Canceled = "canceled";
|
||||
|
||||
/// <summary>
|
||||
/// Represents an expired message batch result.
|
||||
/// </summary>
|
||||
public const string Expired = "expired";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the status of a message batch.
|
||||
/// </summary>
|
||||
public static class MessageBatchStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// The status of a message batch that is being canceled.
|
||||
/// </summary>
|
||||
public const string Canceling = "canceling";
|
||||
|
||||
/// <summary>
|
||||
/// The status of a message batch that is in progress.
|
||||
/// </summary>
|
||||
public const string InProgress = "in_progress";
|
||||
|
||||
/// <summary>
|
||||
/// The status of a message batch that has ended.
|
||||
/// </summary>
|
||||
public const string Ended = "ended";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace AnthropicClient.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a message batch result that contains a message response.
|
||||
/// </summary>
|
||||
public class SucceededMessageBatchResult : MessageBatchResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the message of the message batch result.
|
||||
/// </summary>
|
||||
public MessageResponse Message { get; init; } = new MessageResponse();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SucceededMessageBatchResult"/> class.
|
||||
/// </summary>
|
||||
/// <returns>An instance of the <see cref="SucceededMessageBatchResult"/> class.</returns>
|
||||
public SucceededMessageBatchResult() : base(MessageBatchResultType.Succeeded)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using AnthropicClient.Tests.Files;
|
||||
|
||||
namespace AnthropicClient.Tests.EndToEnd;
|
||||
|
||||
public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(configFixture)
|
||||
public class AnthropicApiClientTests(ConfigurationFixture configFixture) : EndToEndTest(configFixture)
|
||||
{
|
||||
private string GetTestFilePath(string fileName) =>
|
||||
Path.Combine(Directory.GetCurrentDirectory(), "Files", fileName);
|
||||
|
||||
[Fact]
|
||||
public async Task CreateMessageAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
@@ -63,7 +62,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
[Fact]
|
||||
public async Task CreateMessageAsync_WhenImageIsSent_ItShouldReturnResponse()
|
||||
{
|
||||
var imagePath = GetTestFilePath("elephant.jpg");
|
||||
var imagePath = TestFileHelper.GetTestFilePath("elephant.jpg");
|
||||
var mediaType = "image/jpeg";
|
||||
var bytes = await File.ReadAllBytesAsync(imagePath);
|
||||
var base64Data = Convert.ToBase64String(bytes);
|
||||
@@ -102,7 +101,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
{
|
||||
var client = CreateClient(new HttpClient());
|
||||
|
||||
var storyPath = GetTestFilePath("story.txt");
|
||||
var storyPath = TestFileHelper.GetTestFilePath("story.txt");
|
||||
var storyText = await File.ReadAllTextAsync(storyPath);
|
||||
|
||||
var request = new MessageRequest(
|
||||
@@ -141,7 +140,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
{
|
||||
var client = CreateClient(new HttpClient());
|
||||
|
||||
var storyPath = GetTestFilePath("story.txt");
|
||||
var storyPath = TestFileHelper.GetTestFilePath("story.txt");
|
||||
var storyText = await File.ReadAllTextAsync(storyPath);
|
||||
|
||||
var request = new MessageRequest(
|
||||
@@ -217,7 +216,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
[Fact]
|
||||
public async Task CreateMessageAsync_WhenProvidedWithPDF_ItShouldReturnResponse()
|
||||
{
|
||||
var pdfPath = GetTestFilePath("addendum.pdf");
|
||||
var pdfPath = TestFileHelper.GetTestFilePath("addendum.pdf");
|
||||
var bytes = await File.ReadAllBytesAsync(pdfPath);
|
||||
var base64Data = Convert.ToBase64String(bytes);
|
||||
|
||||
@@ -253,7 +252,7 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
[Fact]
|
||||
public async Task CreateMessageAsync_WhenProvidedWithPDFWithCacheControl_ItShouldUseCache()
|
||||
{
|
||||
var pdfPath = GetTestFilePath("addendum.pdf");
|
||||
var pdfPath = TestFileHelper.GetTestFilePath("addendum.pdf");
|
||||
var bytes = await File.ReadAllBytesAsync(pdfPath);
|
||||
var base64Data = Convert.ToBase64String(bytes);
|
||||
|
||||
@@ -341,4 +340,121 @@ public class ClientTests(ConfigurationFixture configFixture) : EndToEndTest(conf
|
||||
result.Value.Should().BeOfType<AnthropicModel>();
|
||||
result.Value.Id.Should().Be(AnthropicModels.Claude3Haiku);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateMessageBatchAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
var request = new MessageBatchRequest([
|
||||
new(
|
||||
Guid.NewGuid().ToString(),
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var result = await _client.CreateMessageBatchAsync(request);
|
||||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().BeOfType<MessageBatchResponse>();
|
||||
result.Value.Id.Should().NotBeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetMessageBatchAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
var request = new MessageBatchRequest([
|
||||
new(
|
||||
Guid.NewGuid().ToString(),
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var createResult = await _client.CreateMessageBatchAsync(request);
|
||||
var getResult = await _client.GetMessageBatchAsync(createResult.Value.Id);
|
||||
|
||||
getResult.IsSuccess.Should().BeTrue();
|
||||
getResult.Value.Should().BeOfType<MessageBatchResponse>();
|
||||
getResult.Value.Id.Should().Be(createResult.Value.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListMessageBatchesAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
var request = new MessageBatchRequest([
|
||||
new(
|
||||
Guid.NewGuid().ToString(),
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var createResult = await _client.CreateMessageBatchAsync(request);
|
||||
var result = await _client.ListMessageBatchesAsync();
|
||||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().BeOfType<Page<MessageBatchResponse>>();
|
||||
result.Value.Data.Should().HaveCountGreaterThan(0);
|
||||
result.Value.Data.Should().ContainSingle(b => b.Id == createResult.Value.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ListAllMessageBatchesAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
var createRequest = (string id) => new MessageBatchRequest([
|
||||
new(
|
||||
id,
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var requestNumberOne = createRequest(Guid.NewGuid().ToString());
|
||||
var requestNumberTwo = createRequest(Guid.NewGuid().ToString());
|
||||
|
||||
var createResultOne = await _client.CreateMessageBatchAsync(requestNumberOne);
|
||||
var createResultTwo = await _client.CreateMessageBatchAsync(requestNumberTwo);
|
||||
|
||||
var responses = await _client.ListAllMessageBatchesAsync(limit: 1).ToListAsync();
|
||||
|
||||
responses.Should().HaveCountGreaterThan(2);
|
||||
|
||||
var batches = responses
|
||||
.Where(r => r.IsSuccess)
|
||||
.Select(r => r.Value)
|
||||
.SelectMany(r => r.Data);
|
||||
|
||||
batches.Should().ContainSingle(b => b.Id == createResultOne.Value.Id);
|
||||
batches.Should().ContainSingle(b => b.Id == createResultTwo.Value.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CancelMessageBatchAsync_WhenCalled_ItShouldReturnResponse()
|
||||
{
|
||||
var request = new MessageBatchRequest([
|
||||
new(
|
||||
Guid.NewGuid().ToString(),
|
||||
new(
|
||||
model: AnthropicModels.Claude3Haiku,
|
||||
messages: [new(MessageRole.User, [new TextContent("Hello!")])]
|
||||
)
|
||||
),
|
||||
]);
|
||||
|
||||
var createResult = await _client.CreateMessageBatchAsync(request);
|
||||
var result = await _client.CancelMessageBatchAsync(createResult.Value.Id);
|
||||
|
||||
result.IsSuccess.Should().BeTrue();
|
||||
result.Value.Should().BeOfType<MessageBatchResponse>();
|
||||
result.Value.Id.Should().Be(createResult.Value.Id);
|
||||
result.Value.ProcessingStatus.Should().Be(MessageBatchStatus.Canceling);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace AnthropicClient.Tests.Files;
|
||||
|
||||
static class TestFileHelper
|
||||
{
|
||||
public static string GetTestFilePath(string fileName) =>
|
||||
Path.Combine(Directory.GetCurrentDirectory(), "Files", fileName);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{"custom_id":"my-fifth-request","result":{"type":"errored","error":{"type":"error","error":{"type":"not_found_error","message":"The requested resource could not be found."}}}}
|
||||
{"custom_id":"my-fourth-request","result":{"type":"expired"}}
|
||||
{"custom_id":"my-third-request","result":{"type":"canceled"}}
|
||||
{"custom_id":"my-second-request","result":{"type":"succeeded","message":{"id":"msg_014VwiXbi91y3JMjcpyGBHX5","type":"message","role":"assistant","model":"claude-3-5-sonnet-20240620","content":[{"type":"text","text":"Hello again! It's nice to see you. How can I assist you today? Is there anything specific you'd like to chat about or any questions you have?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":11,"output_tokens":36}}}}
|
||||
{"custom_id":"my-first-request","result":{"type":"succeeded","message":{"id":"msg_01FqfsLoHwgeFbguDgpz48m7","type":"message","role":"assistant","model":"claude-3-5-sonnet-20240620","content":[{"type":"text","text":"Hello! How can I assist you today? Feel free to ask me any questions or let me know if there's anything you'd like to chat about."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":34}}}}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,8 @@
|
||||
using AnthropicClient.Tests.Unit;
|
||||
|
||||
namespace AnthropicClient.Tests.Integration;
|
||||
|
||||
public class IntegrationTest
|
||||
public class IntegrationTest : SerializationTest
|
||||
{
|
||||
protected readonly MockHttpMessageHandler _mockHttpMessageHandler = new();
|
||||
protected AnthropicApiClient Client => CreateClient();
|
||||
@@ -16,6 +18,7 @@ public static class MockHttpMessageHandlerExtensions
|
||||
private const string BaseUrl = "https://api.anthropic.com/v1";
|
||||
private static readonly string MessagesEndpoint = $"{BaseUrl}/messages";
|
||||
private static readonly string CountTokensEndpoint = $"{BaseUrl}/messages/count_tokens";
|
||||
private static readonly string MessageBatchesEndpoint = $"{BaseUrl}/messages/batches";
|
||||
private static readonly string ModelsEndpoint = $"{BaseUrl}/models";
|
||||
|
||||
private static MockedRequest SetupBaseRequest(
|
||||
@@ -64,4 +67,40 @@ public static class MockHttpMessageHandlerExtensions
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Get, $"{ModelsEndpoint}/{modelId}");
|
||||
}
|
||||
|
||||
public static MockedRequest WhenCreateMessageBatchRequest(this MockHttpMessageHandler mockHttpMessageHandler)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Post, MessageBatchesEndpoint);
|
||||
}
|
||||
|
||||
public static MockedRequest WhenGetMessageBatchRequest(this MockHttpMessageHandler mockHttpMessageHandler, string batchId)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Get, $"{MessageBatchesEndpoint}/{batchId}");
|
||||
}
|
||||
|
||||
public static MockedRequest WhenGetMessageBatchResultsRequest(this MockHttpMessageHandler mockHttpMessageHandler, string batchId)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Get, $"{MessageBatchesEndpoint}/{batchId}/results");
|
||||
}
|
||||
|
||||
public static MockedRequest WhenListMessageBatchesRequest(this MockHttpMessageHandler mockHttpMessageHandler)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Get, MessageBatchesEndpoint);
|
||||
}
|
||||
|
||||
public static MockedRequest WhenCancelMessageBatchRequest(this MockHttpMessageHandler mockHttpMessageHandler, string batchId)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Post, $"{MessageBatchesEndpoint}/{batchId}/cancel");
|
||||
}
|
||||
|
||||
public static MockedRequest WhenDeleteMessageBatchRequest(this MockHttpMessageHandler mockHttpMessageHandler, string batchId)
|
||||
{
|
||||
return mockHttpMessageHandler
|
||||
.SetupBaseRequest(HttpMethod.Delete, $"{MessageBatchesEndpoint}/{batchId}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class CanceledMessageBatchResultTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""type"": ""canceled""
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new CanceledMessageBatchResult();
|
||||
|
||||
result.Type.Should().Be(MessageBatchResultType.Canceled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new CanceledMessageBatchResult();
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedProperties()
|
||||
{
|
||||
var result = Deserialize<CanceledMessageBatchResult>(SampleJson);
|
||||
|
||||
result!.Type.Should().Be(MessageBatchResultType.Canceled);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class ErroredMessageBatchResultTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""type"": ""errored"",
|
||||
""error"": {
|
||||
""type"": ""error"",
|
||||
""error"": {
|
||||
""type"": ""api_error"",
|
||||
""message"": ""An error occurred.""
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new ErroredMessageBatchResult();
|
||||
|
||||
result.Type.Should().Be(MessageBatchResultType.Errored);
|
||||
result.Error.Error.Should().BeOfType<ApiError>();
|
||||
result.Error.Error.Message.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new ErroredMessageBatchResult
|
||||
{
|
||||
Error = new(new ApiError("An error occurred."))
|
||||
};
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedProperties()
|
||||
{
|
||||
var result = Deserialize<ErroredMessageBatchResult>(SampleJson);
|
||||
|
||||
result!.Type.Should().Be(MessageBatchResultType.Errored);
|
||||
result.Error.Error.Should().BeOfType<ApiError>();
|
||||
result.Error.Error.Message.Should().Be("An error occurred.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class ExpiredMessageBatchResultTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""type"": ""expired""
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new ExpiredMessageBatchResult();
|
||||
|
||||
result.Type.Should().Be(MessageBatchResultType.Expired);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new ExpiredMessageBatchResult();
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedProperties()
|
||||
{
|
||||
var result = Deserialize<ExpiredMessageBatchResult>(SampleJson);
|
||||
|
||||
result!.Type.Should().Be(MessageBatchResultType.Expired);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchDeleteResponseTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""id"": ""test-id"",
|
||||
""type"": ""test-type""
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new MessageBatchDeleteResponse();
|
||||
|
||||
result.Id.Should().BeEmpty();
|
||||
result.Type.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new MessageBatchDeleteResponse
|
||||
{
|
||||
Id = "test-id",
|
||||
Type = "test-type"
|
||||
};
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedValues()
|
||||
{
|
||||
var result = Deserialize<MessageBatchDeleteResponse>(SampleJson);
|
||||
|
||||
result!.Id.Should().Be("test-id");
|
||||
result.Type.Should().Be("test-type");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchRequestItemTests : SerializationTest
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet()
|
||||
{
|
||||
var customId = "custom_id";
|
||||
var messageRequest = new MessageRequest();
|
||||
|
||||
var result = new MessageBatchRequestItem(customId, messageRequest);
|
||||
|
||||
result.Should().BeOfType<MessageBatchRequestItem>();
|
||||
result.CustomId.Should().Be(customId);
|
||||
result.Params.Should().BeSameAs(messageRequest);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData(null)]
|
||||
public void Constructor_WhenCalledAndCustomIdIsInvalid_ItShouldThrowException(string? customId)
|
||||
{
|
||||
var act = () => new MessageBatchRequestItem(customId!, new MessageRequest());
|
||||
|
||||
act.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledAndMessageRequestIsNull_ItShouldThrowException()
|
||||
{
|
||||
var act = () => new MessageBatchRequestItem("custom_id", null!);
|
||||
|
||||
act.Should().Throw<ArgumentException>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchRequestTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""requests"": [
|
||||
{
|
||||
""custom_id"": ""my-first-request"",
|
||||
""params"": {
|
||||
""model"": ""claude-3-5-sonnet-20241022"",
|
||||
""messages"": [
|
||||
{""role"": ""user"", ""content"": [{ ""text"": ""Hello, world"", ""type"": ""text"" }]}
|
||||
],
|
||||
""max_tokens"": 1024,
|
||||
""stop_sequences"": [],
|
||||
""temperature"": 0.0,
|
||||
""stream"": false
|
||||
}
|
||||
},
|
||||
{
|
||||
""custom_id"": ""my-second-request"",
|
||||
""params"": {
|
||||
""model"": ""claude-3-5-sonnet-20241022"",
|
||||
""messages"": [
|
||||
{""role"": ""user"", ""content"": [{ ""text"": ""Hi again, friend"", ""type"": ""text"" }]}
|
||||
],
|
||||
""max_tokens"": 1024,
|
||||
""stop_sequences"": [],
|
||||
""temperature"": 0.0,
|
||||
""stream"": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet()
|
||||
{
|
||||
var requests = new List<MessageBatchRequestItem> { new("custom_id", new()) };
|
||||
|
||||
var result = new MessageBatchRequest(requests);
|
||||
|
||||
result.Should().BeOfType<MessageBatchRequest>();
|
||||
result.Requests.Should().BeSameAs(requests);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledWithEmptyRequests_ItShouldThrowException()
|
||||
{
|
||||
var act = () => new MessageBatchRequest([]);
|
||||
|
||||
act.Should().Throw<ArgumentException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var requests = new List<MessageBatchRequestItem>
|
||||
{
|
||||
new("my-first-request", new()
|
||||
{
|
||||
Model = "claude-3-5-sonnet-20241022",
|
||||
MaxTokens = 1024,
|
||||
Messages = [
|
||||
new() { Role = "user", Content = [new TextContent("Hello, world")] }
|
||||
]
|
||||
}),
|
||||
new("my-second-request", new()
|
||||
{
|
||||
Model = "claude-3-5-sonnet-20241022",
|
||||
MaxTokens = 1024,
|
||||
Messages = [
|
||||
new() { Role = "user", Content = [new TextContent("Hi again, friend")] }
|
||||
]
|
||||
})
|
||||
};
|
||||
|
||||
var result = new MessageBatchRequest(requests);
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchResponseTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""id"": ""msgbatch_013Zva2CMHLNnXjNJJKqJ2EF"",
|
||||
""type"": ""message_batch"",
|
||||
""processing_status"": ""in_progress"",
|
||||
""request_counts"": {
|
||||
""processing"": 100,
|
||||
""succeeded"": 50,
|
||||
""errored"": 30,
|
||||
""canceled"": 10,
|
||||
""expired"": 10
|
||||
},
|
||||
""ended_at"": ""2024-08-20T18:37:24.100435Z"",
|
||||
""created_at"": ""2024-08-20T18:37:24.100435Z"",
|
||||
""expires_at"": ""2024-08-20T18:37:24.100435Z"",
|
||||
""archived_at"": ""2024-08-20T18:37:24.100435Z"",
|
||||
""cancel_initiated_at"": ""2024-08-20T18:37:24.100435Z"",
|
||||
""results_url"": ""https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results""
|
||||
}";
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new MessageBatchResponse();
|
||||
|
||||
result.Should().BeOfType<MessageBatchResponse>();
|
||||
result.Id.Should().BeEmpty();
|
||||
result.Type.Should().BeEmpty();
|
||||
result.ProcessingStatus.Should().BeEmpty();
|
||||
result.RequestCounts.Should().BeEquivalentTo(new MessageBatchRequestCounts());
|
||||
result.EndedAt.Should().Be(DateTimeOffset.MinValue);
|
||||
result.CreatedAt.Should().Be(DateTimeOffset.MinValue);
|
||||
result.ExpiresAt.Should().Be(DateTimeOffset.MinValue);
|
||||
result.ArchivedAt.Should().Be(DateTimeOffset.MinValue);
|
||||
result.CancelInitiatedAt.Should().Be(DateTimeOffset.MinValue);
|
||||
result.ResultsUrl.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenDeserialized_ItShouldHaveExpectedValues()
|
||||
{
|
||||
var result = Deserialize<MessageBatchResponse>(SampleJson);
|
||||
|
||||
result.Should().BeEquivalentTo(new MessageBatchResponse
|
||||
{
|
||||
Id = "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
|
||||
Type = "message_batch",
|
||||
ProcessingStatus = "in_progress",
|
||||
RequestCounts = new()
|
||||
{
|
||||
Processing = 100,
|
||||
Succeeded = 50,
|
||||
Errored = 30,
|
||||
Canceled = 10,
|
||||
Expired = 10
|
||||
},
|
||||
EndedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
CreatedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ExpiresAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ArchivedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
CancelInitiatedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ResultsUrl = "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results"
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var expectedJson = @"{
|
||||
""id"": ""msgbatch_013Zva2CMHLNnXjNJJKqJ2EF"",
|
||||
""type"": ""message_batch"",
|
||||
""processing_status"": ""in_progress"",
|
||||
""request_counts"": {
|
||||
""processing"": 100,
|
||||
""succeeded"": 50,
|
||||
""errored"": 30,
|
||||
""canceled"": 10,
|
||||
""expired"": 10
|
||||
},
|
||||
""ended_at"": ""2024-08-20T18:37:24.100435+00:00"",
|
||||
""created_at"": ""2024-08-20T18:37:24.100435+00:00"",
|
||||
""expires_at"": ""2024-08-20T18:37:24.100435+00:00"",
|
||||
""archived_at"": ""2024-08-20T18:37:24.100435+00:00"",
|
||||
""cancel_initiated_at"": ""2024-08-20T18:37:24.100435+00:00"",
|
||||
""results_url"": ""https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results""
|
||||
}";
|
||||
|
||||
var result = Serialize(new MessageBatchResponse
|
||||
{
|
||||
Id = "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
|
||||
Type = "message_batch",
|
||||
ProcessingStatus = "in_progress",
|
||||
RequestCounts = new()
|
||||
{
|
||||
Processing = 100,
|
||||
Succeeded = 50,
|
||||
Errored = 30,
|
||||
Canceled = 10,
|
||||
Expired = 10
|
||||
},
|
||||
EndedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
CreatedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ExpiresAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ArchivedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
CancelInitiatedAt = DateTimeOffset.Parse("2024-08-20T18:37:24.100435Z"),
|
||||
ResultsUrl = "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results"
|
||||
});
|
||||
|
||||
JsonAssert.Equal(expectedJson, result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchResultItemTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new MessageBatchResultItem();
|
||||
|
||||
result.Should().BeOfType<MessageBatchResultItem>();
|
||||
result.CustomId.Should().BeEmpty();
|
||||
result.Result.Should().Be(default);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchResultTests : SerializationTest
|
||||
{
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenHasUnknownType_ItShouldThrowException()
|
||||
{
|
||||
var json = @"{""type"":""unknown""}";
|
||||
|
||||
var action = () => Deserialize<MessageBatchResult>(json);
|
||||
|
||||
action.Should().Throw<JsonException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var expectedJson = @"{""type"":""expired""}";
|
||||
var messageBatchResult = new ExpiredMessageBatchResult();
|
||||
|
||||
var json = Serialize<MessageBatchResult>(messageBatchResult);
|
||||
|
||||
JsonAssert.Equal(expectedJson, json);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchResultTypeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Succeeded_WhenCalled_ItShouldReturnExpectedValue()
|
||||
{
|
||||
var result = MessageBatchResultType.Succeeded;
|
||||
|
||||
result.Should().Be("succeeded");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Errored_WhenCalled_ItShouldReturnExpectedValue()
|
||||
{
|
||||
var result = MessageBatchResultType.Errored;
|
||||
|
||||
result.Should().Be("errored");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Canceled_WhenCalled_ItShouldReturnExpectedValue()
|
||||
{
|
||||
var result = MessageBatchResultType.Canceled;
|
||||
|
||||
result.Should().Be("canceled");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Expired_WhenCalled_ItShouldReturnExpectedValue()
|
||||
{
|
||||
var result = MessageBatchResultType.Expired;
|
||||
|
||||
result.Should().Be("expired");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class MessageBatchStatusTests
|
||||
{
|
||||
[Fact]
|
||||
public void Canceling_WhenCalled_ItShouldReturnCancelingStatus()
|
||||
{
|
||||
MessageBatchStatus.Canceling.Should().Be("canceling");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InProgress_WhenCalled_ItShouldReturnCancelingStatus()
|
||||
{
|
||||
MessageBatchStatus.InProgress.Should().Be("in_progress");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ended_WhenCalled_ItShouldReturnCancelingStatus()
|
||||
{
|
||||
MessageBatchStatus.Ended.Should().Be("ended");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class SucceededMessageBatchResultTests : SerializationTest
|
||||
{
|
||||
private const string SampleJson = @"{
|
||||
""message"": {
|
||||
""id"": ""msg_01FqfsLoHwgeFbguDgpz48m7"",
|
||||
""model"": ""claude-3-5-sonnet-20240620"",
|
||||
""role"": ""assistant"",
|
||||
""stop_reason"": ""end_turn"",
|
||||
""type"": ""message"",
|
||||
""usage"": {
|
||||
""input_tokens"": 10,
|
||||
""output_tokens"": 34,
|
||||
""cache_creation_input_tokens"": 0,
|
||||
""cache_read_input_tokens"": 0
|
||||
},
|
||||
""content"": [
|
||||
{
|
||||
""text"": ""Hello! How can I assist you today? Feel free to ask me any questions or let me know if there\u0027s anything you\u0027d like to chat about."",
|
||||
""type"": ""text""
|
||||
}
|
||||
]
|
||||
},
|
||||
""type"": ""succeeded""
|
||||
}";
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalled_ItShouldReturnAnInstanceWithPropertiesSet()
|
||||
{
|
||||
var result = new SucceededMessageBatchResult();
|
||||
|
||||
result.Type.Should().Be(MessageBatchResultType.Succeeded);
|
||||
result.Message.Should().BeEquivalentTo(new MessageResponse());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonSerialization_WhenSerialized_ItShouldHaveExpectedShape()
|
||||
{
|
||||
var result = new SucceededMessageBatchResult
|
||||
{
|
||||
Message = new MessageResponse
|
||||
{
|
||||
Id = "msg_01FqfsLoHwgeFbguDgpz48m7",
|
||||
Type = "message",
|
||||
Role = "assistant",
|
||||
Model = "claude-3-5-sonnet-20240620",
|
||||
Content = [
|
||||
new TextContent()
|
||||
{
|
||||
Text = "Hello! How can I assist you today? Feel free to ask me any questions or let me know if there's anything you'd like to chat about."
|
||||
}
|
||||
],
|
||||
StopReason = "end_turn",
|
||||
Usage = new()
|
||||
{
|
||||
InputTokens = 10,
|
||||
OutputTokens = 34
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var json = Serialize(result);
|
||||
|
||||
JsonAssert.Equal(SampleJson, json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonDeserialization_WhenDeserialized_ItShouldHaveExpectedValues()
|
||||
{
|
||||
var result = Deserialize<SucceededMessageBatchResult>(SampleJson);
|
||||
|
||||
result!.Type.Should().Be(MessageBatchResultType.Succeeded);
|
||||
result.Message.Should().BeEquivalentTo(new MessageResponse
|
||||
{
|
||||
Id = "msg_01FqfsLoHwgeFbguDgpz48m7",
|
||||
Type = "message",
|
||||
Role = "assistant",
|
||||
Model = "claude-3-5-sonnet-20240620",
|
||||
Content = [
|
||||
new TextContent()
|
||||
{
|
||||
Text = "Hello! How can I assist you today? Feel free to ask me any questions or let me know if there's anything you'd like to chat about."
|
||||
}
|
||||
],
|
||||
StopReason = "end_turn",
|
||||
StopSequence = null,
|
||||
Usage = new()
|
||||
{
|
||||
InputTokens = 10,
|
||||
OutputTokens = 34
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace AnthropicClient.Tests.Unit.Models;
|
||||
|
||||
public class ToolCallTests : SerializationTest
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using AnthropicClient.Json;
|
||||
|
||||
namespace AnthropicClient.Tests.Unit;
|
||||
|
||||
public class SerializationTest
|
||||
|
||||
Reference in New Issue
Block a user