Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/tryagi-openai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dnx tryAGI.OpenAI.CLI <group> --help
| `response` | 5 | |
| `role` | 10 | |
| `skill` | 11 | |
| `spend-alert` | 8 | |
| `spend-alert` | 10 | |
| `upload` | 4 | Use Uploads to upload large files in multiple parts. |
| `usage` | 11 | |
| `user` | 4 | |
Expand Down
2 changes: 2 additions & 0 deletions .claude/skills/tryagi-openai/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ Given text and/or image inputs, classifies if those inputs are potentially harmf
| `delete-project-spend-alert` | `DELETE /organization/projects/{project_id}/spend_alerts/{alert_id}` | Deletes a project spend alert. |
| `list-organization-spend-alerts` | `GET /organization/spend_alerts` | Lists organization spend alerts. |
| `list-project-spend-alerts` | `GET /organization/projects/{project_id}/spend_alerts` | Lists project spend alerts. |
| `retrieve-organization-spend-alert` | `GET /organization/spend_alerts/{alert_id}` | Retrieves an organization spend alert. |
| `retrieve-project-spend-alert` | `GET /organization/projects/{project_id}/spend_alerts/{alert_id}` | Retrieves a project spend alert. |
| `update-organization-spend-alert` | `POST /organization/spend_alerts/{alert_id}` | Updates an organization spend alert. |
| `update-project-spend-alert` | `POST /organization/projects/{project_id}/spend_alerts/{alert_id}` | Updates a project spend alert. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ internal static partial class AuditLogsListAuditLogsCommandApiCommand
private static Option<global::System.Collections.Generic.IList<string>?> ResourceIds { get; } = new(
name: @"--resource-ids")
{
Description = @"Return only events performed on these targets. For example, a project ID updated.",
Description = @"Return only events performed on these targets. For example, a project ID updated. For ChatGPT connector role events, use the workspace connector resource ID shown in `details.id`, such as `<workspace_id>__<connector_id>`.",
};

private static Option<bool?> TenantOnly { get; } = CliRuntime.CreateNullableBoolOption(
name: @"--tenant-only",
description: @"Return only tenant-scoped events associated with this organization. Required for tenant-scoped events such as `role.bound_to_resource` and `role.unbound_from_resource`. When `true`, all supplied event types must be tenant-scoped.");

