111 lines
4.1 KiB
YAML
111 lines
4.1 KiB
YAML
openapi: 3.0.1
|
||
info:
|
||
title: ''
|
||
version: 1.0.0
|
||
paths:
|
||
/agent/chat:
|
||
post:
|
||
summary: AI Agent&聊天
|
||
deprecated: false
|
||
description: >-
|
||
本接口既支持带着消息新建对话,也支持通过旧对话继续聊天。
|
||
在 JSON 中传入 conversation_id,后端查库:存在则延续,不存在则创建新对话后再聊天。
|
||
|
||
流式响应采用 OpenAI/DeepSeek 兼容格式:
|
||
- 思考流:choices[0].delta.reasoning_content
|
||
- 正文流:choices[0].delta.content
|
||
- 结束标记:data: [DONE]
|
||
tags:
|
||
- Agent模块
|
||
parameters:
|
||
- name: Authorization
|
||
in: header
|
||
description: token
|
||
required: false
|
||
example: ''
|
||
schema:
|
||
type: string
|
||
- name: Content-Type
|
||
in: header
|
||
description: ''
|
||
required: false
|
||
example:
|
||
- application/json
|
||
schema:
|
||
type: array
|
||
items:
|
||
type: string
|
||
requestBody:
|
||
required: true
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: object
|
||
properties:
|
||
conversation_id:
|
||
type: string
|
||
description: 可选。不传时后端自动生成,并通过 X-Conversation-ID 响应头返回。
|
||
x-apifox-mock: '{{$string.uuid}}'
|
||
message:
|
||
type: string
|
||
description: 用户输入内容
|
||
model:
|
||
type: string
|
||
description: 可选,worker 或 strategist(默认 worker)
|
||
thinking:
|
||
type: boolean
|
||
description: 是否开启深度思考
|
||
required:
|
||
- message
|
||
- thinking
|
||
x-apifox-orders:
|
||
- conversation_id
|
||
- message
|
||
- model
|
||
- thinking
|
||
example:
|
||
conversation_id: 0b6eac35-ccaa-46d1-aa58-d33bc2cd48aa
|
||
message: 提醒我有空的时候给自己挑一件新衣服
|
||
model: worker
|
||
thinking: true
|
||
responses:
|
||
'200':
|
||
description: ''
|
||
content:
|
||
text/event-stream:
|
||
schema:
|
||
type: string
|
||
description: >-
|
||
每条 SSE 事件都是 `data: {JSON}`,最终以 `data: [DONE]` 结束。
|
||
Apifox 可按 OpenAI 兼容格式自动合并,并区分 reasoning_content 与 content。
|
||
example: |-
|
||
data: {"id":"chatcmpl-3f3ee5d6-8c4f-4b5b-a2a8-7f5b9bde8b9d","object":"chat.completion.chunk","created":1740637581,"model":"worker","choices":[{"index":0,"delta":{"role":"assistant","reasoning_content":"先分析一下你的需求。"},"finish_reason":null}]}
|
||
|
||
data: {"id":"chatcmpl-3f3ee5d6-8c4f-4b5b-a2a8-7f5b9bde8b9d","object":"chat.completion.chunk","created":1740637581,"model":"worker","choices":[{"index":0,"delta":{"reasoning_content":"你提到的是空闲时提醒。"},"finish_reason":null}]}
|
||
|
||
data: {"id":"chatcmpl-3f3ee5d6-8c4f-4b5b-a2a8-7f5b9bde8b9d","object":"chat.completion.chunk","created":1740637581,"model":"worker","choices":[{"index":0,"delta":{"content":"可以,我会在你有空时提醒你。"},"finish_reason":null}]}
|
||
|
||
data: {"id":"chatcmpl-3f3ee5d6-8c4f-4b5b-a2a8-7f5b9bde8b9d","object":"chat.completion.chunk","created":1740637581,"model":"worker","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
|
||
|
||
data: [DONE]
|
||
headers:
|
||
X-Conversation-ID:
|
||
example: 0b6eac35-ccaa-46d1-aa58-d33bc2cd48aa
|
||
required: false
|
||
description: 生效的会话 ID,用于后续续聊
|
||
schema:
|
||
type: string
|
||
x-apifox-name: 成功
|
||
x-apifox-ordering: 0
|
||
security: []
|
||
x-apifox-folder: Agent模块
|
||
x-apifox-status: developing
|
||
components:
|
||
schemas: {}
|
||
responses: {}
|
||
securitySchemes: {}
|
||
servers:
|
||
- url: http://127.0.0.1:8080/api/v1
|
||
description: 开发环境
|
||
security: []
|