feat(channels): IM 车道生成并写入真实 turn_id(user/assistant 成对 + 同源 WithTurnID;群聊隔离与静默语义不变)
This commit is contained in:
1 parent
ba1974038a
commit
8f6a75b7d7
9 files changed
+215
-21
No files matched your search
@@ -67,17 +67,21 @@ func (b *Bridge) notifyPersisted(msg history.Message) {
|
||||
// image 是这条消息携带的图片(data: URI 或 http(s) URL),写进 DTO 的 `image`
|
||||
// 字段(design/16 §4.4);没有图片时传 ""。它**不是** document 列的一部分:
|
||||
// 图片走视觉链路,文档走抽取,两者是两条路(design/24 §4.2 末的明确分野)。
|
||||
// turnID 是这条消息所属的那**一路** IM 回合的权威标识(design/15 §2.5.9),由
|
||||
// 驱动这次回合的桥接器生成(turnid.go):同一次入站回合的用户消息与助手回复传
|
||||
// **同一个**值,前端才能按 (sessionId, turnId) 两级分桶。不属于任何回合的消息
|
||||
// (主动推送等)传 "",那一列因此留空,行为与加入该列之前逐字相同。
|
||||
//
|
||||
// 它返回刚落库的完整消息(未装配历史存储、或写库失败时是零值),
|
||||
// 使调用方能在回合结束后按 id 把文档抽取结论补进同一列
|
||||
// (inbound_documents_persist.go 的两段式)。未装配历史存储时为空操作,
|
||||
// 因此桥接器在没有存储的情况下行为不变。
|
||||
func (b *Bridge) persistToMain(ctx context.Context, role, content, mood, document, image, platform, deviceID, adapterID string) history.Message {
|
||||
func (b *Bridge) persistToMain(ctx context.Context, role, content, mood, document, image, platform, deviceID, adapterID, turnID string) history.Message {
|
||||
if b.history == nil {
|
||||
return history.Message{}
|
||||
}
|
||||
full, err := b.history.AppendFull(ctx, history.Message{
|
||||
SessionID: history.MainSessionID, Role: role, Content: content, Mood: mood, Document: document, Image: image, Platform: platform, DeviceID: deviceID, AdapterID: adapterID, Mode: modeChat,
|
||||
SessionID: history.MainSessionID, Role: role, Content: content, Mood: mood, Document: document, Image: image, Platform: platform, DeviceID: deviceID, AdapterID: adapterID, Mode: modeChat, TurnID: turnID,
|
||||
})
|
||||
if err != nil {
|
||||
b.log.Warn("persist main session", "err", err, "role", role, "platform", platform, "device_id", deviceID, "adapter", adapterID)
|
||||
@@ -98,18 +102,19 @@ func (b *Bridge) persistToMain(ctx context.Context, role, content, mood, documen
|
||||
// 即可追加。document 是该消息携带的文档引用数组(design/24 §2.4),
|
||||
// 与 persistToMain 同一列、同一形状;没有附件时传 ""。image 是该消息携带的图片
|
||||
// (data: URI 或 http(s) URL),同样与 persistToMain 同一列(DTO 的 `image` 字段);
|
||||
// 没有图片时传 ""。
|
||||
// 没有图片时传 ""。turnID 与 persistToMain 同义:这次入站回合的权威标识,
|
||||
// 不属于任何回合(被静默登记的消息)时传 ""。
|
||||
//
|
||||
// 它返回刚落库的完整消息(未装配历史存储、或写库失败时是零值),
|
||||
// 供调用方在回合结束后补回文档抽取结论。未装配历史存储时为空操作,
|
||||
// 因此桥接器在没有存储的情况下行为不变。
|
||||
func (b *Bridge) persistIsolated(ctx context.Context, role, content, document, image, deviceID string, sess session.Session, platform, senderName, adapterID string) history.Message {
|
||||
func (b *Bridge) persistIsolated(ctx context.Context, role, content, document, image, deviceID string, sess session.Session, platform, senderName, adapterID, turnID string) history.Message {
|
||||
if b.history == nil {
|
||||
return history.Message{}
|
||||
}
|
||||
full, err := b.history.AppendFull(ctx, history.Message{
|
||||
SessionID: sess.SessionID, Role: role, Content: content, Document: document, Image: image, Platform: platform,
|
||||
DeviceID: deviceID, SenderName: senderName, AdapterID: adapterID, Mode: modeChat,
|
||||
DeviceID: deviceID, SenderName: senderName, AdapterID: adapterID, Mode: modeChat, TurnID: turnID,
|
||||
})
|
||||
if err != nil {
|
||||
b.log.Warn("persist isolated session", "err", err, "role", role,
|
||||
|
||||
Reference in new issue
Block a user