Skip to content

Commit 9fa0621

Browse files
authored
Merge pull request #528 from iceljc/master
Change to read_file
2 parents 1ebd0d4 + ced713d commit 9fa0621

File tree

14 files changed

+37
-33
lines changed

14 files changed

+37
-33
lines changed

src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace BotSharp.Abstraction.Agents.Enums;
22

33
public class AgentUtility
44
{
5-
public const string FileAnalyzer = "file-analyzer";
5+
public const string FileReader = "file-reader";
66
public const string ImageGenerator = "image-generator";
77
}

src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
<ItemGroup>
4949
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\agent.json" />
5050
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\generate_image.json" />
51+
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\read_file.json" />
5152
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\instruction.liquid" />
52-
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\functions\load_attachment.json" />
5353
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\generate_image.fn.liquid" />
54-
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\load_attachment.fn.liquid" />
54+
<None Remove="data\agents\00000000-0000-0000-0000-000000000000\templates\read_file.fn.liquid" />
5555
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\agent.json" />
5656
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions.json" />
5757
<None Remove="data\agents\01dcc3e5-0af7-49e6-ad7a-a760bd12dc4b\functions\human_intervention_needed.json" />
@@ -159,10 +159,10 @@
159159
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\instruction.liquid">
160160
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
161161
</Content>
162-
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\load_attachment.json">
162+
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\read_file.json">
163163
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
164164
</Content>
165-
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\templates\load_attachment.fn.liquid">
165+
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\templates\read_file.fn.liquid">
166166
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
167167
</Content>
168168
<Content Include="data\agents\00000000-0000-0000-0000-000000000000\functions\generate_image.json">

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async Task<bool> SendMessage(string agentId,
2020

2121
var content = $"Received [{agent.Name}] {message.Role}: {message.Content}";
2222
#if DEBUG
23-
Console.WriteLine(content, Color.GreenYellow);
23+
Console.WriteLine(content);
2424
#else
2525
_logger.LogInformation(content);
2626
#endif
@@ -103,7 +103,7 @@ private async Task HandleAssistantMessage(RoleDialogModel response, Func<RoleDia
103103
response.Role = AgentRole.Assistant;
104104
var text = $"Sending [{agentName}] {response.Role}: {response.Content}";
105105
#if DEBUG
106-
Console.WriteLine(text, Color.Yellow);
106+
Console.WriteLine(text);
107107
#else
108108
_logger.LogInformation(text);
109109
#endif

src/Infrastructure/BotSharp.Core/Conversations/Services/TokenStatistics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void PrintStatistics()
7070
}
7171
var stats = $"Token Usage: {_promptTokenCount} prompt + {_completionTokenCount} completion = {Total} total tokens ({_timer.ElapsedMilliseconds / 1000f:f2}s). One-Way cost: {Cost:C4}, accumulated cost: {AccumulatedCost:C4}. [{_model}]";
7272
#if DEBUG
73-
Console.WriteLine(stats, Color.DarkGray);
73+
Console.WriteLine(stats);
7474
#else
7575
_logger.LogInformation(stats);
7676
#endif

src/Infrastructure/BotSharp.Core/Files/FilePlugin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
1717
{
1818
services.AddScoped<IBotSharpFileService, BotSharpFileService>();
1919

20-
services.AddScoped<IAgentHook, FileAnalyzerHook>();
21-
services.AddScoped<IAgentUtilityHook, FileAnalyzerUtilityHook>();
20+
services.AddScoped<IAgentHook, FileReaderHook>();
21+
services.AddScoped<IAgentUtilityHook, FileReaderUtilityHook>();
2222
services.AddScoped<IAgentHook, ImageGeneratorHook>();
2323
services.AddScoped<IAgentUtilityHook, ImageGeneratorUtilityHook>();
2424
}

src/Infrastructure/BotSharp.Core/Files/Functions/LoadAttachmentFn.cs renamed to src/Infrastructure/BotSharp.Core/Files/Functions/ReadFileFn.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
namespace BotSharp.Core.Files.Functions;
55

6-
public class LoadAttachmentFn : IFunctionCallback
6+
public class ReadFileFn : IFunctionCallback
77
{
8-
public string Name => "load_attachment";
9-
public string Indication => "Analyzing files";
8+
public string Name => "read_file";
9+
public string Indication => "Reading files";
1010

1111
private readonly IServiceProvider _services;
12-
private readonly ILogger<LoadAttachmentFn> _logger;
12+
private readonly ILogger<ReadFileFn> _logger;
1313
private readonly IEnumerable<string> _imageTypes = new List<string> { "image", "images", "png", "jpg", "jpeg" };
1414
private readonly IEnumerable<string> _pdfTypes = new List<string> { "pdf" };
1515
private static string UTILITY_ASSISTANT = Guid.Empty.ToString();
1616

17-
public LoadAttachmentFn(
17+
public ReadFileFn(
1818
IServiceProvider services,
19-
ILogger<LoadAttachmentFn> logger)
19+
ILogger<ReadFileFn> logger)
2020
{
2121
_services = services;
2222
_logger = logger;

src/Infrastructure/BotSharp.Core/Files/Hooks/FileAnalyzerHook.cs renamed to src/Infrastructure/BotSharp.Core/Files/Hooks/FileReaderHook.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
namespace BotSharp.Core.Files.Hooks;
22

3-
public class FileAnalyzerHook : AgentHookBase
3+
public class FileReaderHook : AgentHookBase
44
{
55
private static string UTILITY_ASSISTANT = Guid.Empty.ToString();
6-
private static string FUNCTION_NAME = "load_attachment";
6+
private static string FUNCTION_NAME = "read_file";
77

88
public override string SelfId => string.Empty;
99

10-
public FileAnalyzerHook(IServiceProvider services, AgentSettings settings)
10+
public FileReaderHook(IServiceProvider services, AgentSettings settings)
1111
: base(services, settings)
1212
{
1313
}
@@ -16,7 +16,7 @@ public override void OnAgentLoaded(Agent agent)
1616
{
1717
var conv = _services.GetRequiredService<IConversationService>();
1818
var isConvMode = conv.IsConversationMode();
19-
var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileAnalyzer);
19+
var isEnabled = !agent.Utilities.IsNullOrEmpty() && agent.Utilities.Contains(AgentUtility.FileReader);
2020

2121
if (isConvMode && isEnabled)
2222
{
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace BotSharp.Core.Files.Hooks;
22

3-
public class FileAnalyzerUtilityHook : IAgentUtilityHook
3+
public class FileReaderUtilityHook : IAgentUtilityHook
44
{
55
public void AddUtilities(List<string> utilities)
66
{
7-
utilities.Add(AgentUtility.FileAnalyzer);
7+
utilities.Add(AgentUtility.FileReader);
88
}
99
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "load_attachment",
2+
"name": "read_file",
33
"description": "If the user's request is related to analyzing files and/or images, you can call this function to analyze files and images.",
44
"parameters": {
55
"type": "object",

src/Infrastructure/BotSharp.Core/data/agents/00000000-0000-0000-0000-000000000000/templates/load_attachment.fn.liquid

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)