diff --git a/docs/chat-config.md b/docs/chat-config.md index 16f3632..2df7e22 100644 --- a/docs/chat-config.md +++ b/docs/chat-config.md @@ -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 ||| diff --git a/src/Core/RodelChat.Core/Providers/GeminiProvider.cs b/src/Core/RodelChat.Core/Providers/GeminiProvider.cs index f3999ef..3a761da 100644 --- a/src/Core/RodelChat.Core/Providers/GeminiProvider.cs +++ b/src/Core/RodelChat.Core/Providers/GeminiProvider.cs @@ -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; } @@ -30,7 +30,7 @@ public GeminiProvider(GeminiClientConfig config) if (ShouldRecreateKernel(modelId)) { Kernel = Kernel.CreateBuilder() - .AddGoogleAIGeminiChatCompletion(modelId, AccessKey) + .AddGoogleAIGeminiChatCompletion(modelId, BaseUri, AccessKey) .Build(); } diff --git a/src/Core/RodelChat.Models/Client/ChatClientConfiguration.cs b/src/Core/RodelChat.Models/Client/ChatClientConfiguration.cs index 0ef65f7..5808987 100644 --- a/src/Core/RodelChat.Models/Client/ChatClientConfiguration.cs +++ b/src/Core/RodelChat.Models/Client/ChatClientConfiguration.cs @@ -238,7 +238,7 @@ public sealed class DashScopeClientConfig : ClientConfigBase /// /// Gemini 客户端配置. /// -public sealed class GeminiClientConfig : ClientConfigBase +public sealed class GeminiClientConfig : ClientEndpointConfigBase { } diff --git a/src/Desktop/RodelAgent.UI/Controls/Settings/ModelClientEndpointConfigSettingSection.xaml.cs b/src/Desktop/RodelAgent.UI/Controls/Settings/ModelClientEndpointConfigSettingSection.xaml.cs index 132873d..8000f4a 100644 --- a/src/Desktop/RodelAgent.UI/Controls/Settings/ModelClientEndpointConfigSettingSection.xaml.cs +++ b/src/Desktop/RodelAgent.UI/Controls/Settings/ModelClientEndpointConfigSettingSection.xaml.cs @@ -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; diff --git a/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatClientEndpointConfigSection.xaml.cs b/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatClientEndpointConfigSection.xaml.cs index 10201a9..97b8e71 100644 --- a/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatClientEndpointConfigSection.xaml.cs +++ b/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatClientEndpointConfigSection.xaml.cs @@ -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; } diff --git a/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatConfigurationSection.xaml.cs b/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatConfigurationSection.xaml.cs index f20bbc0..62bd63e 100644 --- a/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatConfigurationSection.xaml.cs +++ b/src/Desktop/RodelAgent.UI/Controls/Startup/Chat/ChatConfigurationSection.xaml.cs @@ -33,7 +33,6 @@ 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 @@ -41,6 +40,7 @@ or ProviderType.TogetherAI or ProviderType.Perplexity or ProviderType.DashScope => CreateForm(), ProviderType.Anthropic + or ProviderType.Gemini or ProviderType.Ollama => CreateForm(), ProviderType.OpenAI => CreateForm(), ProviderType.AzureOpenAI => CreateForm(), diff --git a/src/Desktop/RodelAgent.UI/Pages/Settings/ChatServicesPage.xaml.cs b/src/Desktop/RodelAgent.UI/Pages/Settings/ChatServicesPage.xaml.cs index dc5a9c5..b6b2398 100644 --- a/src/Desktop/RodelAgent.UI/Pages/Settings/ChatServicesPage.xaml.cs +++ b/src/Desktop/RodelAgent.UI/Pages/Settings/ChatServicesPage.xaml.cs @@ -29,7 +29,6 @@ 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 @@ -37,6 +36,7 @@ or ProviderType.TogetherAI or ProviderType.Perplexity or ProviderType.DashScope => CreateForm(item), ProviderType.Anthropic + or ProviderType.Gemini or ProviderType.Ollama => CreateForm(item), ProviderType.OpenAI => CreateForm(item), ProviderType.AzureOpenAI => CreateForm(item),