该文档介绍如何测试你的接口是否符合第三方大模型接口标准。你可以使用该工具测试你的接口是否符合要求,如果符合要求,则可以返回预期的输出结果。否则将返回异常信息。
下载资源包。
进入资源包所在目录。
执行验证命令。
命令格式为:./app-mac <llmAPIUrl> <llmModel> <llmAPIKey> <LLMQuestion>
。
< > 中为你要填入的真实数据。例如:./app-mac
https://api.cn/v1/chat/completion model-v1-chat sk-0aeQbtlX2reL 你好
。
参数名 | 类型 | 是否必填 | 示例 | 描述 |
---|---|---|---|---|
llmAPIUrl | String | 是 |
| 大模型请求 URL。 |
llmModel | String | 否 | model-v1-chat | 大模型模型名称。默认值为空。 |
llmAPIKey | String | 否 |
| 鉴权 APIKey。默认值为空。 |
LLMQuestion | String | 否 | 你好 | 对话问题。 |
openAI:
自定义URL:
接口返回支持SSE。
POST
Content-Type Application/json
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
messages | Object of messages | 是 | 参考StartVoiceChat.HistoryLength ,包含最近 HistoryLength 轮对话内容。当前 ASR 内容在数组末位。 |
stream | bool | 否 | 填入值:true |
temperature | float | 否 | 透传 |
maxTokens | int | 否 | 透传 |
model | string | 是 | 透传 StartVoiceChat.LLMConfig.ModelName |
top_p | string[] | 否 | 透传 |
messages
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
role | string | 是 | 取值:
|
content | string | 否 | 内容 |
Content-Type text/event-stream
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
id | string | 是 | 请求 UUID,不同请求的 ID 需不同,但同一个流式请求的 ID 需相同。 |
choices | Object of choices | 是 | 流式回复对象 |
created | int | 是 | UnixTime 时间戳,精确到秒。同一个请求的流式所有块拥有相同的时间戳。 |
usage | object of usage | 否 | 最后一个包可带此参数 |
object | string | 是 | 填入值:chat.completion.chunk 。填错将导致接口行为异常。 |
Choices
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
finish_resaon | string | 是 |
|
delta | Object of delta | 是 | 流式片段对象 |
model | string | 是 | 模型 ID |
stream_options | object | 是 | 流接口选项 |
delta
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
content | string | 是 | 内容 |
role | string | 是 | 取值:
|
index | int | 是 | 数组中位置,从 0 开始 |
usage
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
completion_tokens | int | 是 | generated tokens 长度 |
prompt_tokens | int | 是 | prompt tokens 长度 |
total_tokens | int | 是 | prompt+generated tokens 长度 |
请求样例
curl -v --location 'https://rtc-cloud-rendering.byted.org/voicechat/test-sse' \ --header 'Content-Type: application/json' \ --data '{ "messages":[{ "role":"user", "content":"今天适合干什么?" }], "stream": true, "temperature": 0.1, "max_tokens": 100, "top_p": 0.9, "model": "doubao-32k", "stream_options": {"include_usage":true} }' > POST /voicechat/test-sse HTTP/1.1 > Host: rtc-cloud-rendering.byted.org > User-Agent: curl/8.4.0 > Accept: */* > Content-Type: application/json > Content-Length: 254 > < HTTP/1.1 200 OK < Date: Thu, 15 Aug 2024 09:36:02 GMT < Content-Type: text/event-stream < Transfer-Encoding: chunked < Connection: keep-alive < Access-Control-Allow-Origin: * < Cache-Control: no-cache data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Role":"assistant"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":1,"delta":{"Content":"天"}},{"finish_reason":null,"index":0,"delta":{"Content":"从明"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"起,"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":1,"delta":{"Content":"幸福"}},{"finish_reason":null,"index":0,"delta":{"Content":"做一个"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"的"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"人"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"。"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"喂马,"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"劈柴,"}},{"finish_reason":null,"index":1,"delta":{"Content":"周游"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":null,"index":0,"delta":{"Content":"世界"}},{"finish_reason":null,"index":1,"delta":{"Content":"。"}}],"model":"doubao-32k-2024-07-25","created":1723714562} data: {"id":"c99d67a4-5ae9-11ef-bdf5-b8cef6dcdbe2","object":"chat.completion.chunk","choices":[{"finish_reason":"stop","index":0,"delta":{}}],"model":"doubao-32k-2024-07-25","created":1723714562,"usage":{"prompt_tokens":1,"completion_tokens":2,"total_tokens":3}} data: [DONE]
Content-Type Application/json
请求终止,报错返回。RTC 不做任何处理,仅报错。
参数 | 类型 | 必填 | 描述 |
---|---|---|---|
Error | object | 是 | 错误 |
Code | string | 是 | 错误码 |
Message | string | 是 | 错误原因 |
Application/json
不处理,直接报错返回 StatusCode。RTC 不做任何处理,仅报错。