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

如何支持非OPENAI官方的API和KEY #3427

Closed
Lvjinhong opened this issue Dec 2, 2023 · 11 comments
Closed

如何支持非OPENAI官方的API和KEY #3427

Lvjinhong opened this issue Dec 2, 2023 · 11 comments

Comments

@Lvjinhong
Copy link

您好!您的项目非常出色!我想知道您是怎么支持 类OPENAI的api和key的,
可以麻烦告知一下对应的代码位置吗? 我想参考一下

代码文件我看了好久,但是更进一步的 我想知道您是如何 设计请求结构的 ,
以至于 改变url地址后依旧可以正常对接。 这对我非常重要,如果您方便,可以麻烦帮助我一下吗? 非常感谢

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: How to support non-OPENAI official API and KEY

Hello! Your project is outstanding! I want to know how you support OPENAI-like APIs and keys.
Could you please tell me the location of the corresponding code? I want to refer to it

I have been looking at the code file for a long time, but further I want to know how you design the request structure.
So that after changing the url address, you can still connect normally. This is very important to me. If it's convenient for you, could you help me? Thank you very much

@Yidadaa
Copy link
Collaborator

Yidadaa commented Dec 3, 2023

为什么不读文档?BASE_URL 和 API_KEY 就是为了兼容 openai 类型的接口而生的。

@Yidadaa Yidadaa closed this as completed Dec 3, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Why not read the documentation? BASE_URL and API_KEY are created to be compatible with openai type interfaces.

@jiz4oh
Copy link

jiz4oh commented Dec 13, 2023

Hi @Yidadaa, 非常感谢你创造这个项目。我发现 BASE_URL 的处理有点问题,假如 BASE_URL 包含 path,输出的请求地址是非预期值,比如

BASE_URL=http://example.org/abc123

最终请求的地址会变为

/abc123/v1/chat/completions?path=v1&path=chat&path=completions
image

在 setting 里面指定 custom endpoint 时不会,只会在环境变量中指定 BASE_URL 的时候会有这种情况

@FranzKafkaYu
Copy link

首先要非常感谢作者的项目,在部署过程中我也有类似的问题,我的API 地址基于Pandora生成,使用BASE_URL环境变量指定时发现Post请求会额外添加路径参数,导致无法正常使用;但是如果我直接在Web中设置URL地址却是可用的,请问该问题该如何解决呢

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


First of all, I would like to thank the author very much for his project. I also had a similar problem during the deployment process. My API address was generated based on Pandora. When specified using the BASE_URL environment variable, I found that the Post request would add additional path parameters, causing it to not work properly; but if I directly It is possible to set the URL address in the Web. How to solve this problem?

@zhangwengyu999
Copy link

Same problem, looking forward to the solution.

@zhangwengyu999
Copy link

I get the solution, change the line 15 of the ./app/api/common.ts from

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(

to

let path = `${req.nextUrl.pathname}`.replaceAll(

where the ${req.nextUrl.search} is removed, so Proxy path will become v1/chat/completions only.

It works for me.

@rookis1
Copy link

rookis1 commented Dec 15, 2023

I get the solution, change the line 15 of the ./app/api/common.ts from

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(

to

let path = `${req.nextUrl.pathname}`.replaceAll(

where the ${req.nextUrl.search} is removed, so Proxy path will become v1/chat/completions only.

It works for me.

it works !

@429383298
Copy link

我得到了解决方案,将 ./app/api/common.ts 的第 15 行

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(

let path = `${req.nextUrl.pathname}`.replaceAll(

其中,则代理路径将变为 only。${req.nextUrl.search}``v1/chat/completions

它对我有用。

你好,请问在群晖的Docker 中如何修改?我并没有找到这个文件。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I got the solution, line 15 of .[/app/api/common.ts](https://github.com/ChatGPTNextWebTeam/ChatGPT-Next-Web/blob/main/app/api/common. ts#L15)from

let path = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll(

since

let path = `${req.nextUrl.pathname}`.replaceAll(

where the proxy path will become only. ${req.nextUrl.search}``v1/chat/completions

It works for me.

Hello, how to modify it in Synology’s Docker? I didn't find this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants