feat: 完成openai响应接口
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Dtos.OpenAi.Responses;
|
||||
|
||||
@@ -7,14 +8,14 @@ public class OpenAiResponsesInput
|
||||
[JsonPropertyName("stream")] public bool? Stream { get; set; }
|
||||
|
||||
[JsonPropertyName("model")] public string Model { get; set; }
|
||||
[JsonPropertyName("input")] public dynamic Input { get; set; }
|
||||
[JsonPropertyName("input")] public JsonElement Input { get; set; }
|
||||
|
||||
[JsonPropertyName("max_output_tokens")]
|
||||
public int? MaxOutputTokens { get; set; }
|
||||
|
||||
[JsonPropertyName("max_tool_calls")] public dynamic? MaxToolCalls { get; set; }
|
||||
[JsonPropertyName("max_tool_calls")] public JsonElement? MaxToolCalls { get; set; }
|
||||
[JsonPropertyName("instructions")] public string? Instructions { get; set; }
|
||||
[JsonPropertyName("metadata")] public dynamic? Metadata { get; set; }
|
||||
[JsonPropertyName("metadata")] public JsonElement? Metadata { get; set; }
|
||||
|
||||
[JsonPropertyName("parallel_tool_calls")]
|
||||
public bool? ParallelToolCalls { get; set; }
|
||||
@@ -22,24 +23,24 @@ public class OpenAiResponsesInput
|
||||
[JsonPropertyName("previous_response_id")]
|
||||
public string? PreviousResponseId { get; set; }
|
||||
|
||||
[JsonPropertyName("prompt")] public dynamic? Prompt { get; set; }
|
||||
[JsonPropertyName("prompt")] public JsonElement? Prompt { get; set; }
|
||||
[JsonPropertyName("prompt_cache_key")] public string? PromptCacheKey { get; set; }
|
||||
|
||||
[JsonPropertyName("prompt_cache_retention")]
|
||||
public string? PromptCacheRetention { get; set; }
|
||||
|
||||
[JsonPropertyName("reasoning")] public dynamic? Reasoning { get; set; }
|
||||
[JsonPropertyName("reasoning")] public JsonElement? Reasoning { get; set; }
|
||||
|
||||
[JsonPropertyName("safety_identifier")]
|
||||
public string? SafetyIdentifier { get; set; }
|
||||
|
||||
[JsonPropertyName("service_tier")] public string? ServiceTier { get; set; }
|
||||
[JsonPropertyName("store")] public bool? Store { get; set; }
|
||||
[JsonPropertyName("stream_options")] public dynamic? StreamOptions { get; set; }
|
||||
[JsonPropertyName("stream_options")] public JsonElement? StreamOptions { get; set; }
|
||||
[JsonPropertyName("temperature")] public decimal? Temperature { get; set; }
|
||||
[JsonPropertyName("text")] public dynamic? Text { get; set; }
|
||||
[JsonPropertyName("tool_choice")] public dynamic? ToolChoice { get; set; }
|
||||
[JsonPropertyName("tools")] public dynamic? Tools { get; set; }
|
||||
[JsonPropertyName("text")] public JsonElement? Text { get; set; }
|
||||
[JsonPropertyName("tool_choice")] public JsonElement? ToolChoice { get; set; }
|
||||
[JsonPropertyName("tools")] public JsonElement? Tools { get; set; }
|
||||
[JsonPropertyName("top_logprobs")] public int? TopLogprobs { get; set; }
|
||||
[JsonPropertyName("top_p")] public decimal? TopP { get; set; }
|
||||
[JsonPropertyName("truncation")] public string? Truncation { get; set; }
|
||||
|
||||
@@ -52,6 +52,18 @@ public class OpenAiResponsesOutput
|
||||
public dynamic? User { get; set; }
|
||||
[JsonPropertyName("metadata")]
|
||||
public dynamic? Metadata { get; set; }
|
||||
|
||||
public void SupplementalMultiplier(decimal multiplier)
|
||||
{
|
||||
if (this.Usage is not null)
|
||||
{
|
||||
this.Usage.InputTokens =
|
||||
(int)Math.Round((this.Usage?.InputTokens ?? 0) * multiplier);
|
||||
|
||||
this.Usage.OutputTokens =
|
||||
(int)Math.Round((this.Usage?.OutputTokens ?? 0) * multiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OpenAiResponsesUsageOutput
|
||||
|
||||
Reference in New Issue
Block a user