mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
### What problem does this PR solve? - Tools management - Pregel engine wrapper for better usage - UT race - Coding style ### Type of change - [x] Refactoring
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package core
|
|
|
|
import "ragflow/internal/harness/core/schema"
|
|
|
|
// TypedReActAgentState is the exported state type for ReActAgent middlewares.
|
|
type TypedReActAgentState[M MessageType] struct {
|
|
Messages []M
|
|
ToolInfos []*schema.ToolInfo
|
|
DeferredToolInfos []*schema.ToolInfo
|
|
Extra map[string]any
|
|
RemainingIterations int
|
|
}
|
|
|
|
type ReActAgentState = TypedReActAgentState[*schema.Message]
|
|
|
|
func NewReActAgentState[M MessageType](msgs []M, tools []*schema.ToolInfo, maxIter int) *TypedReActAgentState[M] {
|
|
return &TypedReActAgentState[M]{
|
|
Messages: msgs, ToolInfos: tools,
|
|
RemainingIterations: maxIter, Extra: make(map[string]any),
|
|
}
|
|
}
|
|
|
|
// ReActAgentContext is passed to BeforeAgent middlewares.
|
|
type ReActAgentContext struct {
|
|
Instruction string
|
|
Tools []Tool
|
|
ReturnDirectly map[string]bool
|
|
ToolSearchTool *schema.ToolInfo
|
|
}
|
|
|
|
// ToolContext provides metadata about a tool being wrapped.
|
|
type ToolContext struct {
|
|
Name string
|
|
CallID string
|
|
}
|
|
|
|
// ToolCallsContext contains metadata about completed tool calls.
|
|
type ToolCallsContext struct {
|
|
ToolCalls []ToolContext
|
|
}
|