feat: 新增gemini支持
This commit is contained in:
@@ -11,6 +11,8 @@ public class PremiumPackageConst
|
||||
"claude-opus-4-5-20251101",
|
||||
"gemini-3-pro-preview",
|
||||
"gpt-5.1-codex-max",
|
||||
"gpt-5.2"
|
||||
"gpt-5.2",
|
||||
"gemini-3-pro-high",
|
||||
"gemini-3-pro-image-preview"
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Text.Json;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Dtos.OpenAi;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Extensions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Dtos.Gemini;
|
||||
|
||||
public static class GeminiGenerateContentAcquirer
|
||||
{
|
||||
public static ThorUsageResponse GetUsage(JsonElement response)
|
||||
{
|
||||
var usage = response.GetPath("usageMetadata");
|
||||
if (!usage.HasValue)
|
||||
{
|
||||
return new ThorUsageResponse();
|
||||
}
|
||||
|
||||
var inputTokens = usage.Value.GetPath("promptTokenCount").GetInt();
|
||||
var outputTokens = usage.Value.GetPath("candidatesTokenCount").GetInt()
|
||||
+ usage.Value.GetPath("cachedContentTokenCount").GetInt()
|
||||
+ usage.Value.GetPath("thoughtsTokenCount").GetInt()
|
||||
+ usage.Value.GetPath("toolUsePromptTokenCount").GetInt();
|
||||
|
||||
|
||||
return new ThorUsageResponse
|
||||
{
|
||||
PromptTokens = inputTokens,
|
||||
InputTokens = inputTokens,
|
||||
OutputTokens = outputTokens,
|
||||
CompletionTokens = outputTokens,
|
||||
TotalTokens = inputTokens + outputTokens,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,5 +11,8 @@ public enum ModelApiTypeEnum
|
||||
Claude,
|
||||
|
||||
[Description("Response")]
|
||||
Response
|
||||
Response,
|
||||
|
||||
[Description("GenerateContent")]
|
||||
GenerateContent
|
||||
}
|
||||
Reference in New Issue
Block a user