1+ using Examples . Utils ;
2+ using MaIN . Core . Hub ;
3+ using MaIN . Core . Hub . Utils ;
4+
5+ namespace Examples . Agents ;
6+
7+ public class AgentExampleTools : IExample
8+ {
9+ public async Task Start ( )
10+ {
11+ AnthropicExample . Setup ( ) ;
12+ Console . WriteLine ( "(Anthropic) Tool example is running!" ) ;
13+
14+ var context = await AIHub . Agent ( )
15+ . WithModel ( "claude-sonnet-4-5-20250929" )
16+ . WithSteps ( StepBuilder . Instance
17+ . Answer ( )
18+ . Build ( ) )
19+ . WithTools ( new ToolsConfigurationBuilder ( )
20+ . AddTool < ListNotesArgs > (
21+ "list_notes" ,
22+ "List all available notes" ,
23+ new
24+ {
25+ type = "object" ,
26+ properties = new
27+ {
28+ folder = new { type = "string" , description = "Notes folder" , @default = "notes" }
29+ }
30+ } ,
31+ NoteTools . ListNotes )
32+ . AddTool < ReadNoteArgs > (
33+ "read_note" ,
34+ "Read the content of a specific note" ,
35+ new
36+ {
37+ type = "object" ,
38+ properties = new
39+ {
40+ noteName = new
41+ { type = "string" , description = "Name of the note (without .txt extension)" }
42+ } ,
43+ required = new [ ] { "noteName" }
44+ } ,
45+ NoteTools . ReadNote )
46+ . AddTool < SaveNoteArgs > (
47+ "save_note" ,
48+ "Save or update a note with new content" ,
49+ new
50+ {
51+ type = "object" ,
52+ properties = new
53+ {
54+ noteName = new
55+ { type = "string" , description = "Name of the note (without .txt extension)" } ,
56+ content = new { type = "string" , description = "Content to save in the note" }
57+ } ,
58+ required = new [ ] { "noteName" , "content" }
59+ } ,
60+ NoteTools . SaveNote )
61+ . WithToolChoice ( "auto" )
62+ . Build ( ) )
63+ . CreateAsync ( interactiveResponse : true ) ;
64+
65+ await context . ProcessAsync ( "What notes do I currently have?" ) ;
66+
67+ Console . WriteLine ( "--//--" ) ;
68+
69+ await context . ProcessAsync ( "Create a new note for a shopping list that includes healthy foods." ) ;
70+ }
71+ }
0 commit comments