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

feat: API Host代理配置 #49

Closed
Ace-Radom opened this issue May 19, 2023 · 2 comments · Fixed by #50
Closed

feat: API Host代理配置 #49

Ace-Radom opened this issue May 19, 2023 · 2 comments · Fixed by #50
Labels
enhancement New feature or request feat New request on features

Comments

@Ace-Radom
Copy link
Collaborator

这是一个在别的一些chatgpt项目里普遍存在的一个功能 我觉得也可以加到这里来

https://github.com/justjavac/openai-proxy

因为这个项目以及其他一些代理项目的存在 有一些处在国外的服务器在为国内的用户提供无需全局代理的API转接服务
也就是更改API的Host到他们提供的域名上 这些网站会把所有请求原封不动转发给openai官方api 随后收到回复后再转回用户
这样的好处是这些服务器是位于国外的而且不会被GFW影响 同时也不会被openai封锁账户停用

我在隔壁也实现了这样的功能:

openai -> host = OPENAI_HOST;
openai -> endpoint = ( char* ) malloc( 256 );
sprintf( openai -> endpoint , "%s/v1/chat/completions" , openai -> host );
openai -> subscription_endpoint = ( char* ) malloc( 256 );
sprintf( openai -> subscription_endpoint , "%s/dashboard/billing/subscription" , openai -> host );
openai -> usage_endpoint = ( char* ) malloc( 256 );
sprintf( openai -> usage_endpoint , "%s/dashboard/billing/usage" , openai -> host );

实现方法也很简单 在 ChatGPT 类内新增一个成员变量存放使用的Host 然后基于这个Host在后面加上类似于 /v1/chat/completions 之类的endpoint来得到API地址

你可以考虑一下

@Ace-Radom Ace-Radom added enhancement New feature or request feat New request on features labels May 19, 2023
@xiaoxx970
Copy link
Owner

我觉得可以,在配置文件里新增一个host配置项然后可以修改成其他反向代理地址,你有空可以弄弄

@Ace-Radom
Copy link
Collaborator Author

基本弄好了 我就开PR了

@xiaoxx970 xiaoxx970 linked a pull request May 20, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat New request on features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants