历史记录
本文档旨在为您的 AI+搜索的历史记录功能提供详细的 API 说明
API 说明
本节详细描述了用于管理和访问聊天历史记录的 API 接口,包括请求方法、URL、参数、响应格式及示例。
获取所有聊天记录
描述
获取所有用户的聊天记录列表,每条记录包含聊天的基本信息。
请求
- 方法:
GET
- URL:
http://192.168.3.9:3001/api/chats
请求参数
无。
响应
状态码: 200 OK
内容类型: application/json
响应体示例:
{
"chats": [
{
"id": "5a31859e83d0e45b6c5ba063091ff9403ed9eb3b",
"title": "when is the first day of Kapiolani cummunity college",
"createdAt": "Sat Dec 07 2024 09:35:59 GMT+0000 (Coordinated Universal Time)",
"focusMode": "webSearch",
"files": []
},
{
"id": "041cd5f3fdef4fda1a0fa2a45564e3c22ce2fd9a",
"title": "when is first day of kapiaoni community college",
"createdAt": "Sat Dec 07 2024 09:21:12 GMT+0000 (Coordinated Universal Time)",
"focusMode": "webSearch",
"files": []
}
]
}
字段说明
- chats: 聊天记录数组。
- id: 聊天的唯一标识符。
- title: 聊天标题,通常为用户的初始问题。
- createdAt: 聊天创建时间,格式为 UTC 时间字符串。
- focusMode: 聊天的焦点模式,例如
webSearch
。 - files: 相关文件数组,当前为空。
获取特定聊天记录详情
描述
获取指定聊天记录的详细信息,包括聊天基本信息和相关的消息内容。
请求
方法:
GET
URL:
http://192.168.3.9:3001/api/chats/{chat_id}
- {chat_id}: 要获取详情的聊天记录的唯一标识符。
请求参数
无。
响应
状态码: 200 OK
内容类型: application/json
响应体示例:
{
"chat": {
"id": "5a31859e83d0e45b6c5ba063091ff9403ed9eb3b",
"title": "when is the first day of Kapiolani cummunity college",
"createdAt": "Sat Dec 07 2024 09:35:59 GMT+0000 (Coordinated Universal Time)",
"focusMode": "webSearch",
"files": []
},
"messages": [
{
"id": 3,
"content": "when is the first day of Kapiolani cummunity college",
"chatId": "5a31859e83d0e45b6c5ba063091ff9403ed9eb3b",
"messageId": "5b61edf4bc179e",
"role": "user",
"metadata": "{\"createdAt\":\"2024-12-07T09:35:59.119Z\"}"
},
{
"id": 4,
"content": "The first day of Kapiʻolani Community College for the current academic year is September 2[9]. This date marks the beginning of the instructional period at the college. It's important to note that a late registration fee of $30.00 is charged for new registrations on or after the first day of instruction[11]. Additionally, tuition payment is typically due by 4:00 pm on the day of registration to ensure enrollment in classes[11].",
"chatId": "5a31859e83d0e45b6c5ba063091ff9403ed9eb3b",
"messageId": "32fcbbf251337c",
"role": "assistant",
"metadata": "{\"createdAt\":\"2024-12-07T09:36:04.371Z\",\"sources\":[{\"pageContent\":\"Last day to register, add, or change full-semester class sections. Last day to withdraw from full-semester classes with 100% tuition refund* online at www.star.hawaii.edu *Note: Full refund of student/program fees are given for complete withdrawal from all classes in the UH System before instruction begins or within the 100% refund period.\",\"metadata\":{\"title\":\"Academic Calendar | Kapi'olani Community College\",\"url\":\"https://www.kapiolani.hawaii.edu/classes/academic-calendar/\"}}, {\"pageContent\":\"First Time Students; Transfer Students; International (F-1 Visa) ... Online PDF Version of the Kapi‘olani Community College General Catalog ... Classes . Other Useful Dates. 2024 Holidays. Jan 15 – Dr. Martin Luther King, Jr. Day Feb 19 – Presidents' Day Mar 18-22 – Spring Recess Mar 26 – Prince Kūhiō Day Mar 29 – Good Friday\",\"metadata\":{\"title\":\"Classes | Kapi'olani Community College\",\"url\":\"https://www.kapiolani.hawaii.edu/classes/\"}}, // 其他资源数据省略]} }"
}
]
}
字段说明
chat: 聊天基本信息。
- id: 聊天的唯一标识符。
- title: 聊天标题,通常为用户的初始问题。
- createdAt: 聊天创建时间,格式为 UTC 时间字符串。
- focusMode: 聊天的焦点模式,例如
webSearch
。 - files: 相关文件数组,当前为空。
messages: 聊天消息数组。
- id: 消息的唯一标识符(数据库中的自增 ID)。
- content: 消息内容。
- chatId: 关联的聊天记录 ID。
- messageId: 消息的唯一标识符(UUID)。
- role: 消息角色,可能的值包括
user
和assistant
。 - metadata: 额外的元数据信息,存储为 JSON 字符串。包括创建时间和来源信息等。