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
@@ -13,11 +13,10 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
)
|
||||
|
||||
// readResponse 消费各 Agent 的事件流,子 Agent 的正文和工具结果不会混入主回复。
|
||||
// readResponse 消费事件流,主助手正文和工具执行状态分别输出。
|
||||
func readResponse(events *adk.AsyncIterator[*adk.AgentEvent], onText, onStatus func(string)) (string, *adk.InterruptInfo, error) {
|
||||
var interrupted *adk.InterruptInfo
|
||||
reply := ""
|
||||
imageStarted := false
|
||||
status := func(text string) {
|
||||
if onStatus != nil {
|
||||
onStatus(text)
|
||||
@@ -38,10 +37,6 @@ func readResponse(events *adk.AsyncIterator[*adk.AgentEvent], onText, onStatus f
|
||||
interrupted = event.Action.Interrupted
|
||||
continue
|
||||
}
|
||||
if event.AgentName == imageAgentName && !imageStarted {
|
||||
status("主助手已委托 image_creator,生图 Agent 开始处理")
|
||||
imageStarted = true
|
||||
}
|
||||
if event.Output == nil || event.Output.MessageOutput == nil {
|
||||
continue
|
||||
}
|
||||
@@ -61,7 +56,7 @@ func readResponse(events *adk.AsyncIterator[*adk.AgentEvent], onText, onStatus f
|
||||
}
|
||||
if output.Role == schema.Tool {
|
||||
message := fmt.Sprintf("%s:%s 执行完成", event.AgentName, output.ToolName)
|
||||
if event.AgentName == imageAgentName && output.ToolName == "generate_image" {
|
||||
if output.ToolName == "generate_image" {
|
||||
var result model.ImageResult
|
||||
if json.Unmarshal([]byte(text), &result) == nil && result.Path != "" {
|
||||
message += ",图片:" + result.Path
|
||||
|
||||
Reference in new issue
Block a user