|
@@ -153,18 +153,14 @@ export default [
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // AI 对话接口 (SSE 流式输出)
|
|
|
|
|
|
|
+ // AI 对话接口 (SSE 流式输出) - 支持 GET/POST
|
|
|
{
|
|
{
|
|
|
url: "/api/upms/ai/chat",
|
|
url: "/api/upms/ai/chat",
|
|
|
- method: "post",
|
|
|
|
|
|
|
+ method: "get",
|
|
|
rawResponse: async (req, res) => {
|
|
rawResponse: async (req, res) => {
|
|
|
- const body = await new Promise<string>((resolve) => {
|
|
|
|
|
- let data = '';
|
|
|
|
|
- req.on('data', (chunk) => data += chunk);
|
|
|
|
|
- req.on('end', () => resolve(data));
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- const { question } = JSON.parse(body);
|
|
|
|
|
|
|
+ // 从 query 参数获取问题
|
|
|
|
|
+ const url = new URL(req.url || '', `http://${req.headers.host}`);
|
|
|
|
|
+ const question = url.searchParams.get('question') || '';
|
|
|
|
|
|
|
|
// AI 回复知识库
|
|
// AI 回复知识库
|
|
|
const knowledgeBase: Record<string, string> = {
|
|
const knowledgeBase: Record<string, string> = {
|