mirror of
https://github.com/idootop/mi-gpt.git
synced 2025-04-13 19:58:04 +00:00
fix: 去除掉ai返回内容中的代码块样式
This commit is contained in:
parent
2f53d99359
commit
c985e5b08f
|
@ -67,6 +67,10 @@ export class LongTermMemoryAgent {
|
|||
shortTermMemory: lastOf(newMemories)!.text,
|
||||
}),
|
||||
});
|
||||
// 如果返回内容是个markdown代码块,就让他变回普通json
|
||||
res?.content?.trim();
|
||||
if (res?.content?.startsWith("```json")) {res.content = res?.content?.replace("```json", "");}
|
||||
if (res?.content?.endsWith("```")) {res.content = res?.content?.replace("```", "");}
|
||||
return jsonDecode(res?.content)?.longTermMemories?.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,10 @@ export class ShortTermMemoryAgent {
|
|||
.join("\n"),
|
||||
}),
|
||||
});
|
||||
// 如果返回内容是个markdown代码块,就让他变回普通json
|
||||
res?.content?.trim();
|
||||
if (res?.content?.startsWith("```json")) {res.content = res?.content?.replace("```json", "");}
|
||||
if (res?.content?.endsWith("```")) {res.content = res?.content?.replace("```", "");}
|
||||
return jsonDecode(res?.content)?.shortTermMemories?.toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user