feat: 支持图片生成
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi.Images;
|
||||
|
||||
/// <summary>
|
||||
/// Image Create Request Model
|
||||
/// </summary>
|
||||
public record ImageCreateRequest : SharedImageRequestBaseModel
|
||||
{
|
||||
public ImageCreateRequest()
|
||||
{
|
||||
}
|
||||
|
||||
public ImageCreateRequest(string prompt)
|
||||
{
|
||||
Prompt = prompt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A text description of the desired image(s). The maximum length is 1000 characters for dall-e-2 and 4000 characters for dall-e-3
|
||||
/// </summary>
|
||||
[JsonPropertyName("prompt")]
|
||||
public string Prompt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The quality of the image that will be generated. Possible values are 'standard' or 'hd' (default is 'standard').
|
||||
/// Hd creates images with finer details and greater consistency across the image.
|
||||
/// This param is only supported for dall-e-3 model.
|
||||
/// <br /><br />Check <see cref="StaticValues.ImageStatics.Quality"/> for possible values
|
||||
/// </summary>
|
||||
[JsonPropertyName("quality")]
|
||||
public string? Quality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The style of the generated images. Must be one of vivid or natural.
|
||||
/// Vivid causes the model to lean towards generating hyper-real and dramatic images.
|
||||
/// Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for dall-e-3.
|
||||
/// <br /><br />Check <see cref="StaticValues.ImageStatics.Style"/> for possible values
|
||||
/// </summary>
|
||||
[JsonPropertyName("style")]
|
||||
public string? Style { get; set; }
|
||||
|
||||
[JsonPropertyName("background")]
|
||||
public string? Background { get; set; }
|
||||
|
||||
[JsonPropertyName("moderation")]
|
||||
public string? Moderation { get; set; }
|
||||
|
||||
[JsonPropertyName("output_compression")]
|
||||
public string? OutputCompression { get; set; }
|
||||
|
||||
[JsonPropertyName("output_format")]
|
||||
public string? OutputFormat { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi.Images;
|
||||
|
||||
public record ImageCreateResponse : ThorBaseResponse
|
||||
{
|
||||
[JsonPropertyName("data")] public List<ImageDataResult> Results { get; set; }
|
||||
|
||||
[JsonPropertyName("usage")] public ThorUsageResponse? Usage { get; set; } = new();
|
||||
|
||||
|
||||
|
||||
public record ImageDataResult
|
||||
{
|
||||
[JsonPropertyName("url")] public string Url { get; set; }
|
||||
[JsonPropertyName("b64_json")] public string B64 { get; set; }
|
||||
[JsonPropertyName("revised_prompt")] public string RevisedPrompt { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi.Images;
|
||||
|
||||
public record ImageEditCreateRequest : SharedImageRequestBaseModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The image to edit. Must be a valid PNG file, less than 4MB, and square.
|
||||
/// </summary>
|
||||
public byte[]? Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Image file name
|
||||
/// </summary>
|
||||
public string ImageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited.
|
||||
/// Must be a valid PNG file, less than 4MB, and have the same dimensions as image.
|
||||
/// </summary>
|
||||
public byte[]? Mask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mask file name
|
||||
/// </summary>
|
||||
public string? MaskName { get; set; }
|
||||
|
||||
[JsonPropertyName("quality")]
|
||||
public string Quality { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A text description of the desired image(s). The maximum length is 1000 characters.
|
||||
/// </summary>
|
||||
[JsonPropertyName("prompt")]
|
||||
public string Prompt { get; set; }
|
||||
|
||||
[JsonPropertyName("background")]
|
||||
public string? Background { get; set; }
|
||||
|
||||
[JsonPropertyName("moderation")]
|
||||
public string? Moderation { get; set; }
|
||||
|
||||
[JsonPropertyName("output_compression")]
|
||||
public string? OutputCompression { get; set; }
|
||||
|
||||
[JsonPropertyName("output_format")]
|
||||
public string? OutputFormat { get; set; }
|
||||
|
||||
[JsonPropertyName("style")]
|
||||
public string? Style { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi.Images;
|
||||
|
||||
public record ImageVariationCreateRequest : SharedImageRequestBaseModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The image to edit. Must be a valid PNG file, less than 4MB, and square.
|
||||
/// </summary>
|
||||
public byte[] Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Image file name
|
||||
/// </summary>
|
||||
public string ImageName { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.Framework.AiHub.Application.Contracts.Dtos.OpenAi.Images;
|
||||
|
||||
public record SharedImageRequestBaseModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of images to generate. Must be between 1 and 10.
|
||||
/// For dall-e-3 model, only n=1 is supported.
|
||||
/// </summary>
|
||||
[JsonPropertyName("n")]
|
||||
public int? N { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the generated images.
|
||||
/// Must be one of 256x256, 512x512, or 1024x1024 for dall-e-2.
|
||||
/// Must be one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3 models.
|
||||
/// <br /><br />Check <see cref="StaticValues.ImageStatics.Size"/> for possible values
|
||||
/// </summary>
|
||||
[JsonPropertyName("size")]
|
||||
public string? Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The format in which the generated images are returned. Must be one of url or b64_json
|
||||
/// </summary>
|
||||
[JsonPropertyName("response_format")]
|
||||
public string? ResponseFormat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
|
||||
/// <a href="https://platform.openai.com/docs/usage-policies/end-user-ids">Learn more</a>.
|
||||
/// </summary>
|
||||
[JsonPropertyName("user")]
|
||||
public string? User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The model to use for image generation. Must be one of dall-e-2 or dall-e-3
|
||||
/// For ImageEditCreateRequest and for ImageVariationCreateRequest only dall-e-2 modell is supported at this time.
|
||||
/// </summary>
|
||||
[JsonPropertyName("model")]
|
||||
public string? Model { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user