Skip to content

Commit 1424c75

Browse files
committed
fix: Fixed generation.
1 parent d066bbc commit 1424c75

306 files changed

Lines changed: 10280 additions & 9978 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/helpers/FixOpenApiSpec/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
openApiDocument.Components.Schemas["Tool"].Properties["input_schema"].Type = "object";
4949
openApiDocument.Components.Schemas["BetaTool"].Properties["input_schema"].AllOf.Clear();
5050
openApiDocument.Components.Schemas["BetaTool"].Properties["input_schema"].Type = "object";
51-
openApiDocument.Components.Schemas["PromptCachingBetaTool"].Properties["input_schema"].AllOf.Clear();
52-
openApiDocument.Components.Schemas["PromptCachingBetaTool"].Properties["input_schema"].Type = "object";
5351

5452
openApiDocument.Components.SecuritySchemes.Clear();
5553
openApiDocument.Components.SecuritySchemes.Add("ApiKeyAuth", new OpenApiSecurityScheme

src/libs/Anthropic/Extensions/AnthropicClient.ChatClient.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ private static CreateMessageParams CreateRequest(IList<ChatMessage> chatMessages
166166
continue;
167167
}
168168

169-
List<ContentVariant2Item2> blocks = [];
169+
List<InputContentBlock> blocks = [];
170170
foreach (var content in chatMessage.Contents)
171171
{
172172
switch (content)
173173
{
174174
case TextContent tc:
175-
blocks.Add(new ContentVariant2Item2(new RequestTextBlock { Text = tc.Text }));
175+
blocks.Add(new InputContentBlock(new RequestTextBlock { Text = tc.Text }));
176176
break;
177177

178178
case ImageContent ic when ic.ContainsData:
179-
blocks.Add(new ContentVariant2Item2(new RequestImageBlock
179+
blocks.Add(new InputContentBlock(new RequestImageBlock
180180
{
181181
Source = new Base64ImageSource
182182
{
@@ -194,7 +194,7 @@ private static CreateMessageParams CreateRequest(IList<ChatMessage> chatMessages
194194
break;
195195

196196
case FunctionCallContent fcc:
197-
blocks.Add(new ContentVariant2Item2(new RequestToolUseBlock
197+
blocks.Add(new InputContentBlock(new RequestToolUseBlock
198198
{
199199
Id = fcc.CallId,
200200
Name = fcc.Name,
@@ -203,7 +203,7 @@ private static CreateMessageParams CreateRequest(IList<ChatMessage> chatMessages
203203
break;
204204

205205
case FunctionResultContent frc:
206-
blocks.Add(new ContentVariant2Item2(new RequestToolResultBlock
206+
blocks.Add(new InputContentBlock(new RequestToolResultBlock
207207
{
208208
ToolUseId = frc.CallId,
209209
Content = frc.Result?.ToString() ?? string.Empty,
@@ -212,7 +212,7 @@ private static CreateMessageParams CreateRequest(IList<ChatMessage> chatMessages
212212
break;
213213
}
214214

215-
foreach (ContentVariant2Item2 block in blocks)
215+
foreach (InputContentBlock block in blocks)
216216
{
217217
messages.Add(new InputMessage
218218
{

src/libs/Anthropic/Extensions/StringExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static InputMessage AsToolCall(this string content, ResponseToolUseBlock
4646
return new InputMessage
4747
{
4848
Role = InputMessageRole.User,
49-
Content = new List<ContentVariant2Item2>
49+
Content = new List<InputContentBlock>
5050
{
5151
new RequestToolResultBlock
5252
{
@@ -72,22 +72,22 @@ public static InputMessage AsInputMessage(this Message message)
7272
{
7373
if (x.IsText)
7474
{
75-
return new ContentVariant2Item2(new RequestTextBlock
75+
return new InputContentBlock(new RequestTextBlock
7676
{
7777
Text = x.Text!.Text,
7878
});
7979
}
8080
if (x.IsToolUse)
8181
{
82-
return new ContentVariant2Item2(new RequestToolUseBlock
82+
return new InputContentBlock(new RequestToolUseBlock
8383
{
8484
Id = x.ToolUse!.Id,
8585
Input = x.ToolUse.Input,
8686
Name = x.ToolUse!.Name,
8787
});
8888
}
8989

90-
return new ContentVariant2Item2();
90+
return new InputContentBlock();
9191
}).ToList(),
9292
Role = InputMessageRole.Assistant,
9393
};
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
2+
#nullable enable
3+
4+
namespace Anthropic
5+
{
6+
public partial class AnthropicClient
7+
{
8+
partial void PrepareBetaModelsGetArguments(
9+
global::System.Net.Http.HttpClient httpClient,
10+
ref string modelId,
11+
ref string? anthropicVersion,
12+
ref string? xApiKey);
13+
partial void PrepareBetaModelsGetRequest(
14+
global::System.Net.Http.HttpClient httpClient,
15+
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
16+
string modelId,
17+
string? anthropicVersion,
18+
string? xApiKey);
19+
partial void ProcessBetaModelsGetResponse(
20+
global::System.Net.Http.HttpClient httpClient,
21+
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
22+
23+
partial void ProcessBetaModelsGetResponseContent(
24+
global::System.Net.Http.HttpClient httpClient,
25+
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
26+
ref string content);
27+
28+
/// <summary>
29+
/// Get a Model<br/>
30+
/// Get a specific model.<br/>
31+
/// The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.
32+
/// </summary>
33+
/// <param name="modelId">
34+
/// Model identifier or alias.
35+
/// </param>
36+
/// <param name="anthropicVersion">
37+
/// The version of the Anthropic API you want to use.<br/>
38+
/// Read more about versioning and our version history [here](https://docs.anthropic.com/en/api/versioning).
39+
/// </param>
40+
/// <param name="xApiKey">
41+
/// Your unique API key for authentication. <br/>
42+
/// This key is required in the header of all API requests, to authenticate your account and access Anthropic's services. Get your API key through the [Console](https://console.anthropic.com/settings/keys). Each key is scoped to a Workspace.
43+
/// </param>
44+
/// <param name="cancellationToken">The token to cancel the operation with</param>
45+
/// <exception cref="global::Anthropic.ApiException"></exception>
46+
public async global::System.Threading.Tasks.Task<global::Anthropic.BetaModelResponse> BetaModelsGetAsync(
47+
string modelId,
48+
string? anthropicVersion = default,
49+
string? xApiKey = default,
50+
global::System.Threading.CancellationToken cancellationToken = default)
51+
{
52+
PrepareArguments(
53+
client: HttpClient);
54+
PrepareBetaModelsGetArguments(
55+
httpClient: HttpClient,
56+
modelId: ref modelId,
57+
anthropicVersion: ref anthropicVersion,
58+
xApiKey: ref xApiKey);
59+
60+
var __pathBuilder = new PathBuilder(
61+
path: $"/v1/models/{modelId}?beta=true",
62+
baseUri: HttpClient.BaseAddress);
63+
var __path = __pathBuilder.ToString();
64+
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
65+
method: global::System.Net.Http.HttpMethod.Get,
66+
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
67+
#if NET6_0_OR_GREATER
68+
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
69+
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
70+
#endif
71+
72+
foreach (var __authorization in Authorizations)
73+
{
74+
if (__authorization.Type == "Http" ||
75+
__authorization.Type == "OAuth2")
76+
{
77+
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
78+
scheme: __authorization.Name,
79+
parameter: __authorization.Value);
80+
}
81+
else if (__authorization.Type == "ApiKey" &&
82+
__authorization.Location == "Header")
83+
{
84+
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
85+
}
86+
}
87+
88+
if (anthropicVersion != default)
89+
{
90+
__httpRequest.Headers.TryAddWithoutValidation("anthropic-version", anthropicVersion.ToString());
91+
}
92+
if (xApiKey != default)
93+
{
94+
__httpRequest.Headers.TryAddWithoutValidation("x-api-key", xApiKey.ToString());
95+
}
96+
97+
98+
PrepareRequest(
99+
client: HttpClient,
100+
request: __httpRequest);
101+
PrepareBetaModelsGetRequest(
102+
httpClient: HttpClient,
103+
httpRequestMessage: __httpRequest,
104+
modelId: modelId,
105+
anthropicVersion: anthropicVersion,
106+
xApiKey: xApiKey);
107+
108+
using var __response = await HttpClient.SendAsync(
109+
request: __httpRequest,
110+
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
111+
cancellationToken: cancellationToken).ConfigureAwait(false);
112+
113+
ProcessResponse(
114+
client: HttpClient,
115+
response: __response);
116+
ProcessBetaModelsGetResponse(
117+
httpClient: HttpClient,
118+
httpResponseMessage: __response);
119+
// Error response. See our [errors documentation](https://docs.anthropic.com/en/api/errors) for more details.
120+
if ((int)__response.StatusCode >= 400 && (int)__response.StatusCode <= 499)
121+
{
122+
string? __content_4XX = null;
123+
global::Anthropic.BetaErrorResponse? __value_4XX = null;
124+
if (ReadResponseAsString)
125+
{
126+
__content_4XX = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
127+
__value_4XX = global::Anthropic.BetaErrorResponse.FromJson(__content_4XX, JsonSerializerContext);
128+
}
129+
else
130+
{
131+
var __contentStream_4XX = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
132+
__value_4XX = await global::Anthropic.BetaErrorResponse.FromJsonStreamAsync(__contentStream_4XX, JsonSerializerContext).ConfigureAwait(false);
133+
}
134+
135+
throw new global::Anthropic.ApiException<global::Anthropic.BetaErrorResponse>(
136+
message: __response.ReasonPhrase ?? string.Empty,
137+
statusCode: __response.StatusCode)
138+
{
139+
ResponseBody = __content_4XX,
140+
ResponseObject = __value_4XX,
141+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
142+
__response.Headers,
143+
h => h.Key,
144+
h => h.Value),
145+
};
146+
}
147+
148+
if (ReadResponseAsString)
149+
{
150+
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
151+
152+
ProcessResponseContent(
153+
client: HttpClient,
154+
response: __response,
155+
content: ref __content);
156+
ProcessBetaModelsGetResponseContent(
157+
httpClient: HttpClient,
158+
httpResponseMessage: __response,
159+
content: ref __content);
160+
161+
try
162+
{
163+
__response.EnsureSuccessStatusCode();
164+
}
165+
catch (global::System.Net.Http.HttpRequestException __ex)
166+
{
167+
throw new global::Anthropic.ApiException(
168+
message: __content ?? __response.ReasonPhrase ?? string.Empty,
169+
innerException: __ex,
170+
statusCode: __response.StatusCode)
171+
{
172+
ResponseBody = __content,
173+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
174+
__response.Headers,
175+
h => h.Key,
176+
h => h.Value),
177+
};
178+
}
179+
180+
return
181+
global::Anthropic.BetaModelResponse.FromJson(__content, JsonSerializerContext) ??
182+
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
183+
}
184+
else
185+
{
186+
try
187+
{
188+
__response.EnsureSuccessStatusCode();
189+
}
190+
catch (global::System.Net.Http.HttpRequestException __ex)
191+
{
192+
throw new global::Anthropic.ApiException(
193+
message: __response.ReasonPhrase ?? string.Empty,
194+
innerException: __ex,
195+
statusCode: __response.StatusCode)
196+
{
197+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
198+
__response.Headers,
199+
h => h.Key,
200+
h => h.Value),
201+
};
202+
}
203+
204+
using var __content = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
205+
206+
return
207+
await global::Anthropic.BetaModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
208+
throw new global::System.InvalidOperationException("Response deserialization failed.");
209+
}
210+
}
211+
}
212+
}

0 commit comments

Comments
 (0)