private static Option<int?> Limit { get; } = new(
name: @"--limit")
{
Expand Down Expand Up @@ -93,6 +97,7 @@ public static Command Create()
command.Options.Add(ActorIds);
command.Options.Add(ActorEmails);
command.Options.Add(ResourceIds);
command.Options.Add(TenantOnly);
command.Options.Add(Limit);
command.Options.Add(After);
command.Options.Add(Before);
Expand All @@ -107,6 +112,7 @@ await CliRuntime.RunAsync(async () =>
var actorIds = parseResult.GetValue(ActorIds);
var actorEmails = parseResult.GetValue(ActorEmails);
var resourceIds = parseResult.GetValue(ResourceIds);
var tenantOnly = parseResult.GetValue(TenantOnly);
var limit = parseResult.GetValue(Limit);
var after = parseResult.GetValue(After);
var before = parseResult.GetValue(Before);
Expand All @@ -120,6 +126,7 @@ await CliRuntime.RunAsync(async () =>
actorIds: actorIds,
actorEmails: actorEmails,
resourceIds: resourceIds,
tenantOnly: tenantOnly,
limit: limit,
after: after,
before: before,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ internal static partial class CreateAdminApiKeyCommandApiCommand
Description = @"",
};

private static Option<int?> ExpiresInSeconds { get; } = new(
name: @"--expires-in-seconds")
{
Description = @"The number of seconds until the API key expires. Omit this field for a key that does not expire.",
};
private static Option<string?> Input { get; } = new(@"--input")
{
Description = "Load request JSON from a file path, '-' for stdin, or an inline JSON object/array string.",
};

private static Option<string?> RequestJson { get; } = new(@"--request-json")
{
Description = "Request body as JSON.",
Hidden = true,
};

private static Option<string?> RequestFile { get; } = new(@"--request-file")
{
Description = "Path to a JSON request file, or '-' for stdin.",
Hidden = true,
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.AdminApiKeyCreateResponse value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
Expand All @@ -38,17 +60,40 @@ public static Command Create()
var command = new Command(@"create-admin-api-key", @"Create an organization admin API key
Create a new admin-level API key for the organization.");
command.Arguments.Add(NameOption);

command.Options.Add(ExpiresInSeconds);
command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
command.Validators.Add(result =>
{
var hasInput = result.GetResult(Input) is not null;
var hasRequestJson = result.GetResult(RequestJson) is not null;
var hasRequestFile = result.GetResult(RequestFile) is not null;
var specifiedCount = (hasInput ? 1 : 0) + (hasRequestJson ? 1 : 0) + (hasRequestFile ? 1 : 0);
if (specifiedCount > 1)
{
result.AddError(@"Specify at most one of --input, --request-json, or --request-file.");
}
});

command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var __requestBase = await CliRuntime.ReadRequestOrDefaultAsync<global::tryAGI.OpenAI.AdminApiKeysCreateRequest>(
parseResult,
Input,
RequestJson,
RequestFile,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
cancellationToken).ConfigureAwait(false);
var name = parseResult.GetRequiredValue(NameOption);
var expiresInSeconds = CliRuntime.WasSpecified(parseResult, ExpiresInSeconds) ? parseResult.GetValue(ExpiresInSeconds) : (__requestBase is { } __ExpiresInSecondsBaseValue ? __ExpiresInSecondsBaseValue.ExpiresInSeconds : default);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.CreateAdminApiKeyAsync(
name: name,
expiresInSeconds: expiresInSeconds,
cancellationToken: cancellationToken).ConfigureAwait(false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ internal static partial class GetInputTokenCountsCommandApiCommand
Description = @"",
};

private static Option<global::tryAGI.OpenAI.TruncationEnum?> Truncation { get; } = new(
name: @"--truncation")
{
Description = @"The truncation strategy to use for the model response. - `auto`: If the input to this Response exceeds the model's context window size, the model will truncate the response to fit the context window by dropping items from the beginning of the conversation. - `disabled` (default): If the input size will exceed the context window size for a model, the request will fail with a 400 error.",
};

private static Option<string?> Instructions { get; } = new(
name: @"--instructions")
{
Expand Down Expand Up @@ -124,7 +118,6 @@ public static Command Create()
command.Options.Add(Tools);
command.Options.Add(Text);
command.Options.Add(Reasoning);
command.Options.Add(Truncation);
command.Options.Add(Instructions);
command.Options.Add(Personality);
command.Options.Add(Conversation);
Expand Down Expand Up @@ -161,7 +154,6 @@ await CliRuntime.RunAsync(async () =>
var tools = CliRuntime.WasSpecified(parseResult, Tools) ? parseResult.GetValue(Tools) : (__requestBase is { } __ToolsBaseValue ? __ToolsBaseValue.Tools : default);
var text = CliRuntime.WasSpecified(parseResult, Text) ? parseResult.GetValue(Text) : (__requestBase is { } __TextBaseValue ? __TextBaseValue.Text : default);
var reasoning = CliRuntime.WasSpecified(parseResult, Reasoning) ? parseResult.GetValue(Reasoning) : (__requestBase is { } __ReasoningBaseValue ? __ReasoningBaseValue.Reasoning : default);
var truncation = CliRuntime.WasSpecified(parseResult, Truncation) ? parseResult.GetValue(Truncation) : (__requestBase is { } __TruncationBaseValue ? __TruncationBaseValue.Truncation : default);
var instructions = CliRuntime.WasSpecified(parseResult, Instructions) ? parseResult.GetValue(Instructions) : (__requestBase is { } __InstructionsBaseValue ? __InstructionsBaseValue.Instructions : default);
var personality = CliRuntime.WasSpecified(parseResult, Personality) ? parseResult.GetValue(Personality) : (__requestBase is { } __PersonalityBaseValue ? __PersonalityBaseValue.Personality : default);
var conversation = CliRuntime.WasSpecified(parseResult, Conversation) ? parseResult.GetValue(Conversation) : (__requestBase is { } __ConversationBaseValue ? __ConversationBaseValue.Conversation : default);
Expand All @@ -177,7 +169,6 @@ await CliRuntime.RunAsync(async () =>
tools: tools,
text: text,
reasoning: reasoning,
truncation: truncation,
instructions: instructions,
personality: personality,
conversation: conversation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public static Command Create()
command.Subcommands.Add(SpendAlertsDeleteProjectSpendAlertCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsListOrganizationSpendAlertsCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsListProjectSpendAlertsCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsRetrieveOrganizationSpendAlertCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsRetrieveProjectSpendAlertCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsUpdateOrganizationSpendAlertCommandApiCommand.Create());
command.Subcommands.Add(SpendAlertsUpdateProjectSpendAlertCommandApiCommand.Create());
return command;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class SpendAlertsRetrieveOrganizationSpendAlertCommandApiCommand
{
private static Argument<string> AlertId { get; } = new(
name: @"alert-id")
{
Description = @"The ID of the spend alert to retrieve.",
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.OrganizationSpendAlert value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}

var hints = new Dictionary<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::tryAGI.OpenAI.OrganizationSpendAlert value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"retrieve-organization-spend-alert", @"Retrieves an organization spend alert.");
command.Arguments.Add(AlertId);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var alertId = parseResult.GetRequiredValue(AlertId);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.SpendAlerts.RetrieveOrganizationSpendAlertAsync(
alertId: alertId,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
return command;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#nullable enable
#pragma warning disable CS0618

using System.CommandLine;

namespace tryAGI.OpenAI.Cli.GeneratedApi.Commands;

internal static partial class SpendAlertsRetrieveProjectSpendAlertCommandApiCommand
{
private static Argument<string> ProjectId { get; } = new(
name: @"project-id")
{
Description = @"The ID of the project.",
};

private static Argument<string> AlertId { get; } = new(
name: @"alert-id")
{
Description = @"The ID of the spend alert to retrieve.",
};

private static string FormatResponse(ParseResult parseResult, global::tryAGI.OpenAI.ProjectSpendAlert value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
if (!string.IsNullOrWhiteSpace(text))
{
return text;
}

var hints = new Dictionary<string, CliFormatHint>(StringComparer.OrdinalIgnoreCase)
{
};
CustomizeResponseFormatHints(hints);
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::tryAGI.OpenAI.ProjectSpendAlert value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"retrieve-project-spend-alert", @"Retrieves a project spend alert.");
command.Arguments.Add(ProjectId);
command.Arguments.Add(AlertId);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var projectId = parseResult.GetRequiredValue(ProjectId);
var alertId = parseResult.GetRequiredValue(AlertId);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.SpendAlerts.RetrieveProjectSpendAlertAsync(
projectId: projectId,
alertId: alertId,
cancellationToken: cancellationToken).ConfigureAwait(false);


await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::tryAGI.OpenAI.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
return command;
}
}
Loading