change to read file
This commit is contained in:
parent
232f286be6
commit
0cd664636e
|
|
@ -2,6 +2,6 @@ namespace BotSharp.Abstraction.Agents.Enums;
|
|||
|
||||
public class AgentUtility
|
||||
{
|
||||
public const string FileAnalyzer = "file-analyzer";
|
||||
public const string FileReader = "file-reader";
|
||||
public const string ImageGenerator = "image-generator";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@
|
|||
<ItemGroup>
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\agent.json" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\generate_image.json" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\read_file.json" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\instruction.liquid" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\load_attachment.json" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\generate_image.fn.liquid" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\load_attachment.fn.liquid" />
|
||||
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\read_file.fn.liquid" />
|
||||
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\agent.json" />
|
||||
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions.json" />
|
||||
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions\human_intervention_needed.json" />
|
||||
|
|
@ -159,10 +159,10 @@
|
|||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\instruction.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\load_attachment.json">
|
||||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\read_file.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\templates\load_attachment.fn.liquid">
|
||||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\templates\read_file.fn.liquid">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\generate_image.json">
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ public class FilePlugin : IBotSharpPlugin
|
|||
{
|
||||
services.AddScoped<IBotSharpFileService, BotSharpFileService>();
|
||||
|
||||
services.AddScoped<IAgentHook, FileAnalyzerHook>();
|
||||
services.AddScoped<IAgentUtilityHook, FileAnalyzerUtilityHook>();
|
||||
services.AddScoped<IAgentHook, FileReaderHook>();
|
||||
services.AddScoped<IAgentUtilityHook, FileReaderUtilityHook>();
|
||||
services.AddScoped<IAgentHook, ImageGeneratorHook>();
|
||||
services.AddScoped<IAgentUtilityHook, ImageGeneratorUtilityHook>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,20 @@ using BotSharp.Abstraction.MLTasks;
|
|||
|
||||
namespace BotSharp.Core.Files.Functions;
|
||||
|
||||
public class LoadAttachmentFn : IFunctionCallback
|
||||
public class ReadFileFn : IFunctionCallback
|
||||
{
|
||||
public string Name => "load_attachment";
|
||||
public string Indication => "Analyzing files";
|
||||
public string Name => "read_file";
|
||||
public string Indication => "Reading files";
|
||||
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly ILogger<LoadAttachmentFn> _logger;
|
||||
private readonly ILogger<ReadFileFn> _logger;
|
||||
private readonly IEnumerable<string> _imageTypes = new List<string> { "image", "images", "png", "jpg", "jpeg" };
|
||||
private readonly IEnumerable<string> _pdfTypes = new List<string> { "pdf" };
|
||||
private static string UTILITY_ASSISTANT = Guid.Empty.ToString();
|
||||
|
||||
public LoadAttachmentFn(
|
||||
public ReadFileFn(
|
||||
IServiceProvider services,
|
||||
ILogger<LoadAttachmentFn> logger)
|
||||
ILogger<ReadFileFn> logger)
|
||||
{
|
||||
_services = services;
|
||||
_logger = logger;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
namespace BotSharp.Core.Files.Hooks;
|
||||
|
||||
public class FileAnalyzerHook : AgentHookBase
|
||||
public class FileReaderHook : AgentHookBase
|
||||
{
|
||||
private static string UTILITY_ASSISTANT = Guid.Empty.ToString();
|
||||
private static string FUNCTION_NAME = "load_attachment";
|
||||
private static string FUNCTION_NAME = "read_file";
|
||||
|
||||
public override string SelfId => string.Empty;
|
||||
|
||||
public FileAnalyzerHook(IServiceProvider services, AgentSettings settings)
|
||||
public FileReaderHook(IServiceProvider services, AgentSettings settings)
|
||||
: base(services, settings)
|
||||
{
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ public class FileAnalyzerHook : AgentHookBase
|
|||
{
|
||||
var conv = _services.GetRequiredService<IConversationService>();
|
||||
var isConvMode = conv.IsConversationMode();
|
||||
var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileAnalyzer);
|
||||
var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileReader);
|
||||
|
||||
if (isConvMode && isEnabled)
|
||||
{
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
namespace BotSharp.Core.Files.Hooks;
|
||||
|
||||
public class FileAnalyzerUtilityHook : IAgentUtilityHook
|
||||
public class FileReaderUtilityHook : IAgentUtilityHook
|
||||
{
|
||||
public void AddUtilities(List<string> utilities)
|
||||
{
|
||||
utilities.Add(AgentUtility.FileAnalyzer);
|
||||
utilities.Add(AgentUtility.FileReader);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "load_attachment",
|
||||
"name": "read_file",
|
||||
"description": "If the user's request is related to analyzing files and/or images, you can call this function to analyze files and images.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
|
|
@ -1 +0,0 @@
|
|||
Please call load_attachment if user wants to describe files, such as images, pdf.
|
||||
|
|
@ -0,0 +1 @@
|
|||
Please call read_file if user wants to describe files, such as images, pdf.
|
||||
Loading…
Reference in a new issue