Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gemini 增加代理终结点设置 #11

Merged
merged 1 commit into from
Jun 23, 2024
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
4 changes: 4 additions & 0 deletions docs/chat-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ Azure Open AI 相较于 Open AI,最大的不同在于你需要手动部署需

和 [Open AI](#open-ai) 类似,获取访问密钥后,将其填入 `访问密钥` 中即可。

### 代理

Gemini 作为谷歌提供的 AI 服务,国内用户如果要访问,也可能需要代理,这一点和 [OpenAI](#open-ai) 是一致的,请参考 Open AI 的配置方式,配置 Gemini 的代理服务。需要注意的是,Gemini 中的代理终结点不要加版本号,目前应用使用 `v1-beta`。

## Anthropic

|||
Expand Down
4 changes: 2 additions & 2 deletions src/Core/RodelChat.Core/Providers/GeminiProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class GeminiProvider : ProviderBase, IProvider
public GeminiProvider(GeminiClientConfig config)
: base(config.Key, config.CustomModels)
{
SetBaseUri(ProviderConstants.GeminiApi);
SetBaseUri(ProviderConstants.GeminiApi, config.Endpoint);
ServerModels = PredefinedModels.GeminiModels;
}

Expand All @@ -30,7 +30,7 @@ public GeminiProvider(GeminiClientConfig config)
if (ShouldRecreateKernel(modelId))
{
Kernel = Kernel.CreateBuilder()
.AddGoogleAIGeminiChatCompletion(modelId, AccessKey)
.AddGoogleAIGeminiChatCompletion(modelId, BaseUri, AccessKey)
.Build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public sealed class DashScopeClientConfig : ClientConfigBase
/// <summary>
/// Gemini 客户端配置.
/// </summary>
public sealed class GeminiClientConfig : ClientConfigBase
public sealed class GeminiClientConfig : ClientEndpointConfigBase
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ private ClientConfigBase CreateCurrentConfig()
{
config.Endpoint = ProviderConstants.AnthropicApi;
}
else if (config is GeminiClientConfig)
{
config.Endpoint = ProviderConstants.GeminiApi;
}
else if (config is OllamaClientConfig)
{
config.Endpoint = ProviderConstants.OllamaApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ private ClientEndpointConfigBase CreateCurrentConfig()
{
config.Endpoint = ProviderConstants.AnthropicApi;
}
else if (config is GeminiClientConfig)
{
config.Endpoint = ProviderConstants.GeminiApi;
}
else if (config is OllamaClientConfig)
{
config.Key = "ollama";
config.Endpoint = ProviderConstants.OllamaApi;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ protected override void OnViewModelChanged(DependencyPropertyChangedEventArgs e)
or ProviderType.ZhiPu
or ProviderType.LingYi
or ProviderType.DeepSeek
or ProviderType.Gemini
or ProviderType.OpenRouter
or ProviderType.Groq
or ProviderType.MistralAI
or ProviderType.TogetherAI
or ProviderType.Perplexity
or ProviderType.DashScope => CreateForm<ChatClientConfigSection>(),
ProviderType.Anthropic
or ProviderType.Gemini
or ProviderType.Ollama => CreateForm<ChatClientEndpointConfigSection>(),
ProviderType.OpenAI => CreateForm<OpenAIChatConfigSection>(),
ProviderType.AzureOpenAI => CreateForm<AzureOpenAIChatConfigSection>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ protected override async void OnPageLoaded()
or ProviderType.ZhiPu
or ProviderType.LingYi
or ProviderType.DeepSeek
or ProviderType.Gemini
or ProviderType.OpenRouter
or ProviderType.Groq
or ProviderType.MistralAI
or ProviderType.TogetherAI
or ProviderType.Perplexity
or ProviderType.DashScope => CreateForm<ModelClientConfigSettingSection>(item),
ProviderType.Anthropic
or ProviderType.Gemini
or ProviderType.Ollama => CreateForm<ModelClientEndpointConfigSettingSection>(item),
ProviderType.OpenAI => CreateForm<OpenAIChatConfigSettingSection>(item),
ProviderType.AzureOpenAI => CreateForm<AzureOpenAIChatConfigSettingSection>(item),
Expand Down
Loading