feat: 全面支持geminicli
This commit is contained in:
@@ -262,7 +262,7 @@ public class OpenApiService : ApplicationService
|
||||
/// <param name="modelId"></param>
|
||||
/// <param name="alt"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
[HttpPost("openApi/v1beta/models/{modelId}:generateContent")]
|
||||
[HttpPost("openApi/v1beta/models/{modelId}:{action:regex(^(generateContent|streamGenerateContent)$)}")]
|
||||
public async Task GenerateContentAsync([FromBody] JsonElement input,
|
||||
[FromRoute] string modelId,
|
||||
[FromQuery] string? alt, CancellationToken cancellationToken)
|
||||
@@ -297,13 +297,15 @@ public class OpenApiService : ApplicationService
|
||||
//ai网关代理httpcontext
|
||||
if (alt == "sse")
|
||||
{
|
||||
// await _aiGateWayManager.OpenAiResponsesStreamForStatisticsAsync(_httpContextAccessor.HttpContext,
|
||||
// input,
|
||||
// userId, null, tokenId, cancellationToken);
|
||||
await _aiGateWayManager.GeminiGenerateContentStreamForStatisticsAsync(_httpContextAccessor.HttpContext,
|
||||
modelId, input,
|
||||
userId,
|
||||
null, tokenId,
|
||||
cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _aiGateWayManager.GeminiGenerateContentAsyncForStatisticsAsync(_httpContextAccessor.HttpContext,
|
||||
await _aiGateWayManager.GeminiGenerateContentForStatisticsAsync(_httpContextAccessor.HttpContext,
|
||||
modelId, input,
|
||||
userId,
|
||||
null, tokenId,
|
||||
@@ -321,6 +323,13 @@ public class OpenApiService : ApplicationService
|
||||
{
|
||||
return apiKeyHeader.Trim();
|
||||
}
|
||||
|
||||
// 再从 谷歌 获取
|
||||
string googApiKeyHeader = httpContext.Request.Headers["x-goog-api-key"];
|
||||
if (!string.IsNullOrWhiteSpace(googApiKeyHeader))
|
||||
{
|
||||
return googApiKeyHeader.Trim();
|
||||
}
|
||||
|
||||
// 再检查 Authorization 头
|
||||
string authHeader = httpContext.Request.Headers["Authorization"];
|
||||
|
||||
Reference in New Issue
Block a user