现象
使用FastGPT 4.9.2版本,通过Docker私有化部署时,按照官方文档调用历史记录相关API,会返回HTTP 404错误。涉及的接口包括获取历史记录、删除历史记录、更新历史标题、清空历史记录四类,文档中给出的接口路径均包含/history层级,但实际可用的接口路径无此层级。
可能原因
官方文档中的历史记录API路径多了/history路由层级,与实际部署的API路由规则不一致,导致请求路径无法匹配到正确的接口,最终返回404错误。
排查步骤
- 确认当前使用的FastGPT版本为4.9.2;
- 对比官方文档中给出的API路径与实际调用时返回404的请求路径,例如文档中
/api/core/chat/history/getHistories与实际可用的/api/core/chat/getHistories的差异; - 测试移除/history层级后的路径,验证是否可以正常返回200状态码。
解决与验证
- 找到FastGPT项目中的
docs/openapi/chat.mdx文件; - 移除该文件中四个历史记录API路径的/history部分,具体修改如下:
- 将http://localhost:3000/api/core/chat/history/getHistories修改为http://localhost:3000/api/core/chat/getHistories
- 将http://localhost:3000/api/core/chat/history/delHistory修改为http://localhost:3000/api/core/chat/delHistory
- 将http://localhost:3000/api/core/chat/history/updateHistory修改为http://localhost:3000/api/core/chat/updateHistory
- 将http://localhost:3000/api/core/chat/history/clearHistories修改为http://localhost:3000/api/core/chat/clearHistories
- 修改完成后,重新调用修改后的API路径,验证返回状态码为200即可。
来源:https://github.com/labring/FastGPT/issues/6341