内容正在完善中,欢迎提交 PR
服务端
聊天

聊天

通过提问的方式,与 AI 进行互动。不同的模型有不同的回答。

话题

每个话题具有独立的上下文,您可以通过话题来切换上下文。

创建话题

在开始聊天之前,您需要创建并选择一个话题。

URL: POST /chat/topic

示例请求体:

{
  "name": "topic_1",
  "seriesId": 1
}

示例响应体:

{
  "id": 1,
  "userId": 1,
  "name": "topic_1",
  "seriesId": 1,
  "favorite": false,
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z"
}

获取话题列表

您可以查询之前创建过的话题列表。

URL: GET /chat/topic?seriesId=1

示例响应体

[
  {
    "id": 1,
    "userId": 1,
    "name": "topic_1",
    "seriesId": 1,
    "favorite": false,
    "createdAt": "2021-01-01T00:00:00.000Z",
    "updatedAt": "2021-01-01T00:00:00.000Z"
  },
  {
    "id": 2,
    "userId": 1,
    "name": "topic_2",
    "seriesId": 1,
    "favorite": false,
    "createdAt": "2021-01-01T00:00:00.000Z",
    "updatedAt": "2021-01-01T00:00:00.000Z"
  }
]

获取某个话题

您可以查询某个话题的详细信息。

URL: GET /chat/topic/:id

示例响应体:

{
  "id": 1,
  "userId": 1,
  "name": "topic_1",
  "seriesId": 1,
  "favorite": false,
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z"
}

更新某个话题

您可以更新某个话题的信息。

URL: PATCH /chat/topic/:id

示例请求体:

{
  "name": "topic_1",
  "favorite": true
}

示例响应体:

{
  "id": 1,
  "userId": 1,
  "name": "topic_1",
  "seriesId": 1,
  "favorite": false,
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z"
}

删除某个话题

您可以删除某个话题。

URL: DELETE /chat/topic/:id

示例响应体:

{
  "id": 1,
  "userId": 1,
  "name": "topic_1",
  "seriesId": 1,
  "favorite": false,
  "createdAt": "2021-01-01T00:00:00.000Z",
  "updatedAt": "2021-01-01T00:00:00.000Z"
}

消息

消息是您与 AI 交互的记录。

消息的类型有两种:

  • 用户消息:用户发送的消息

  • AI 消息:AI 回复的消息

发送消息

URL: POST /chat/topic/:topic_id/message

示例请求体:

{
  "seriesId": 1,
  "modelId": 1,
  "message": "你好",
  "enableMemory": true
}

示例响应体:

响应体为纯文本形式。

通过 ¦ 分隔符,将消息分为两部分:

  • 第一部分为 AI 回复的消息

  • 第二部分为消息的元数据,包含 userMsgIdassistantMsgIdtopicId 三个字段。

你好人类。¦{"userMsgId":12343,"assistantMsgId":12344,"topicId":430}

获取某个话题下的消息列表

URL: GET /chat/topic/:topic_id/message

示例请求体:

{
  "topicId": 1
}

示例响应体:

[
  {
    "id": 1,
    "userId": 1,
    "topicId": 430,
    "type": 0,
    "message": "你好。",
    "seriesId": 1,
    "images": [],
    "createdAt": "2023-04-03T06:07:55.371Z",
    "updatedAt": "2023-04-03T06:07:55.371Z"
  },
  {
    "id": 2,
    "userId": 1,
    "topicId": 430,
    "type": 1,
    "message": "您好,有什么可以需要帮助的吗?",
    "seriesId": 1,
    "images": [],
    "createdAt": "2023-04-03T06:07:55.371Z",
    "updatedAt": "2023-04-03T06:07:55.371Z"
  }
]

更新某个消息

URL: PATCH /chat/topic/:id/message/:messageId

示例请求体:

{
  "message": "你好"
}

示例响应体:

{
  "id": 1,
  "userId": 1,
  "topicId": 430,
  "type": 0,
  "message": "你好。",
  "seriesId": 1,
  "images": [],
  "createdAt": "2023-04-03T06:07:55.371Z",
  "updatedAt": "2023-04-03T06:07:55.371Z"
}

重新生成某个消息

URL: POST /chat/topic/:id/message/:messageId/regenerate

示例请求体:

{
  "seriesId": 1,
  "modelId": 1,
  "enableGoogleResults": true,
  "enableMemory": true
}

示例响应体:

响应体为纯文本形式。

通过 ¦ 分隔符,将消息分为两部分:

  • 第一部分为 AI 回复的消息

  • 第二部分为消息的元数据,包含 userMsgIdassistantMsgIdtopicId 三个字段。

你好人类。¦{"userMsgId":12343,"assistantMsgId":12344,"topicId":430}