Documentation
¶
Overview ¶
Package agentic 提供代理式检索增强生成 (Agentic RAG) 实现
Agentic RAG 通过智能代理进行多步推理和检索:
- 分析查询,生成检索计划
- 执行多步检索和推理
- 动态调整计划
- 支持多个检索源
使用示例:
arag := agentic.New(
llmProvider,
agentic.WithRetriever("knowledge", knowledgeRetriever),
agentic.WithRetriever("web", webRetriever),
agentic.WithMaxSteps(5),
)
response, err := arag.Query(ctx, "复杂问题")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgenticRAG ¶
type AgenticRAG struct {
// contains filtered or unexported fields
}
AgenticRAG 代理式检索增强生成
工作流程:
- 分析查询,生成检索计划
- 执行计划中的每个步骤
- 根据步骤结果动态调整
- 综合所有结果生成回答
type Option ¶
type Option func(*AgenticRAG)
Option AgenticRAG 配置选项
func WithRetriever ¶
WithRetriever 添加检索器
type Plan ¶
type Plan struct {
// Query 原始查询
Query string `json:"query"`
// Steps 计划步骤
Steps []Step `json:"steps"`
// Analysis 查询分析
Analysis string `json:"analysis,omitempty"`
}
Plan 执行计划
type Response ¶
type Response struct {
// Content 生成的回答
Content string `json:"content"`
// Sources 使用的来源文档
Sources []rag.Document `json:"sources,omitempty"`
// ExecutedSteps 执行的步骤
ExecutedSteps []Step `json:"executed_steps"`
// TotalSteps 总步骤数
TotalSteps int `json:"total_steps"`
}
Response Agentic RAG 的响应
type Step ¶
type Step struct {
// Type 步骤类型
Type StepType `json:"type"`
// Query 检索查询(对于检索步骤)
Query string `json:"query,omitempty"`
// Source 检索源(对于检索步骤)
Source string `json:"source,omitempty"`
// Reasoning 推理内容(对于推理步骤)
Reasoning string `json:"reasoning,omitempty"`
// Results 步骤结果
Results []rag.Document `json:"results,omitempty"`
// Conclusion 步骤结论
Conclusion string `json:"conclusion,omitempty"`
}
Step 执行步骤
Click to show internal directories.
Click to hide internal directories.