-
Notifications
You must be signed in to change notification settings - Fork 527
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: support claude ai model #969
Conversation
此外,请解决冲突并同步更新 README.md。 |
Anthropic Claude AI 的 API 模型和 OpenAI 的好像不太一样。请确认能否适配。 |
@CH3CHO
2.处理 Claude 的响应格式,保持和 OpenAI 输出一样的格式和字段,例如: {
"id": "cmpl-e5ca873642ca4f5d8b178c1742f9a8e8",
"object": "chat.completion",
"created": 1872961,
"model": "moonshot-v1-128k",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "文案内容是关于一个名为“xxxx”的支付平台..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 11,
"completion_tokens": 498,
"total_tokens": 509
}
} |
我这边开发百度文心一言的时候,是参考的这个项目,有需要的话也可以参考下,https://github.com/songquanpeng/one-api/tree/91b80ae87945ed1a77b3507dd277ee9cdddaa0b4/relay/adaptor |
@hanxiantao 感谢,我研究一下 |
Signed-off-by: chengzw <[email protected]>
@CH3CHO PR 已经根据重新要求调整好了,请继续 review。测试的内容我更新在 PR 的描述里了 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #969 +/- ##
==========================================
- Coverage 35.97% 35.93% -0.04%
==========================================
Files 69 69
Lines 11514 11536 +22
==========================================
+ Hits 4142 4146 +4
- Misses 7056 7074 +18
Partials 316 316 |
使用 OpenAI 非流式请求协议的相应格式是不是有点问题?看上去前面都没有 data: 前缀。 能参考下面两篇文档的内容用 NextChat 或者 LobeChat 测一下对接情况吗? |
| `version` | string | 必填 | - | Claude 服务的 API 版本 | | ||
| 名称 | 数据类型 | 填写要求 | 默认值 | 描述 | | ||
|-----------|--------|------|-----|----------------------------------| | ||
| `version` | string | 可选 | - | Claude 服务的 API 版本,默认为 2023-06-01 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个字段建议在命名里就说明是 Anthropic Claude 用的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改成 claudeVersion
@CH3CHO 修改后的流式响应如下: curl "http://localhost:10000/v1/chat/completions" -H "Content-Type: application/json" -d '{
"model": "gpt-3",
"messages": [
{
"role": "user",
"content": "你好,你是谁?"
}
],
"stream": true
}'
data: {"id":"msg_01CXXy31FcARBcbTeKG6RagV","choices":[{"index":0,"delta":{"role":"assistant"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"你"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"好"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"很"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"高"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"兴"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"认"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"识"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"你"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"!"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"是"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"一"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"款"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"由"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"人"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"工"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"智"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"能"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"公"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"司"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"Anthrop"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"ic"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"开"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"发"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"的"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"对"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"话"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"式"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"AI"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"助"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"手"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"的"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"名"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"字"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"是"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"Claude"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"是"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"一"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"个"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"虚"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"构"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"的"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"人"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"名"}}],"created":1718463889,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"擅"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"长"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"回"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"答"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"各"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"种"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"问"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"题"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"并"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"且"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"可"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"以"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"协"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"助"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"完"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"成"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"诸"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"如"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"写"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"作"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"、"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"编"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"程"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"、"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"分"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"析"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"等"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"多"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"种"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"任"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"务"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"会"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"尽"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"最"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"大"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"努"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"力"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"提"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"供"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"有"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"用"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"和"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"准"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"确"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"的"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"信"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"息"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"但"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"作"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"为"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"AI"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"系"}}],"created":1718463890,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"统"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"也"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"有"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"一"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"些"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"局"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"限"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"性"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"很"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"乐"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"意"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"与"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"你"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"交"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"流"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"但"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"也"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"希"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"望"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"能"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"明"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"确"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"们"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"之"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"间"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"是"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"AI"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"与"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"人"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"类"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"的"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"关"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"系"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"而"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"不"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"是"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"朋"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"友"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"如"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"果"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"你"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"有"}}],"created":1718463891,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"任"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"何"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"疑"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"问"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"或"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"需"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"要"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"帮"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"助"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"欢"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"迎"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"随"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"时"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"告"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"诉"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"我"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{"content":"。"}}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
data: {"choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"created":1718463892,"model":"claude-3-sonnet-20240229","object":"chat.completion.chunk","usage":{}}
|
Ⅰ. Describe what this PR did
Support calude ai model. Claude API documentation: https://docs.anthropic.com/en/api/messages
Ⅱ. Does this pull request fix one issue?
fixes #946
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
docker-compose.yaml
envoy.yaml
使用 OpenAI 协议
非流式请求
流式请求
stop
stop 接受一个 string 数组,当生成的内容遇到该词时,停止生成。(在 claude 中是 stop_sequence)
使用 Claude 协议
Claude Streaming 文档:https://docs.anthropic.com/en/api/messages-streaming#streaming-with-sdks
非流式请求
流式请求
stop_sequence
Ⅴ. Special notes for reviews