Skip to content

refine utility name #781

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
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ public virtual void OnAgentUtilityLoaded(Agent agent)
return ([], []);
}

var prefix = "util-";
utilities = utilities?.Where(x => !string.IsNullOrEmpty(x.Name) && !x.Disabled)?.ToList() ?? [];
var functionNames = utilities.SelectMany(x => x.Functions)
.Where(x => !string.IsNullOrEmpty(x.Name))
.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.StartsWith(prefix))
.Select(x => x.Name)
.Distinct().ToList();
var templateNames = utilities.SelectMany(x => x.Templates)
.Where(x => !string.IsNullOrEmpty(x.Name))
.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.StartsWith(prefix))
.Select(x => x.Name)
.Distinct().ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
</ItemGroup>

<ItemGroup>
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_audio_request.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_audio_request.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-audio-handle_audio_request.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-audio-handle_audio_request.fn.liquid" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_audio_request.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-audio-handle_audio_request.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_audio_request.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-audio-handle_audio_request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace BotSharp.Plugin.AudioHandler.Enums;

public class UtilityName
{
public const string AudioHandler = "audio-handler";
public const string AudioHandler = "audio.audio-handler";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BotSharp.Plugin.AudioHandler.Functions;

public class HandleAudioRequestFn : IFunctionCallback
{
public string Name => "handle_audio_request";
public string Name => "util-audio-handle_audio_request";
public string Indication => "Handling audio request";

private readonly IServiceProvider _serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace BotSharp.Plugin.AudioHandler.Hooks;

public class AudioHandlerUtilityHook : IAgentUtilityHook
{
private const string HANDLER_AUDIO = "handle_audio_request";
private const string PREFIX = "util-audio-";
private const string HANDLER_AUDIO = $"{PREFIX}handle_audio_request";

public void AddUtilities(List<AgentUtility> utilities)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "handle_audio_request",
"name": "util-audio-handle_audio_request",
"description": "If the user requests to transcribe or summarize audio content, you need to call this function to transcribe the audio content to raw texts or provide sunmmary based on raw texts transcribed from audio",
"parameters": {
"type": "object",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please call util-audio-handle_audio_request if user wants to transcribe or summarize the content of a audio file.
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@
</PropertyGroup>

<ItemGroup>
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_email_reader.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_email_sender.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_sender.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_reader.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\select_attachment_prompt.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-email-handle_email_reader.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-email-handle_email_sender.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-email-handle_email_sender.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-email-handle_email_reader.fn.liquid" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_email_reader.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-email-handle_email_reader.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_email_sender.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-email-handle_email_sender.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_sender.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-email-handle_email_sender.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_email_reader.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-email-handle_email_reader.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
13 changes: 3 additions & 10 deletions src/Plugins/BotSharp.Plugin.EmailHandler/Enums/UtilityName.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BotSharp.Plugin.EmailHandler.Enums;

namespace BotSharp.Plugin.EmailHandler.Enums
public class UtilityName
{
public class UtilityName
{
public const string EmailHandler = "email-handler";
}
public const string EmailHandler = "email.email-handler";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BotSharp.Plugin.EmailReader.Functions;

public class HandleEmailReaderFn : IFunctionCallback
{
public string Name => "handle_email_reader";
public string Name => "util-email-handle_email_reader";
public readonly static string PROMPT_SUMMARY = "Provide a text summary of the following content.";
public readonly static string RICH_CONTENT_SUMMARIZE = "is_email_summarize: true. messageId";
public readonly static string RICH_CONTENT_READ_EMAIL = "Read the email by messageId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BotSharp.Plugin.EmailHandler.Functions;

public class HandleEmailSenderFn : IFunctionCallback
{
public string Name => "handle_email_sender";
public string Name => "util-email-handle_email_sender";
public string Indication => "Handling email send request";

private readonly IServiceProvider _services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace BotSharp.Plugin.EmailHandler.Hooks;

public class EmailHandlerUtilityHook : IAgentUtilityHook
{
private static string EMAIL_READER_FN = "handle_email_reader";
private static string EMAIL_SENDER_FN = "handle_email_sender";
private static string PREFIX = "util-email-";
private static string EMAIL_READER_FN = $"{PREFIX}handle_email_reader";
private static string EMAIL_SENDER_FN = $"{PREFIX}handle_email_sender";

public void AddUtilities(List<AgentUtility> utilities)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "handle_email_reader",
"name": "util-email-handle_email_reader",
"description": "If the user wants to read messages from email inbox or user wants to mark an email message as read.If message id is provided, capture it but it is not required. Then call this function to read the email message or mark any message as read.",
"parameters": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "handle_email_sender",
"name": "util-email-handle_email_sender",
"description": "If the user requests to send an email with or without attachments or files, you need to capture the email content and the recipient email address. If the user explicitly enter email subject use the same if not intelligently capture the email subject from the content. Then call this function to send out email.",
"parameters": {
"type": "object",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please call util-email-handle_email_reader if user wants to read messages from email inbox.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
** Please take a look at the conversation and decide whether user wants to send email.
** If yes, then decide whether user wants to send email with files/attachments/images or not.
** If user does not want to send email explicitly or only upload images or files, please do not respond anything email related message.
** Please call handle_email_sender if user wants to send email.
** Please call util-email-handle_email_sender if user wants to send email.
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
</ItemGroup>

<ItemGroup>
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_excel_request.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_excel_request.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-excel-handle_excel_request.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-excel-handle_excel_request.fn.liquid" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\handle_excel_request.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-excel-handle_excel_request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\handle_excel_request.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-excel-handle_excel_request.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace BotSharp.Plugin.ExcelHandler.Enums;

public class UtilityName
{
public const string ExcelHandler = "excel-handler";
public const string ExcelHandler = "excel.excel-handler";
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using BotSharp.Abstraction.Files.Enums;
using BotSharp.Abstraction.Files.Models;
using BotSharp.Abstraction.Files.Utilities;
using BotSharp.Plugin.ExcelHandler.Helpers.Sqlite;
using BotSharp.Plugin.ExcelHandler.Models;
using BotSharp.Plugin.ExcelHandler.Services;
using NPOI.SS.UserModel;
Expand All @@ -12,7 +11,7 @@ namespace BotSharp.Plugin.ExcelHandler.Functions;

public class HandleExcelRequestFn : IFunctionCallback
{
public string Name => "handle_excel_request";
public string Name => "util-excel-handle_excel_request";
public string Indication => "Handling excel request";

private readonly IServiceProvider _serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace BotSharp.Plugin.ExcelHandler.Hooks;

public class ExcelHandlerUtilityHook : IAgentUtilityHook
{
private const string HANDLER_EXCEL = "handle_excel_request";
private static string PREFIX = "util-excel-";
private static string HANDLER_EXCEL = $"{PREFIX}handle_excel_request";

public void AddUtilities(List<AgentUtility> utilities)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "handle_excel_request",
"name": "util-excel-handle_excel_request",
"description": "If the user requests to read/load data from excel/csv files, you need to call this function to load the data from excel/csv files and transform into JSON format data",
"parameters": {
"type": "object",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Please call util-excel-handle_excel_request if user wants to load the data from a excel/csv file.
util-excel-handle_excel_request can NOT generate excel/csv.
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,43 @@
</PropertyGroup>

<ItemGroup>
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\edit_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\generate_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\read_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\read_pdf.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\edit_image.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\generate_image.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\read_image.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\read_pdf.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\select_edit_image_prompt.liquid" />
</ItemGroup>

<ItemGroup>
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-generate_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-generate_image.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-read_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-read_image.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-read_pdf.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-read_pdf.fn.liquid" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-edit_image.json" />
<None Remove="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-edit_image.fn.liquid" />
</ItemGroup>

<ItemGroup>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\generate_image.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-generate_image.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\read_image.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-generate_image.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\generate_image.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-read_image.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\read_image.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-read_image.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\read_pdf.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-read_pdf.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\read_pdf.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-read_pdf.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\edit_image.json">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\functions\util-file-edit_image.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\edit_image.fn.liquid">
<Content Include="data\agents\6745151e-6d46-4a02-8de4-1c4f21c7da95\templates\util-file-edit_image.fn.liquid">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Plugins/BotSharp.Plugin.FileHandler/Enums/UtilityName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ namespace BotSharp.Plugin.FileHandler.Enums;

public class UtilityName
{
public const string ImageGenerator = "image-generator";
public const string ImageReader = "image-reader";
public const string ImageEditor = "image-editor";
public const string PdfReader = "pdf-reader";
public const string ImageGenerator = "file.image-generator";
public const string ImageReader = "file.image-reader";
public const string ImageEditor = "file.image-editor";
public const string PdfReader = "file.pdf-reader";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace BotSharp.Plugin.FileHandler.Functions;

public class EditImageFn : IFunctionCallback
{
public string Name => "edit_image";
public string Name => "util-file-edit_image";
public string Indication => "Editing image";

private readonly IServiceProvider _services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BotSharp.Plugin.FileHandler.Functions;

public class GenerateImageFn : IFunctionCallback
{
public string Name => "generate_image";
public string Name => "util-file-generate_image";
public string Indication => "Generating image";

private readonly IServiceProvider _services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BotSharp.Plugin.FileHandler.Functions;

public class ReadImageFn : IFunctionCallback
{
public string Name => "read_image";
public string Name => "util-file-read_image";
public string Indication => "Reading images";

private readonly IServiceProvider _services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace BotSharp.Plugin.FileHandler.Functions;

public class ReadPdfFn : IFunctionCallback
{
public string Name => "read_pdf";
public string Name => "util-file-read_pdf";
public string Indication => "Reading pdf";

private readonly IServiceProvider _services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace BotSharp.Plugin.FileHandler.Hooks;

public class FileHandlerUtilityHook : IAgentUtilityHook
{
private const string READ_IMAGE_FN = "read_image";
private const string READ_PDF_FN = "read_pdf";
private const string GENERATE_IMAGE_FN = "generate_image";
private const string EDIT_IMAGE_FN = "edit_image";
private const string READ_IMAGE_FN = "util-file-read_image";
private const string READ_PDF_FN = "util-file-read_pdf";
private const string GENERATE_IMAGE_FN = "util-file-generate_image";
private const string EDIT_IMAGE_FN = "util-file-edit_image";

public void AddUtilities(List<AgentUtility> utilities)
{
Expand Down

This file was deleted.

Loading