Skip to content

Commit f3e9d74

Browse files
committed
feat: Added ServiceProvider to CLI generation.
1 parent 3566a6f commit f3e9d74

File tree

615 files changed

+6357
-2290
lines changed

Some content is hidden

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

615 files changed

+6357
-2290
lines changed

src/libs/AutoSDK/Sources/Sources.CLI.Command.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace {endPoint.Settings.Namespace}
3232
internal sealed partial class {endPoint.NotAsyncMethodName}Command : global::System.CommandLine.Command
3333
{{
3434
private readonly {clientType} _client;
35+
private readonly global::System.IServiceProvider _serviceProvider;
3536
3637
partial void Initialize();
3738
partial void Validate(
@@ -61,11 +62,14 @@ partial void Complete(
6162
}};
6263
").Inject()}
6364
64-
public {endPoint.NotAsyncMethodName}Command({clientType} client) : base(
65+
public {endPoint.NotAsyncMethodName}Command(
66+
{clientType} client,
67+
global::System.IServiceProvider serviceProvider) : base(
6568
name: ""{endPoint.CliAction}"",
6669
description: @""{endPoint.Description.ClearForCSharp()}"")
6770
{{
6871
_client = client;
72+
_serviceProvider = serviceProvider;
6973
7074
{endPoint.Parameters.Where(x => x.IsRequired).Select((x, i) => @$"
7175
Arguments.Add({x.Name.ToPropertyName()});").Inject()}

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesCancelCommand.g.verified.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesCancelCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -41,7 +42,9 @@ partial void Complete(
4142
4243
Read more about versioning and our version history [here](https://docs.anthropic.com/en/api/versioning).",
4344
};
44-
public BetaMessageBatchesCancelCommand(G.IApi client) : base(
45+
public BetaMessageBatchesCancelCommand(
46+
G.IApi client,
47+
global::System.IServiceProvider serviceProvider) : base(
4548
name: "beta",
4649
description: @"Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.
4750
@@ -50,6 +53,7 @@ public BetaMessageBatchesCancelCommand(G.IApi client) : base(
5053
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
5154
{
5255
_client = client;
56+
_serviceProvider = serviceProvider;
5357

5458
Arguments.Add(MessageBatchId);
5559
Options.Add(AnthropicBeta);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesDeleteCommand.g.verified.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesDeleteCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -50,7 +51,9 @@ Read more about versioning and our version history [here](https://docs.anthropic
5051
5152
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.",
5253
};
53-
public BetaMessageBatchesDeleteCommand(G.IApi client) : base(
54+
public BetaMessageBatchesDeleteCommand(
55+
G.IApi client,
56+
global::System.IServiceProvider serviceProvider) : base(
5457
name: "beta",
5558
description: @"Delete a Message Batch.
5659
@@ -59,6 +62,7 @@ public BetaMessageBatchesDeleteCommand(G.IApi client) : base(
5962
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
6063
{
6164
_client = client;
65+
_serviceProvider = serviceProvider;
6266

6367
Arguments.Add(MessageBatchId);
6468
Options.Add(AnthropicBeta);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesListCommand.g.verified.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesListCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -67,13 +68,16 @@ Read more about versioning and our version history [here](https://docs.anthropic
6768
6869
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.",
6970
};
70-
public BetaMessageBatchesListCommand(G.IApi client) : base(
71+
public BetaMessageBatchesListCommand(
72+
G.IApi client,
73+
global::System.IServiceProvider serviceProvider) : base(
7174
name: "beta",
7275
description: @"List all Message Batches within a Workspace. Most recently created batches are returned first.
7376
7477
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
7578
{
7679
_client = client;
80+
_serviceProvider = serviceProvider;
7781

7882
Options.Add(BeforeId);
7983
Options.Add(AfterId);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesPostCommand.g.verified.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesPostCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -23,7 +24,7 @@ partial void Complete(
2324
private global::System.CommandLine.Argument<global::System.Collections.Generic.IList<global::G.BetaMessageBatchIndividualRequestParams>> Requests { get; } = new(
2425
name: "requests")
2526
{
26-
Description = @"",
27+
Description = @"List of requests for prompt completion. Each is an individual request to create a Message.",
2728
};
2829

2930
private global::System.CommandLine.Option<string?> AnthropicBeta { get; } = new(
@@ -41,7 +42,9 @@ partial void Complete(
4142
4243
Read more about versioning and our version history [here](https://docs.anthropic.com/en/api/versioning).",
4344
};
44-
public BetaMessageBatchesPostCommand(G.IApi client) : base(
45+
public BetaMessageBatchesPostCommand(
46+
G.IApi client,
47+
global::System.IServiceProvider serviceProvider) : base(
4548
name: "beta",
4649
description: @"Send a batch of Message creation requests.
4750
@@ -50,6 +53,7 @@ public BetaMessageBatchesPostCommand(G.IApi client) : base(
5053
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
5154
{
5255
_client = client;
56+
_serviceProvider = serviceProvider;
5357

5458
Arguments.Add(Requests);
5559
Options.Add(AnthropicBeta);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesResultsCommand.g.verified.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesResultsCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -50,7 +51,9 @@ Read more about versioning and our version history [here](https://docs.anthropic
5051
5152
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.",
5253
};
53-
public BetaMessageBatchesResultsCommand(G.IApi client) : base(
54+
public BetaMessageBatchesResultsCommand(
55+
G.IApi client,
56+
global::System.IServiceProvider serviceProvider) : base(
5457
name: "beta",
5558
description: @"Streams the results of a Message Batch as a `.jsonl` file.
5659
@@ -59,6 +62,7 @@ Each line in the file is a JSON object containing the result of a single request
5962
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
6063
{
6164
_client = client;
65+
_serviceProvider = serviceProvider;
6266

6367
Arguments.Add(MessageBatchId);
6468
Options.Add(AnthropicBeta);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessageBatchesRetrieveCommand.g.verified.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessageBatchesRetrieveCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -50,13 +51,16 @@ Read more about versioning and our version history [here](https://docs.anthropic
5051
5152
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.",
5253
};
53-
public BetaMessageBatchesRetrieveCommand(G.IApi client) : base(
54+
public BetaMessageBatchesRetrieveCommand(
55+
G.IApi client,
56+
global::System.IServiceProvider serviceProvider) : base(
5457
name: "beta",
5558
description: @"This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.
5659
5760
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)")
5861
{
5962
_client = client;
63+
_serviceProvider = serviceProvider;
6064

6165
Arguments.Add(MessageBatchId);
6266
Options.Add(AnthropicBeta);

src/tests/AutoSDK.SnapshotTests/Snapshots/CLI/anthropic/_#G.Commands.BetaMessagesCountTokensPostCommand.g.verified.cs

Lines changed: 138 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace G
77
internal sealed partial class BetaMessagesCountTokensPostCommand : global::System.CommandLine.Command
88
{
99
private readonly G.IApi _client;
10+
private readonly global::System.IServiceProvider _serviceProvider;
1011

1112
partial void Initialize();
1213
partial void Validate(
@@ -28,13 +29,76 @@ partial void Complete(
2829
private global::System.CommandLine.Argument<global::System.Collections.Generic.IList<global::G.BetaInputMessage>> Messages { get; } = new(
2930
name: "messages")
3031
{
31-
Description = @"",
32+
Description = @"Input messages.
33+
34+
Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.
35+
36+
Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.
37+
38+
If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.
39+
40+
Example with a single `user` message:
41+
42+
```json
43+
[{""role"": ""user"", ""content"": ""Hello, Claude""}]
44+
```
45+
46+
Example with multiple conversational turns:
47+
48+
```json
49+
[
50+
{""role"": ""user"", ""content"": ""Hello there.""},
51+
{""role"": ""assistant"", ""content"": ""Hi, I'm Claude. How can I help you?""},
52+
{""role"": ""user"", ""content"": ""Can you explain LLMs in plain English?""},
53+
]
54+
```
55+
56+
Example with a partially-filled response from Claude:
57+
58+
```json
59+
[
60+
{""role"": ""user"", ""content"": ""What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun""},
61+
{""role"": ""assistant"", ""content"": ""The best answer is (""},
62+
]
63+
```
64+
65+
Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `""text""`. The following input messages are equivalent:
66+
67+
```json
68+
{""role"": ""user"", ""content"": ""Hello, Claude""}
69+
```
70+
71+
```json
72+
{""role"": ""user"", ""content"": [{""type"": ""text"", ""text"": ""Hello, Claude""}]}
73+
```
74+
75+
Starting with Claude 3 models, you can also send image content blocks:
76+
77+
```json
78+
{""role"": ""user"", ""content"": [
79+
{
80+
""type"": ""image"",
81+
""source"": {
82+
""type"": ""base64"",
83+
""media_type"": ""image/jpeg"",
84+
""data"": ""/9j/4AAQSkZJRg..."",
85+
}
86+
},
87+
{""type"": ""text"", ""text"": ""What is in this image?""}
88+
]}
89+
```
90+
91+
We currently support the `base64` source type for images, and the `image/jpeg`, `image/png`, `image/gif`, and `image/webp` media types.
92+
93+
See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for more input examples.
94+
95+
Note that if you want to include a [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `""system""` role for input messages in the Messages API.",
3296
};
3397

3498
private global::System.CommandLine.Argument<global::G.Model> Model { get; } = new(
3599
name: "model")
36100
{
37-
Description = @"",
101+
Description = @"The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.",
38102
};
39103

40104
private global::System.CommandLine.Option<string?> AnthropicBeta { get; } = new(
@@ -56,27 +120,93 @@ Read more about versioning and our version history [here](https://docs.anthropic
56120
private global::System.CommandLine.Option<global::G.BetaToolChoice?> ToolChoice { get; } = new(
57121
name: "toolChoice")
58122
{
59-
Description = @"",
123+
Description = @"How the model should use the provided tools. The model can use a specific tool, any available tool, or decide by itself.",
60124
};
61125

62126
private global::System.CommandLine.Option<global::System.Collections.Generic.IList<global::G.ToolsItem>?> Tools { get; } = new(
63127
name: "tools")
64128
{
65-
Description = @"",
129+
Description = @"Definitions of tools that the model may use.
130+
131+
If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.
132+
133+
Each tool definition includes:
134+
135+
* `name`: Name of the tool.
136+
* `description`: Optional, but strongly-recommended description of the tool.
137+
* `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.
138+
139+
For example, if you defined `tools` as:
140+
141+
```json
142+
[
143+
{
144+
""name"": ""get_stock_price"",
145+
""description"": ""Get the current stock price for a given ticker symbol."",
146+
""input_schema"": {
147+
""type"": ""object"",
148+
""properties"": {
149+
""ticker"": {
150+
""type"": ""string"",
151+
""description"": ""The stock ticker symbol, e.g. AAPL for Apple Inc.""
152+
}
153+
},
154+
""required"": [""ticker""]
155+
}
156+
}
157+
]
158+
```
159+
160+
And then asked the model ""What's the S&P 500 at today?"", the model might produce `tool_use` content blocks in the response like this:
161+
162+
```json
163+
[
164+
{
165+
""type"": ""tool_use"",
166+
""id"": ""toolu_01D7FLrfh4GYq7yT1ULFeyMV"",
167+
""name"": ""get_stock_price"",
168+
""input"": { ""ticker"": ""^GSPC"" }
169+
}
170+
]
171+
```
172+
173+
You might then run your `get_stock_price` tool with `{""ticker"": ""^GSPC""}` as an input, and return the following back to the model in a subsequent `user` message:
174+
175+
```json
176+
[
177+
{
178+
""type"": ""tool_result"",
179+
""tool_use_id"": ""toolu_01D7FLrfh4GYq7yT1ULFeyMV"",
180+
""content"": ""259.75 USD""
181+
}
182+
]
183+
```
184+
185+
Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.
186+
187+
See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.",
66188
};
67189

68190
private global::System.CommandLine.Option<global::G.AnyOf<string, global::System.Collections.Generic.IList<global::G.BetaRequestTextBlock>>?> System { get; } = new(
69191
name: "system")
70192
{
71-
Description = @"",
193+
Description = @"System prompt.
194+
195+
A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).",
72196
};
73197

74198
private global::System.CommandLine.Option<global::G.BetaThinkingConfigParam?> Thinking { get; } = new(
75199
name: "thinking")
76200
{
77-
Description = @"",
201+
Description = @"Configuration for enabling Claude's extended thinking.
202+
203+
When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.
204+
205+
See [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking) for details.",
78206
};
79-
public BetaMessagesCountTokensPostCommand(G.IApi client) : base(
207+
public BetaMessagesCountTokensPostCommand(
208+
G.IApi client,
209+
global::System.IServiceProvider serviceProvider) : base(
80210
name: "beta",
81211
description: @"Count the number of tokens in a Message.
82212
@@ -85,6 +215,7 @@ public BetaMessagesCountTokensPostCommand(G.IApi client) : base(
85215
Learn more about token counting in our [user guide](/en/docs/build-with-claude/token-counting)")
86216
{
87217
_client = client;
218+
_serviceProvider = serviceProvider;
88219

89220
Arguments.Add(Messages);
90221
Arguments.Add(Model);

0 commit comments

Comments
 (0)