ChatGPTNextWeb / ChatGPT-Next-Web

A cross-platform ChatGPT/Gemini UI (Web / PWA / Linux / Win / MacOS). 一键拥有你自己的跨平台 ChatGPT/Gemini 应用。
https://app.nextchat.dev/
MIT License
76.46k stars 59.12k forks source link

[question]Claude模型的请求地址改了吗?原来是BASE_URL/v1/chat/completions,现在Claude模型的改为了BASE_URL/v1/messages,于是报错了 #4478

Closed Innocent-children closed 7 months ago

Innocent-children commented 7 months ago

Bug Description

Claude模型的请求地址改了吗?原来是BASE_URL/v1/chat/completions,现在Claude模型的请求地址改为了BASE_URL/v1/messages,于是报错了

Steps to Reproduce

使用ChatGPT next web,部署方式是vercel

返回信息如下:

{
  "error": {
    "message": "Invalid URL (POST /v1/messages)",
    "type": "invalid_request_error",
    "param": "",
    "code": ""
  }
}

Expected Behavior

Claude opus可以正确返回

Screenshots

No response

Deployment Method

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

nextchat-manager[bot] commented 7 months ago

Please follow the issue template to update title and description of your issue.

Issues-translate-bot commented 7 months ago

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


Title: [question]Has the request address of Claude model been changed? It used to be BASE_URL/v1/chat/completions, but now the Claude model has been changed to BASE_URL/v1/messages, so an error was reported.

Dean-YZG commented 7 months ago

Please repeat the application configuration in detail and provide the specific request url

Innocent-children commented 7 months ago

以下是最新代码使用Claude opus的结果: 请求 URL: https://[XXX].vercel.app/api/anthropic/v1/messages 请求方法: POST Status Code: 404 Not Found 远程地址: 127.0.0.1:10809 Referrer Policy: strict-origin-when-cross-origin

以下是上个版本代码使用Claude opus的结果: 请求 URL: https://[XXX]/api/openai/v1/chat/completions 请求方法: POST Status Code: 200 OK 远程地址: 127.0.0.1:10809 Referrer Policy: strict-origin-when-cross-origin

Dean-YZG commented 7 months ago

这个域名是通过什么方式配置的?[XXX].vercel.app,如果是通过服务的 BASE_URL, proxy 将会 拼接BASE_URL 、v1/messages,发起请求;若通过客户端配置 anthropicUrl,则 客户端会拼接 anthropicUrl、v1/messages,发起请求,直接向服务发起请求

Issues-translate-bot commented 7 months ago

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


How is this domain name configured? [XXX].vercel.app, if it is through the BASE_URL of the service, the proxy will concatenate BASE_URL and v1/messages to initiate the request; if the anthropoticUrl is configured through the client, the client will concatenate anthropoticUrl and v1/messages to initiate the request directly. Make a request to a service

Innocent-children commented 7 months ago

域名是vercel自动生成的,我使用了CNAME解析,我的域名是:www.abc.com。对于Claude模型,上个版本代码完整的请求URL是:https://www.abc.com/api/openai/v1/chat/completions;这个版本代码完整的请求URL是:https://www.abc.com/api/openai/v1/messages;我认为是由于更改了代码,导致请求URL由/v1/chat/completions变为了/v1/messages,我的疑问是如果这个改变是由于Claude官方的规则变化而来,那么是我API中转的问题,如果Claude官方最近没有任何规则变更,那可能是请求URL有误。此外GPT系列模型的请求地址一直是:https://www.abc.com/api/openai/v1/chat/completions

Dean-YZG commented 7 months ago

get,是否可以理解为,目前abc服务提供的接口使用的是claude模型名,但是接口协议使用的是 gpt的接口协议对吧,新版本中根据调用的模型名称来决定使用的接口协议,我们会尽快处理这个问题

Issues-translate-bot commented 7 months ago

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


get, can it be understood that the interface provided by the abc service currently uses the claude model name, but the interface protocol uses the gpt interface protocol, right? In the new version, the interface protocol used will be determined based on the called model name. We will Deal with this problem as soon as possible

Innocent-children commented 7 months ago

明白了,感谢解答

Issues-translate-bot commented 7 months ago

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


Got it, thanks for the answer

Dean-YZG commented 7 months ago

https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/pull/4480

WHUEugene commented 7 months ago

get,是否可以理解为,目前abc服务提供的接口使用的是claude模型名,但是接口协议使用的是 gpt的接口协议对吧,新版本中根据调用的模型名称来决定使用的接口协议,我们会尽快处理这个问题

如何退回到原来只使用openai协议方式调用?考虑到国内大部分使用中转api

Issues-translate-bot commented 7 months ago

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


get, can it be understood that the interface provided by the abc service currently uses the claude model name, but the interface protocol uses the gpt interface protocol, right? In the new version, the interface protocol used is determined based on the called model name. We This issue will be dealt with as soon as possible

How to return to the original method of calling only using the openai protocol? Considering that most of the domestic users use the transit API

Innocent-children commented 7 months ago

如果使用vercel部署的话,只需要在Deployments的那一页选择想要回退的版本,点击instant rollback即可

tkizm1 commented 7 months ago

能通过配置全局变量让claude只使用openai协议方式调用吗

Issues-translate-bot commented 7 months ago

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


Can claude be called only using the openai protocol by configuring global variables?

Innocent-children commented 7 months ago

能通过配置全局变量让claude只使用openai协议方式调用吗

我觉得这个想法不错,使用环境变量来配置

Issues-translate-bot commented 7 months ago

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


Can claude be called only using the openai protocol by configuring global variables?

I think this is a good idea, use environment variables to configure

oahcgnaw commented 6 months ago

自己找到了一种解决方式,可以参考下 https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/4492#issuecomment-2067972233

Innocent-children commented 6 months ago

自己找到了一种解决方式,可以参考下 #4492 (comment)

感谢大佬

Issues-translate-bot commented 6 months ago

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


I found a solution myself, you can refer to #4492 (comment)

Thanks boss

Innocent-children commented 6 months ago

自己找到了一种解决方式,可以参考下 #4492 (comment)

我参照 #4492 ,注释掉了代码中内置的Claude模型之后(constant.ts),就可以让Claude模型走openai代理 const anthropicModels = [ "claude-instant-1.2", "claude-2.0", "claude-2.1", // "claude-3-sonnet-20240229", // "claude-3-opus-20240229", // "claude-3-haiku-20240307", ];

Issues-translate-bot commented 6 months ago

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


I found a solution myself, you can refer to #4492 (comment)

I followed #4492 and commented out the built-in Claude model in the code (constant.ts), so that the Claude model can use the openai proxy. const anthropicModels = [ "claude-instant-1.2", "claude-2.0", "claude-2.1", // "claude-3-sonnet-20240229", // "claude-3-opus-20240229", // "claude-3-haiku-20240307", ];