11using MaIN . Core . Hub . Contexts . Interfaces . AgentContext ;
2+ using MaIN . Core . Hub . Utils ;
23using MaIN . Domain . Configuration ;
34using MaIN . Domain . Entities ;
45using MaIN . Domain . Entities . Agents ;
56using MaIN . Domain . Entities . Agents . AgentSource ;
6- using MaIN . Domain . Models ;
7- using MaIN . Domain . Models . Abstract ;
8- using MaIN . Services . Services . Abstract ;
9- using MaIN . Services . Services . Models ;
10- using MaIN . Core . Hub . Utils ;
117using MaIN . Domain . Entities . Agents . Knowledge ;
128using MaIN . Domain . Entities . Tools ;
139using MaIN . Domain . Exceptions . Agents ;
14- using MaIN . Domain . Exceptions . Models ;
10+ using MaIN . Domain . Models ;
11+ using MaIN . Domain . Models . Abstract ;
1512using MaIN . Services . Constants ;
13+ using MaIN . Services . Services . Abstract ;
14+ using MaIN . Services . Services . Models ;
1615
1716namespace MaIN . Core . Hub . Contexts ;
1817
@@ -63,8 +62,8 @@ internal AgentContext(IAgentService agentService, Agent existingAgent)
6362 public async Task < Agent ? > GetAgentById ( string id ) => await _agentService . GetAgentById ( id ) ;
6463 public async Task Delete ( ) => await _agentService . DeleteAgent ( _agent . Id ) ;
6564 public async Task < bool > Exists ( ) => await _agentService . AgentExists ( _agent . Id ) ;
66-
67-
65+
66+
6867 public IAgentConfigurationBuilder WithModel ( string model )
6968 {
7069 _agent . Model = model ;
@@ -85,18 +84,18 @@ public async Task<IAgentContextExecutor> FromExisting(string agentId)
8584 {
8685 throw new AgentNotFoundException ( agentId ) ;
8786 }
88-
87+
8988 var context = new AgentContext ( _agentService , existingAgent ) ;
9089 context . LoadExistingKnowledgeIfExists ( ) ;
9190 return context ;
9291 }
93-
92+
9493 public IAgentConfigurationBuilder WithInitialPrompt ( string prompt )
9594 {
9695 _agent . Context . Instruction = prompt ;
9796 return this ;
9897 }
99-
98+
10099 public IAgentConfigurationBuilder WithId ( string id )
101100 {
102101 _agent . Id = id ;
@@ -130,7 +129,7 @@ public IAgentConfigurationBuilder WithSource(IAgentSource source, AgentSourceTyp
130129 } ;
131130 return this ;
132131 }
133-
132+
134133 public IAgentConfigurationBuilder WithName ( string name )
135134 {
136135 _agent . Name = name ;
@@ -152,7 +151,7 @@ public IAgentConfigurationBuilder WithMcpConfig(Mcp mcpConfig)
152151 _agent . Context . McpConfig = mcpConfig ;
153152 return this ;
154153 }
155-
154+
156155 public IAgentConfigurationBuilder WithInferenceParams ( InferenceParams inferenceParams )
157156 {
158157 _inferenceParams = inferenceParams ;
@@ -183,7 +182,7 @@ public IAgentConfigurationBuilder WithKnowledge(KnowledgeBuilder knowledge)
183182 _knowledge = knowledge . ForAgent ( _agent ) . Build ( ) ;
184183 return this ;
185184 }
186-
185+
187186 public IAgentConfigurationBuilder WithKnowledge ( Knowledge knowledge )
188187 {
189188 _knowledge = knowledge ;
@@ -198,7 +197,7 @@ public IAgentConfigurationBuilder WithInMemoryKnowledge(Func<KnowledgeBuilder, K
198197 _knowledge = knowledgeConfig ( builder ) . Build ( ) ;
199198 return this ;
200199 }
201-
200+
202201 public IAgentConfigurationBuilder WithBehaviour ( string name , string instruction )
203202 {
204203 _agent . Behaviours ??= new Dictionary < string , string > ( ) ;
@@ -233,7 +232,7 @@ public IAgentConfigurationBuilder WithTools(ToolsConfiguration toolsConfiguratio
233232 _agent . ToolsConfiguration = toolsConfiguration ;
234233 return this ;
235234 }
236-
235+
237236 internal void LoadExistingKnowledgeIfExists ( )
238237 {
239238 _knowledge ??= new Knowledge ( _agent ) ;
@@ -247,7 +246,7 @@ internal void LoadExistingKnowledgeIfExists()
247246 Console . WriteLine ( "Knowledge cannot be loaded - new one will be created" ) ;
248247 }
249248 }
250-
249+
251250 public async Task < ChatResult > ProcessAsync ( Chat chat , bool translate = false )
252251 {
253252 if ( _knowledge == null )
@@ -265,7 +264,7 @@ public async Task<ChatResult> ProcessAsync(Chat chat, bool translate = false)
265264 CreatedAt = DateTime . Now
266265 } ;
267266 }
268-
267+
269268 public async Task < ChatResult > ProcessAsync (
270269 string message ,
271270 bool translate = false ,
@@ -294,8 +293,8 @@ public async Task<ChatResult> ProcessAsync(
294293 CreatedAt = DateTime . Now
295294 } ;
296295 }
297-
298- public async Task < ChatResult > ProcessAsync ( Message message ,
296+
297+ public async Task < ChatResult > ProcessAsync ( Message message ,
299298 bool translate = false ,
300299 Func < LLMTokenValue , Task > ? tokenCallback = null ,
301300 Func < ToolInvocation , Task > ? toolCallback = null )
@@ -306,7 +305,7 @@ public async Task<ChatResult> ProcessAsync(Message message,
306305 }
307306 var chat = await _agentService . GetChatByAgent ( _agent . Id ) ;
308307 chat . Messages . Add ( message ) ;
309- var result = await _agentService . Process ( chat , _agent . Id , _knowledge , translate , tokenCallback , toolCallback ) ; ;
308+ var result = await _agentService . Process ( chat , _agent . Id , _knowledge , translate , tokenCallback , toolCallback ) ;
310309 var messageResult = result . Messages . LastOrDefault ( ) ! ;
311310 return new ChatResult ( )
312311 {
@@ -316,7 +315,7 @@ public async Task<ChatResult> ProcessAsync(Message message,
316315 CreatedAt = DateTime . Now
317316 } ;
318317 }
319-
318+
320319 public async Task < ChatResult > ProcessAsync (
321320 IEnumerable < Message > messages ,
322321 bool translate = false ,
@@ -335,7 +334,7 @@ public async Task<ChatResult> ProcessAsync(
335334 chat . Messages . Add ( systemMsg ) ;
336335 }
337336 chat . Messages . AddRange ( messages ) ;
338- var result = await _agentService . Process ( chat , _agent . Id , _knowledge , translate , tokenCallback , toolCallback ) ; ;
337+ var result = await _agentService . Process ( chat , _agent . Id , _knowledge , translate , tokenCallback , toolCallback ) ;
339338 var messageResult = result . Messages . LastOrDefault ( ) ! ;
340339 return new ChatResult ( )
341340 {
@@ -353,7 +352,7 @@ public static async Task<AgentContext> FromExisting(IAgentService agentService,
353352 {
354353 throw new AgentNotFoundException ( agentId ) ;
355354 }
356-
355+
357356 var context = new AgentContext ( agentService , existingAgent ) ;
358357 context . LoadExistingKnowledgeIfExists ( ) ;
359358 return context ;
@@ -363,8 +362,8 @@ public static async Task<AgentContext> FromExisting(IAgentService agentService,
363362public static class AgentExtensions
364363{
365364 public static async Task < ChatResult > ProcessAsync (
366- this Task < AgentContext > agentTask ,
367- string message ,
365+ this Task < AgentContext > agentTask ,
366+ string message ,
368367 bool translate = false )
369368 {
370369 var agent = await agentTask ;
0 commit comments