Skip to content

Commit 8ae9cae

Browse files
author
Krystian Moskal
committed
modifies regarding pr comments
1 parent 90760ba commit 8ae9cae

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

Examples/Examples/Agents/AgentWithBecomeExample.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public async Task Start()
1111
var becomeAgent = AIHub.Agent()
1212
.WithModel("llama3.1:8b")
1313
.WithInitialPrompt("Extract 5 best books that you can find in your memory")
14-
.WithSource(new AgentFileSourceDetails()
14+
.WithSource(new AgentFileSourceDetails
1515
{
16-
Files = new Dictionary<string, string>
17-
{
18-
{ "Books.json", "./Files/Books.json" }
19-
},
16+
Files =
17+
[
18+
"./Files/Books.json"
19+
]
2020
}, AgentSourceType.File)
2121
.WithBehaviour("SalesGod",
2222
"""

src/MaIN.Domain/Entities/Agents/AgentSource/AgentFileSourceDetails.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace MaIN.Domain.Entities.Agents.AgentSource;
22

33
public class AgentFileSourceDetails : AgentSourceDetailsBase, IAgentSource
44
{
5-
public required Dictionary<string, string> Files { get; init; } = new();
5+
public List<string> Files { get; init; } = [];
66
public bool PreProcess { get; init; } = false;
77
}

src/MaIN.Services/Services/Steps/Commands/FetchCommandHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public class FetchCommandHandler(
8181
private async Task<Message> HandleFileSource(FetchCommand command, Dictionary<string, string> properties)
8282
{
8383
var fileData = JsonSerializer.Deserialize<AgentFileSourceDetails>(command.Context.Source!.Details?.ToString()!);
84-
84+
var filesDictionary = fileData!.Files.ToDictionary( path => Path.GetFileName(path), path => path);
85+
8586
if (command.Chat.Messages.Count > 0)
8687
{
8788
var memoryChat = command.MemoryChat;
@@ -90,15 +91,15 @@ private async Task<Message> HandleFileSource(FetchCommand command, Dictionary<st
9091
memoryChat!,
9192
new ChatMemoryOptions
9293
{
93-
FilesData = fileData!.Files,
94+
FilesData = filesDictionary,
9495
PreProcess = fileData.PreProcess
9596
}
9697
);
9798

9899
return result!.Message;
99100
}
100101

101-
var data = await dataSourceService.FetchFileData(fileData!.Files);
102+
var data = await dataSourceService.FetchFileData(filesDictionary);
102103
return CreateMessage(data, properties);
103104
}
104105

0 commit comments

Comments
 (0)