feat(resource): add stable resource registry with LLM-context alias compaction
Introduce resource://<handle> as the stable application identity for stored objects, decoupling API responses, persisted rich text, and LLM prompts from physical storage paths. Adds a resource catalog service (register/resolve/bind, revocable expiring access grants), a request-local alias registry that compacts resource references while in the LLM context and restores them (including across streaming chunks), plus router, IM, chat-pipeline, and multimodal integration. Includes schema migrations (resources, resource_bindings, resource_access_grants) for sqlite, and hardens URL/output security handling.
This commit is contained in:
@@ -3,6 +3,7 @@ package chatpipeline
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/llmresource"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/Tencent/WeKnora/internal/types/interfaces"
|
||||
)
|
||||
@@ -51,6 +52,8 @@ func (p *PluginChatCompletion) OnEvent(
|
||||
"message_count": len(chatManage.History) + 2,
|
||||
})
|
||||
chatMessages := prepareMessagesWithHistory(chatManage)
|
||||
resourceRefs := llmresource.NewRegistry()
|
||||
chatMessages = resourceRefs.EncodeMessages(chatMessages)
|
||||
|
||||
// Call the chat model to generate response
|
||||
pipelineInfo(ctx, "Completion", "model_call", map[string]interface{}{
|
||||
@@ -64,6 +67,7 @@ func (p *PluginChatCompletion) OnEvent(
|
||||
})
|
||||
return ErrModelCall.WithError(err)
|
||||
}
|
||||
resourceRefs.DecodeResponse(chatResponse)
|
||||
|
||||
pipelineInfo(ctx, "Completion", "output", map[string]interface{}{
|
||||
"answer_preview": chatResponse.Content,
|
||||
|
||||
Reference in New Issue
Block a user