mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-26 04:39:53 +01:00
fix: Gemini代理配置使用REST传输修复gRPC不支持代理的问题
This commit is contained in:
parent
f0512ce1cc
commit
145c5b37a4
1 changed files with 6 additions and 1 deletions
|
|
@ -77,6 +77,7 @@ class LLMProvider(LLMProviderBase):
|
||||||
if model_key_msg:
|
if model_key_msg:
|
||||||
log.bind(tag=TAG).error(model_key_msg)
|
log.bind(tag=TAG).error(model_key_msg)
|
||||||
|
|
||||||
|
use_proxy = False
|
||||||
if http_proxy or https_proxy:
|
if http_proxy or https_proxy:
|
||||||
log.bind(tag=TAG).info(
|
log.bind(tag=TAG).info(
|
||||||
f"检测到Gemini代理配置,开始测试代理连通性和设置代理环境..."
|
f"检测到Gemini代理配置,开始测试代理连通性和设置代理环境..."
|
||||||
|
|
@ -85,8 +86,12 @@ class LLMProvider(LLMProviderBase):
|
||||||
log.bind(tag=TAG).info(
|
log.bind(tag=TAG).info(
|
||||||
f"Gemini 代理设置成功 - HTTP: {http_proxy}, HTTPS: {https_proxy}"
|
f"Gemini 代理设置成功 - HTTP: {http_proxy}, HTTPS: {https_proxy}"
|
||||||
)
|
)
|
||||||
|
use_proxy = True
|
||||||
# 配置API密钥
|
# 配置API密钥
|
||||||
genai.configure(api_key=self.api_key)
|
if use_proxy:
|
||||||
|
genai.configure(api_key=self.api_key, transport="rest")
|
||||||
|
else:
|
||||||
|
genai.configure(api_key=self.api_key)
|
||||||
|
|
||||||
# 设置请求超时(秒)
|
# 设置请求超时(秒)
|
||||||
self.timeout = cfg.get("timeout", 120) # 默认120秒
|
self.timeout = cfg.get("timeout", 120) # 默认120秒
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue