-
Notifications
You must be signed in to change notification settings - Fork 21
Feat/97 include tools support for cloud providers #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wisedev-pstach
merged 8 commits into
main
from
feat/97-include-tools-support-for-cloud-providers
Oct 23, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9f593ba
feat: updates for tools usage
5d5f0d5
feat: tool use basics
a947944
feat: cd incorporate tools
9b5d47c
feat: fix tool calls
438c361
feat: finalize code changes
200aadd
feat: tool support
b6d665c
f: cleanup
3dc6da4
process pr comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| using Examples.Utils; | ||
| using MaIN.Core.Hub; | ||
| using MaIN.Core.Hub.Utils; | ||
|
|
||
| namespace Examples.Agents; | ||
|
|
||
| public class AgentExampleTools : IExample | ||
| { | ||
| public async Task Start() | ||
| { | ||
| AnthropicExample.Setup(); | ||
| Console.WriteLine("(Anthropic) Tool example is running!"); | ||
|
|
||
| var context = await AIHub.Agent() | ||
| .WithModel("claude-sonnet-4-5-20250929") | ||
| .WithSteps(StepBuilder.Instance | ||
| .Answer() | ||
| .Build()) | ||
| .WithTools(new ToolsConfigurationBuilder() | ||
| .AddTool<ListNotesArgs>( | ||
| "list_notes", | ||
| "List all available notes", | ||
| new | ||
| { | ||
| type = "object", | ||
| properties = new | ||
| { | ||
| folder = new { type = "string", description = "Notes folder", @default = "notes" } | ||
| } | ||
| }, | ||
| NoteTools.ListNotes) | ||
| .AddTool<ReadNoteArgs>( | ||
| "read_note", | ||
| "Read the content of a specific note", | ||
| new | ||
| { | ||
| type = "object", | ||
| properties = new | ||
| { | ||
| noteName = new | ||
| { type = "string", description = "Name of the note (without .txt extension)" } | ||
| }, | ||
| required = new[] { "noteName" } | ||
| }, | ||
| NoteTools.ReadNote) | ||
| .AddTool<SaveNoteArgs>( | ||
| "save_note", | ||
| "Save or update a note with new content", | ||
| new | ||
| { | ||
| type = "object", | ||
| properties = new | ||
| { | ||
| noteName = new | ||
| { type = "string", description = "Name of the note (without .txt extension)" }, | ||
| content = new { type = "string", description = "Content to save in the note" } | ||
| }, | ||
| required = new[] { "noteName", "content" } | ||
| }, | ||
| NoteTools.SaveNote) | ||
| .WithToolChoice("auto") | ||
| .Build()) | ||
| .CreateAsync(interactiveResponse: true); | ||
|
|
||
| await context.ProcessAsync("What notes do I currently have?"); | ||
|
|
||
| Console.WriteLine("--//--"); | ||
|
|
||
| await context.ProcessAsync("Create a new note for a shopping list that includes healthy foods."); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| using Examples.Utils; | ||
| using MaIN.Core.Hub; | ||
| using MaIN.Domain.Configuration; | ||
|
|
||
| namespace Examples.Chat; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using Examples.Utils; | ||
| using MaIN.Core.Hub; | ||
| using MaIN.Core.Hub.Utils; | ||
| using MaIN.Domain.Configuration; | ||
|
|
||
| namespace Examples.Chat; | ||
|
|
||
| public class ChatExampleToolsSimple : IExample | ||
| { | ||
| public async Task Start() | ||
| { | ||
| OpenAiExample.Setup(); //We need to provide OpenAi API key | ||
|
|
||
| Console.WriteLine("(OpenAi) ChatExample with tools is running!"); | ||
|
|
||
| await AIHub.Chat() | ||
| .WithModel("gpt-5-nano") | ||
| .WithMessage("What time is it right now?") | ||
| .WithTools(new ToolsConfigurationBuilder() | ||
| .AddTool( | ||
| name: "get_current_time", | ||
| description: "Get the current date and time", | ||
| execute: Tools.GetCurrentTime) | ||
| .WithToolChoice("auto") | ||
| .Build()) | ||
| .CompleteAsync(interactive: true); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| using System.Text.Json; | ||
|
|
||
| namespace Examples.Utils; | ||
|
|
||
| public static class Tools | ||
| { | ||
| public static object GetCurrentTime() | ||
| { | ||
| var now = DateTime.Now; | ||
| var timeInfo = new | ||
| { | ||
| date = now.ToString("yyyy-MM-dd"), | ||
| time = now.ToString("HH:mm:ss"), | ||
| dayOfWeek = now.DayOfWeek.ToString() | ||
| }; | ||
|
|
||
| return $"Date: {timeInfo.date}, Time: {timeInfo.time}, Day of week: {timeInfo.dayOfWeek}"; | ||
| } | ||
| } | ||
|
|
||
| public static class NoteTools | ||
| { | ||
| private const string NotesFolder = "notes"; | ||
|
|
||
|
|
||
|
wisedev-pstach marked this conversation as resolved.
Outdated
|
||
| public static async Task<object> ListNotes(ListNotesArgs args) | ||
| { | ||
| if (!Directory.Exists(args.Folder)) | ||
| Directory.CreateDirectory(args.Folder); | ||
|
|
||
| var files = Directory.GetFiles(args.Folder, "*.txt"); | ||
|
|
||
| return new | ||
| { | ||
| count = files.Length, | ||
| notes = files.Select(f => new | ||
| { | ||
| name = Path.GetFileNameWithoutExtension(f), | ||
| lastModified = File.GetLastWriteTime(f).ToString("yyyy-MM-dd HH:mm:ss"), | ||
| sizeBytes = new FileInfo(f).Length | ||
| }).ToArray() | ||
| }; | ||
| } | ||
|
|
||
| public static async Task<object> ReadNote(ReadNoteArgs args) | ||
| { | ||
| var filePath = Path.Combine(NotesFolder, $"{args.NoteName}.txt"); | ||
|
|
||
| if (!File.Exists(filePath)) | ||
| return new { error = $"Note '{args.NoteName}' not found" }; | ||
|
|
||
| var content = await File.ReadAllTextAsync(filePath); | ||
|
|
||
| return new | ||
| { | ||
| name = args.NoteName, | ||
| content = content, | ||
| lastModified = File.GetLastWriteTime(filePath).ToString("yyyy-MM-dd HH:mm:ss") | ||
| }; | ||
| } | ||
|
|
||
| public static async Task<object> SaveNote(SaveNoteArgs args) | ||
| { | ||
| if (!Directory.Exists(NotesFolder)) | ||
| Directory.CreateDirectory(NotesFolder); | ||
|
|
||
| var filePath = Path.Combine(NotesFolder, $"{args.NoteName}.txt"); | ||
| var isNew = !File.Exists(filePath); | ||
|
|
||
| await File.WriteAllTextAsync(filePath, args.Content); | ||
|
|
||
| return new | ||
| { | ||
| success = true, | ||
| name = args.NoteName, | ||
| action = isNew ? "created" : "updated", | ||
| path = filePath | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public class ListNotesArgs | ||
| { | ||
| public string Folder { get; set; } = "notes"; | ||
| } | ||
|
|
||
| public class ReadNoteArgs | ||
| { | ||
| public string NoteName { get; set; } = null!; | ||
| } | ||
|
|
||
| public class SaveNoteArgs | ||
| { | ||
| public string NoteName { get; set; } = null!; | ||
| public string Content { get; set; } = null!; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # 0.7.0 release | ||
|
|
||
| - Add full tool support for all available cloud providers | ||
|
|
||
| On chat/agent context | ||
|
|
||
| ``` | ||
| .WithTools(new ToolsConfigurationBuilder() | ||
| .AddTool( | ||
| name: "get_current_time", | ||
| description: "Get the current date and time", | ||
| execute: Tools.GetCurrentTime) | ||
| .WithToolChoice("auto") | ||
| .Build()) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.