Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 适配 XML 格式下含消息元素消息的发送 #89

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[fix] XML 格式下 finalReply 可能为数组
HydroGest committed Jan 26, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit e2b6e6ac2a185c1365be4e7f257f621791bc49ad
2 changes: 1 addition & 1 deletion packages/core/src/bot.ts
Original file line number Diff line number Diff line change
@@ -270,7 +270,7 @@ export class Bot {
} else if (LLMResponse.status === "function") {
return this.handleFunctionCalls(LLMResponse.functions, debug);
} else {
const reason = `Status 不是一个有效值: ${LLMResponse.status}`;
const reason = `status 不是一个有效值: ${LLMResponse.status}`;
return {
status: "fail",
raw: content,
5 changes: 5 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -324,6 +324,11 @@ ${toolsToString(functions)}
let { replyTo, finalReply, nextTriggerCount, logic, functions } = chatResponse as SuccessResponse;

if (isEmpty(replyTo)) replyTo = session.channelId;

finalReply = Array.isArray(finalReply)
? finalReply.join('') // 如果是数组,拼接成字符串。场景: 当使用 XML 格式时,此处中可能包含 <at/>、<quote> 等无法被正确解析成字符串。
: finalReply; // 如果是字符串,直接使用


sendQueue.setTriggerCount(channelId, nextTriggerCount);
template = `