Add proxy configuration support in .env.example and base_client#57
Closed
daytime001 wants to merge 3 commits intoErlichLiu:mainfrom
Closed
Add proxy configuration support in .env.example and base_client#57daytime001 wants to merge 3 commits intoErlichLiu:mainfrom
daytime001 wants to merge 3 commits intoErlichLiu:mainfrom
Conversation
GowayLee
requested changes
Feb 27, 2025
| # 代理配置 | ||
| USE_PROXY=false # 是否使用代理,默认不使用.如使用请改为true,并修改PROXY_URL为对应代理地址 | ||
| PROXY_URL=http://127.0.0.1:7890 # 代理服务器地址,如不填写则不使用代理.此处默认为Clash,如果使用其他代理,需改为对应的代理地址 | ||
|
|
Collaborator
There was a problem hiding this comment.
可以将这两个环境变量合并为一个, 例如:
- 设置
PROXY_URL=false, 在读取环境变量时添加一个判断逻辑, 直接完成proxy是否为None的设置.
|
|
||
| # 根据环境变量决定是否使用代理 | ||
| proxy = self.proxy_url if self.use_proxy else None | ||
|
|
Collaborator
There was a problem hiding this comment.
将proxy声明为成员变量, base_client实例化时即可确定proxy的值. 未来发送请求时只需要传入self.proxy, 可优化该if判断.
Closed
Collaborator
Collaborator
|
已在v1.0.0中支持 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本地部署完成后,调用api请求deepgemini模型报以下错误:
经排查后发现问题出在代理上,在调用gemini时对网络有要求,因此设置了两个代理相关的环境变量
USE_PROXY和PROXY_URL,并在base_client文件中进行了相应修改。修改完成后可供用户自主选择是否使用代理,如Gemini等模型则必须使用,其它选择直连即可