zmh-program / chatnio

🚀 Next Generation AI One-Stop Internationalization Solution. 🚀 下一代 AI 一站式 B/C 端解决方案,支持 OpenAI,Midjourney,Claude,讯飞星火,Stable Diffusion,DALL·E,ChatGLM,通义千问,腾讯混元,360 智脑,百川 AI,火山方舟,新必应,Gemini,Moonshot 等模型,支持对话分享,自定义预设,云端同步,模型市场,支持弹性计费和订阅计划模式,支持图片解析,支持联网搜索,支持模型缓存,丰富美观的后台管理与仪表盘数据统计。
https://chatnio.com
Apache License 2.0
4.17k stars 619 forks source link

对接部分中转 Anthropic 渠道的格式兼容性问题 #227

Closed bmwa0813 closed 1 month ago

bmwa0813 commented 3 months ago

目前“重新回答”会在现有回答的基础上生成一条新的回复,在使用claude模型时继续对话,会提示found multiple "assistant" roles in a row。

能否改变生成逻辑,用新回复替换原有回答

Issues-translate-bot commented 3 months ago

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


Title: About the "re-answer" function

Currently, "re-answer" will generate a new reply based on the existing answer. When using the claude model to continue the conversation, it will prompt found multiple "assistant" roles in a row.

Can you change the generation logic and replace the original answer with a new one?

zmh-program commented 3 months ago

这是 Anthropic 的限制导致的,我猜测您的Anthropic上游应该是以 OpenAI 格式接入的中转。 重新回答存储于后端,目前无法优化。

Chat Nio 的 Anthropic 类型渠道会处理此问题,将所有回答合并为 Anthropic 的可接纳格式。 但是如果您使用的是 OpenAI 格式的渠道(比如 One API/New API/Shell API类)接入将不会做任何处理,因为 OpenAI 官方 API 不会限制格式限制。 请您咨询您的上游提供 Anthropic 格式的接口或预先处理,或者使用 Anthropic 格式接入渠道,Chat Nio 无权对 OpenAI 格式的入参进行处理(因为这样会对原本正常的 OpenAI 渠道的所有模型造成 Prompt 窜意的问题)。

此错误并不是 Chat Nio 造成,同时也无法解决,请您咨询您的上游让其提供解决方案。

TIP: New API 最新版本使用 Anthropic 转 OpenAI 对接不会产生问题

Issues-translate-bot commented 3 months ago

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


The upstream is claude called through the openai format, which is currently the most widely used method. After all, projects such as oneapi are used for transfer. Many front-end projects such as lobechat will not have this problem when calling the same API. I wonder how they solved it. Is it not possible for chatnio?

bmwa0813 commented 3 months ago

能否判断并仅对OpenAI格式的Claude模型的回答进行处理,使其成为可被Claude模型接纳的格式。

ps:在这里交流一下对本项目的一些看法 作为商业版用户,选择本项目最核心原因是它可以为c端用户提供其他项目所不具备的功能,例如同时支持按次/量付费以及api。至于后台的渠道管理,只需要能保证各类模型可对接oneapi类项目即可。

但目前项目后台渠道管理页面是与oneapi类项目看齐的,需要根据不同厂商模型单独配置渠道,不能无脑对接oneapi,否则使用效果不理想(例如Claude、mj)。这对作为面向c端用户的项目来说,运营成本太高了。(即便是中转商也不能保证每个模型都使用的自建渠道,而非对接的经oneapi转发的上游)

本项目定义为“下一代 AI 一站式 B/C 端解决方案”,但目前提供api中转服务的oneapi类项目生态已很完善,中转供应商人手一个。因此建议,开发重点优先放到C端功能完善,以及对oneapi类项目的适配上。

由衷希望项目越做越好😘 @zmh-program

Issues-translate-bot commented 3 months ago

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


Is it possible to determine and process only the answers of the Claude model in the OpenAI format so that they become a format acceptable to the Claude model.

ps: Share some views on this project here As a commercial version user, the core reason for choosing this project is that it can provide C-side users with functions that other projects do not have, such as supporting pay-per-view/pay-per-volume and API at the same time. As for the backend channel management, it only needs to ensure that various models can be connected to oneapi projects.

However, the current project backend channel management page is in line with oneapi projects. Channels need to be configured separately according to different manufacturers' models. You cannot connect to oneapi without thinking, otherwise the use effect will not be ideal (such as Claude, mj). For a project targeting c-end users, the operating cost is too high. (Even the transit agent cannot guarantee that each model uses a self-built channel instead of the connected upstream forwarded by oneapi)

This project is defined as a "next-generation AI one-stop B/C solution", but currently the oneapi project ecology that provides api transfer services is already complete, and the transfer supplier has one at hand. Therefore, it is recommended that the development focus should be given to improving the C-side functions and adapting to oneapi projects.

I sincerely hope that the project will get better and better😘 @zmh-program

zmh-program commented 3 months ago

这其实是 One API 的设计不完善,并且 One 二开的开源的 New API 修复了此漏洞。如果 Chat Nio 考虑插手的话,因为 One API 是以 OpenAI 格式接入的,如果 chatnio 对 openai 格式进行处理,那么所有 openai 格式的渠道都会应用此规则,原本不是 claude 也会变成 claude 的 prompt 格式,或者有什么好的建议?

Issues-translate-bot commented 3 months ago

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


This is actually due to the imperfect design of One API, and the open source New API of One has fixed this vulnerability. If Chat Nio considers getting involved, because the One API is accessed in the OpenAI format, if chatnio processes the openai format, then all channels in the openai format will apply this rule, and the original ones that are not claude will also become claude's prompt format, or Any good suggestions?

zmh-program commented 3 months ago

因为 chatnio 不知道上游 one api 他接入的是不是 anthropic 渠道类型变成的 openai 格式,只能知道这只是一个 openai 类型的渠道。

Issues-translate-bot commented 3 months ago

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


Because chatnio doesn’t know whether the upstream one api is connected to the openai format from the anthropopic channel type, it can only know that this is just an openai type channel.

bmwa0813 commented 3 months ago

你没有好办法我就更不懂了,我只需要提问题,你要考虑的就多了,哈哈哈

Issues-translate-bot commented 3 months ago

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


If you don’t have a good solution, I don’t understand it even more. I just need to ask questions, and you have a lot to think about, hahaha.

zmh-program commented 3 months ago

或者 我可以在openai类型的渠道里加个【应用 Anthropic 中转格式兼容】 开启后所有带 claude的模型都会pre-format

Issues-translate-bot commented 3 months ago

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


Or I can add [application Anthropic transfer format compatible] to the openai type channel. After opening, all models with claude will be pre-format

bmwa0813 commented 3 months ago

可以解决问题就行诶

Issues-translate-bot commented 3 months ago

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


As long as it can solve the problem

zmh-program commented 3 months ago

同样也可以参考一下 #237 的方案,将上游换成one hub/new api/shell api, 现在只有one api有这个bug

AnnaStreeter commented 1 month ago

此为上游问题,可以加钱对您特殊的上游渠道做单独处理。

Issues-translate-bot commented 1 month ago

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


This is an upstream issue, and you can add money to handle your special upstream channel individually.