refactor: replace image sub-agent with direct tool calling
This commit is contained in:
1 parent
975352c7d6
commit
fd3dcbe104
11 files changed
+108
-180
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"example.com/ueino/adk/internal/config"
|
||||
"example.com/ueino/internal/opt"
|
||||
"example.com/ueino/pkg/memory"
|
||||
"example.com/ueino/pkg/provider"
|
||||
"example.com/ueino/pkg/tool"
|
||||
|
||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
)
|
||||
|
||||
const mainAgentName = "terminal_chat"
|
||||
const imageAgentName = "image_creator"
|
||||
|
||||
// Agent 管理主助手的执行和会话历史。
|
||||
type Agent struct {
|
||||
@@ -37,18 +37,15 @@ func New(ctx context.Context, cfg config.Config) (*Agent, error) {
|
||||
instruction := opt.SYSTEM_PROMPT
|
||||
|
||||
if cfg.Image.Model != "" {
|
||||
imageAgent, err := newImageAgent(ctx, cfg, chat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tools = append(tools, adk.NewAgentTool(ctx, imageAgent))
|
||||
instruction += imageDelegationPrompt
|
||||
image := provider.NewImage(cfg.Image.BaseURL, cfg.Image.Model, cfg.Image.APIKey, cfg.Image.OutputDir)
|
||||
tools = append(tools, &confirmedImage{InvokableTool: tool.NewImage(image)})
|
||||
instruction += imagePrompt
|
||||
}
|
||||
|
||||
mainAgent, err := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
|
||||
Name: mainAgentName, Instruction: instruction, Model: chat, MaxIterations: opt.MAX_TOOL_ROUND,
|
||||
GenModelInput: genModelInput,
|
||||
ToolsConfig: adk.ToolsConfig{ToolsNodeConfig: compose.ToolsNodeConfig{Tools: tools}, EmitInternalEvents: true},
|
||||
ToolsConfig: adk.ToolsConfig{ToolsNodeConfig: compose.ToolsNodeConfig{Tools: tools}},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user