feat(pipeline): inject QuotedContext at LLM prompt stage
This commit is contained in:
@@ -92,6 +92,9 @@ func (p *PluginIntoChatMessage) OnEvent(ctx context.Context,
|
||||
if chatManage.ImageDescription != "" && !chatManage.ChatModelSupportsVision {
|
||||
userContent += "\n\n[用户上传图片内容]\n" + chatManage.ImageDescription
|
||||
}
|
||||
if chatManage.QuotedContext != "" {
|
||||
userContent += "\n\n" + chatManage.QuotedContext
|
||||
}
|
||||
|
||||
if tpl := chatManage.SummaryConfig.ContextTemplate; tpl != "" {
|
||||
chatManage.UserContent = types.RenderPromptPlaceholders(tpl, types.PlaceholderValues{
|
||||
@@ -174,6 +177,9 @@ func (p *PluginIntoChatMessage) OnEvent(ctx context.Context,
|
||||
if chatManage.ImageDescription != "" && !chatManage.ChatModelSupportsVision {
|
||||
userContent += "\n\n[用户上传图片内容]\n" + chatManage.ImageDescription
|
||||
}
|
||||
if chatManage.QuotedContext != "" {
|
||||
userContent += "\n\n" + chatManage.QuotedContext
|
||||
}
|
||||
|
||||
// Set formatted content back to chat management
|
||||
chatManage.UserContent = userContent
|
||||
|
||||
@@ -174,6 +174,9 @@ func (s *sessionService) AgentQA(
|
||||
agentQuery = req.Query + "\n\n[用户上传图片内容]\n" + req.ImageDescription
|
||||
logger.Infof(ctx, "Agent model does not support vision, appending image description (%d chars)", len(req.ImageDescription))
|
||||
}
|
||||
if req.QuotedContext != "" {
|
||||
agentQuery += "\n\n" + req.QuotedContext
|
||||
}
|
||||
|
||||
// Execute agent with streaming (asynchronously)
|
||||
// Events will be emitted to EventBus and handled by the Handler layer
|
||||
|
||||
@@ -126,6 +126,7 @@ func (s *sessionService) KnowledgeQA(
|
||||
PipelineState: types.PipelineState{
|
||||
RewriteQuery: req.Query,
|
||||
ImageDescription: req.ImageDescription,
|
||||
QuotedContext: req.QuotedContext,
|
||||
},
|
||||
PipelineContext: types.PipelineContext{
|
||||
EventBus: eventBus.AsEventBusInterface(),
|
||||
@@ -150,6 +151,9 @@ func (s *sessionService) KnowledgeQA(
|
||||
if req.ImageDescription != "" && !chatModelSupportsVision {
|
||||
userContent += "\n\n[用户上传图片内容]\n" + req.ImageDescription
|
||||
}
|
||||
if req.QuotedContext != "" {
|
||||
userContent += "\n\n" + req.QuotedContext
|
||||
}
|
||||
chatManage.UserContent = userContent
|
||||
|
||||
pipeline = types.NewPipelineBuilder().
|
||||
@@ -732,6 +736,9 @@ func (s *sessionService) renderFallbackPrompt(ctx context.Context, chatManage *t
|
||||
if chatManage.ImageDescription != "" && !chatManage.ChatModelSupportsVision {
|
||||
result += "\n\n[用户上传图片内容]\n" + chatManage.ImageDescription
|
||||
}
|
||||
if chatManage.QuotedContext != "" {
|
||||
result += "\n\n" + chatManage.QuotedContext
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user