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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal static class ImageGenerationApiGroupCommand
public static Command Create()
{
var command = new Command(@"image-generation", @"Image Generation endpoint commands.");
command.Subcommands.Add(ImageGenerationGetGeneratedImageCommandApiCommand.Create());
command.Subcommands.Add(ImageGenerationOpenaiImagesEditsCommandApiCommand.Create());
command.Subcommands.Add(ImageGenerationOpenaiImagesGenerationsCommandApiCommand.Create());
command.Subcommands.Add(ImageGenerationOpenaiImagesVariationsCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,15 @@

namespace DeepInfra.CLI.Commands;

internal static partial class ModelsModelVersionsCommandApiCommand
internal static partial class ImageGenerationGetGeneratedImageCommandApiCommand
{
private static Argument<string> ModelName { get; } = new(
name: @"model-name")
private static Argument<string> ImageId { get; } = new(
name: @"image-id")
{
Description = @"",
};

private static Option<string?> XiApiKey { get; } = new(
name: @"--xi-api-key")
{
Description = @"",
};

private static Option<string?> XApiKey { get; } = new(
name: @"--x-api-key")
{
Description = @"",
};

private static string FormatResponse(ParseResult parseResult, global::System.Collections.Generic.IList<global::DeepInfra.ModelVersionOut> value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
private static string FormatResponse(ParseResult parseResult, string value, global::System.Text.Json.Serialization.JsonSerializerContext context, bool truncateLongStrings)
{
string? text = null;
CustomizeResponseText(parseResult, value, ref text);
Expand All @@ -41,48 +29,35 @@ private static string FormatResponse(ParseResult parseResult, global::System.Col
return CliRuntime.FormatHumanReadable(value, context, truncateLongStrings, hints);
}

static partial void CustomizeResponseText(ParseResult parseResult, global::System.Collections.Generic.IList<global::DeepInfra.ModelVersionOut> value, ref string? text);
static partial void CustomizeResponseText(ParseResult parseResult, string value, ref string? text);
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


public static Command Create()
{
var command = new Command(@"versions", @"Model Versions");
command.Arguments.Add(ModelName);
command.Options.Add(XiApiKey);
command.Options.Add(XApiKey);
var command = new Command(@"get-generated-image", @"Get Generated Image
Serve a `response_format=url` image; unauthenticated, 404 once expired.");
command.Arguments.Add(ImageId);


command.SetAction(async (ParseResult parseResult, CancellationToken cancellationToken) =>
await CliRuntime.RunAsync(async () =>
{
var modelName = parseResult.GetRequiredValue(ModelName);
var xiApiKey = parseResult.GetValue(XiApiKey);
var xApiKey = parseResult.GetValue(XApiKey);
var imageId = parseResult.GetRequiredValue(ImageId);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


var response = await client.Models.ModelVersionsAsync(
modelName: modelName,
xiApiKey: xiApiKey,
xApiKey: xApiKey,
var response = await client.ImageGeneration.GetGeneratedImageAsync(
imageId: imageId,
cancellationToken: cancellationToken).ConfigureAwait(false);


if (!await CliRuntime.TryWriteOutputDirectoryAsync(
parseResult,
response,
global::DeepInfra.SourceGenerationContext.Default,
@"$self",
cancellationToken).ConfigureAwait(false))
{
await CliRuntime.WriteResponseAsync(
parseResult,
response,
global::DeepInfra.SourceGenerationContext.Default,
FormatResponse,
cancellationToken).ConfigureAwait(false);
}
}, cancellationToken).ConfigureAwait(false));
return command;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ internal static partial class ImageGenerationOpenaiImagesEditsCommandApiCommand
Description = @"",
Required = true,
};

private static Option<global::DeepInfra.OpenAIImagesResponseFormat?> ResponseFormat { get; } = new(
name: @"--response-format")
{
Description = @"",
};
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.",
Expand Down Expand Up @@ -100,6 +106,7 @@ public static Command Create()
command.Options.Add(Inp);
command.Options.Add(Prompt);
command.Options.Add(Model);
command.Options.Add(ResponseFormat);
command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
Expand Down Expand Up @@ -132,6 +139,7 @@ await CliRuntime.RunAsync(async () =>
var inp = CliRuntime.WasSpecified(parseResult, Inp) ? parseResult.GetValue(Inp) : (__requestBase is { } __InpBaseValue ? __InpBaseValue.Inp : default);
var prompt = parseResult.GetRequiredValue(Prompt);
var model = parseResult.GetRequiredValue(Model);
var responseFormat = CliRuntime.WasSpecified(parseResult, ResponseFormat) ? parseResult.GetValue(ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


Expand All @@ -143,6 +151,7 @@ await CliRuntime.RunAsync(async () =>
inp: inp,
prompt: prompt,
model: model,
responseFormat: responseFormat,
cancellationToken: cancellationToken).ConfigureAwait(false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal static partial class ImageGenerationOpenaiImagesGenerationsCommandApiCo
private static Option<global::DeepInfra.OpenAIImagesResponseFormat?> ResponseFormat { get; } = new(
name: @"--response-format")
{
Description = @"The format in which the generated images are returned. Currently only b64_json is supported.",
Description = @"The format in which the generated images are returned: 'b64_json' (default) or 'url'. For most models 'url' points to a temporary copy we host that expires after about a day; for some provider-backed models it is the provider's own URL with the provider's own lifetime.",
};

private static Option<string?> Size { get; } = new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ internal static partial class ImageGenerationOpenaiImagesVariationsCommandApiCom
Description = @"",
Required = true,
};

private static Option<global::DeepInfra.OpenAIImagesResponseFormat?> ResponseFormat { get; } = new(
name: @"--response-format")
{
Description = @"",
};
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.",
Expand Down Expand Up @@ -92,6 +98,7 @@ public static Command Create()
command.Options.Add(Imagename);
command.Options.Add(Inp);
command.Options.Add(Model);
command.Options.Add(ResponseFormat);
command.Options.Add(Input);
command.Options.Add(RequestJson);
command.Options.Add(RequestFile);
Expand Down Expand Up @@ -123,6 +130,7 @@ await CliRuntime.RunAsync(async () =>
var imagename = parseResult.GetRequiredValue(Imagename);
var inp = CliRuntime.WasSpecified(parseResult, Inp) ? parseResult.GetValue(Inp) : (__requestBase is { } __InpBaseValue ? __InpBaseValue.Inp : default);
var model = parseResult.GetRequiredValue(Model);
var responseFormat = CliRuntime.WasSpecified(parseResult, ResponseFormat) ? parseResult.GetValue(ResponseFormat) : (__requestBase is { } __ResponseFormatBaseValue ? __ResponseFormatBaseValue.ResponseFormat : default);
using var client = await CliRuntime.CreateClientAsync(parseResult, cancellationToken).ConfigureAwait(false);


Expand All @@ -133,6 +141,7 @@ await CliRuntime.RunAsync(async () =>
imagename: imagename,
inp: inp,
model: model,
responseFormat: responseFormat,
cancellationToken: cancellationToken).ConfigureAwait(false);


Expand Down
1 change: 0 additions & 1 deletion src/cli/DeepInfra.CLI/Commands/ModelsApiGroupCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static Command Create()
command.Subcommands.Add(ModelsModelMetaUpdateCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelPublicityCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelSchemaCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelVersionsCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelsDeploymentListCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelsFeaturedCommandApiCommand.Create());
command.Subcommands.Add(ModelsModelsInfoCommandApiCommand.Create());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,30 @@

namespace DeepInfra
{
public partial interface IModelsClient
public partial interface IImageGenerationClient
{
/// <summary>
/// Model Versions
/// Get Generated Image<br/>
/// Serve a `response_format=url` image; unauthenticated, 404 once expired.
/// </summary>
/// <param name="modelName"></param>
/// <param name="xiApiKey"></param>
/// <param name="xApiKey"></param>
/// <param name="imageId"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
global::System.Threading.Tasks.Task<global::System.Collections.Generic.IList<global::DeepInfra.ModelVersionOut>> ModelVersionsAsync(
string modelName,
string? xiApiKey = default,
string? xApiKey = default,
global::System.Threading.Tasks.Task<string> GetGeneratedImageAsync(
string imageId,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Model Versions
/// Get Generated Image<br/>
/// Serve a `response_format=url` image; unauthenticated, 404 once expired.
/// </summary>
/// <param name="modelName"></param>
/// <param name="xiApiKey"></param>
/// <param name="xApiKey"></param>
/// <param name="imageId"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
global::System.Threading.Tasks.Task<global::DeepInfra.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::DeepInfra.ModelVersionOut>>> ModelVersionsAsResponseAsync(
string modelName,
string? xiApiKey = default,
string? xApiKey = default,
global::System.Threading.Tasks.Task<global::DeepInfra.AutoSDKHttpResponse<string>> GetGeneratedImageAsResponseAsync(
string imageId,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public partial interface IImageGenerationClient
/// <param name="inp"></param>
/// <param name="prompt"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
Expand All @@ -60,6 +61,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesEditsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);

Expand All @@ -76,6 +78,7 @@ public partial interface IImageGenerationClient
/// <param name="inp"></param>
/// <param name="prompt"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
Expand All @@ -87,6 +90,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesEditsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
Expand All @@ -102,6 +106,7 @@ public partial interface IImageGenerationClient
/// <param name="inp"></param>
/// <param name="prompt"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
Expand All @@ -113,6 +118,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesEditsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public partial interface IImageGenerationClient
/// Default Value: 1
/// </param>
/// <param name="responseFormat">
/// The format in which the generated images are returned. Currently only b64_json is supported.<br/>
/// The format in which the generated images are returned: 'b64_json' (default) or 'url'. For most models 'url' points to a temporary copy we host that expires after about a day; for some provider-backed models it is the provider's own URL with the provider's own lifetime.<br/>
/// Default Value: b64_json
/// </param>
/// <param name="size">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public partial interface IImageGenerationClient
/// <param name="imagename"></param>
/// <param name="inp"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
Expand All @@ -58,6 +59,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesVariationsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);

Expand All @@ -73,6 +75,7 @@ public partial interface IImageGenerationClient
/// <param name="imagename"></param>
/// <param name="inp"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
Expand All @@ -83,6 +86,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesVariationsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
Expand All @@ -97,6 +101,7 @@ public partial interface IImageGenerationClient
/// <param name="imagename"></param>
/// <param name="inp"></param>
/// <param name="model"></param>
/// <param name="responseFormat"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::DeepInfra.ApiException"></exception>
Expand All @@ -107,6 +112,7 @@ public partial interface IImageGenerationClient
string? xiApiKey = default,
string? xApiKey = default,
global::DeepInfra.OpenAIImagesVariationsIn? inp = default,
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default,
global::DeepInfra.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default);
}
Expand Down
Loading