feat(chat): implement orphan alias detection and logging in chat completion and streaming
Add functionality to detect unresolvable resource aliases emitted by the model during chat completion and streaming. Introduce logging for these orphan aliases to aid in debugging and improve the handling of resource references. Update the stream processing to ensure held aliases are flushed upon cancellation, preventing data loss. Include tests to verify the correct reporting of orphan aliases.
This commit is contained in:
@@ -68,6 +68,12 @@ func (p *PluginChatCompletion) OnEvent(
|
||||
return ErrModelCall.WithError(err)
|
||||
}
|
||||
resourceRefs.DecodeResponse(chatResponse)
|
||||
if orphans := resourceRefs.OrphanAliases(chatResponse.Content); len(orphans) > 0 {
|
||||
pipelineWarn(ctx, "Completion", "orphan_resource_aliases", map[string]interface{}{
|
||||
"session_id": chatManage.SessionID,
|
||||
"aliases": orphans,
|
||||
})
|
||||
}
|
||||
|
||||
pipelineInfo(ctx, "Completion", "output", map[string]interface{}{
|
||||
"answer_preview": chatResponse.Content,
|
||||
|
||||
Reference in New Issue
Block a user