feat: add weather tools to legacy and Eino chat
This commit is contained in:
1 parent
6e6171f481
commit
86e86bc9fa
18 files changed
+926
-77
No files matched your search
+15
-3
@@ -7,9 +7,12 @@ import (
|
||||
|
||||
"example.com/ueino/internal/opt"
|
||||
"example.com/ueino/pkg/memory"
|
||||
"example.com/ueino/pkg/tool"
|
||||
|
||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||
"github.com/cloudwego/eino/adk"
|
||||
einotool "github.com/cloudwego/eino/components/tool"
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
)
|
||||
|
||||
@@ -37,9 +40,11 @@ func New(ctx context.Context, config Config) (*Agent, error) {
|
||||
return nil, err
|
||||
}
|
||||
chatAgent, err := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
|
||||
Name: "terminal_chat",
|
||||
Instruction: opt.SYSTEM_PROMPT,
|
||||
Model: chat,
|
||||
Name: "terminal_chat",
|
||||
Instruction: opt.SYSTEM_PROMPT,
|
||||
Model: chat,
|
||||
MaxIterations: opt.MAX_TOOL_ROUND,
|
||||
ToolsConfig: adk.ToolsConfig{ToolsNodeConfig: compose.ToolsNodeConfig{Tools: []einotool.BaseTool{tool.NewWeather()}}},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -87,6 +92,13 @@ func readResponse(events *adk.AsyncIterator[*adk.AgentEvent], onChunk func(strin
|
||||
continue
|
||||
}
|
||||
output := event.Output.MessageOutput
|
||||
if output.Role != schema.Assistant {
|
||||
if output.IsStreaming {
|
||||
output.MessageStream.Close()
|
||||
}
|
||||
continue
|
||||
}
|
||||
reply.Reset()
|
||||
if !output.IsStreaming {
|
||||
onChunk(output.Message.Content)
|
||||
reply.WriteString(output.Message.Content)
|
||||
|
||||
Reference in new issue
Block a user