Skip to content

Commit 291165d

Browse files
committed
Updated
1 parent 67e0ad4 commit 291165d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

examples/tool_adder/main.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ func main() {
5656
}
5757

5858
// Register tool
59-
session := model.Context()
6059
toolkit := tool.NewToolKit()
6160
toolkit.Register(&Adder{})
6261

63-
// Get the tool call
62+
// Create a chat session
63+
session := model.Context(llm.WithToolKit(toolkit))
64+
65+
// Make the prompt
6466
prompt := fmt.Sprintf("What is %v plus %v?", os.Args[2], os.Args[3])
65-
if err := session.FromUser(context.TODO(), prompt, llm.WithToolKit(toolkit), llm.WithToolChoice("any")); err != nil {
67+
if err := session.FromUser(context.TODO(), prompt); err != nil {
6668
panic(err)
6769
}
6870

@@ -73,11 +75,6 @@ func main() {
7375
break
7476
}
7577

76-
// Print out any intermediate messages
77-
if session.Text(0) != "" {
78-
fmt.Println(session.Text(0))
79-
}
80-
8178
// Get the results from the toolkit
8279
fmt.Println("Running", calls)
8380
results, err := toolkit.Run(context.TODO(), calls...)

0 commit comments

Comments
 (0)