Skip to content

Commit 5385723

Browse files
committed
[#19] Add XML Documentation Comments to the Flow, Mcp, Model Contexts
1 parent d17fa45 commit 5385723

11 files changed

Lines changed: 302 additions & 54 deletions

File tree

src/MaIN.Core/Hub/Contexts/ChatContext.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace MaIN.Core.Hub.Contexts;
1414

15-
public sealed class ChatContext : IChatBuilderEntryPoint, IChatMessageBuilder, IChatCompletionBuilder
15+
public sealed class ChatContext : IChatBuilderEntryPoint, IChatMessageBuilder, IChatConfigurationBuilder
1616
{
1717
private readonly IChatService _chatService;
1818
private bool _preProcess;
@@ -58,38 +58,38 @@ public IChatMessageBuilder EnableVisual()
5858
return this;
5959
}
6060

61-
public IChatCompletionBuilder WithInferenceParams(InferenceParams inferenceParams)
61+
public IChatConfigurationBuilder WithInferenceParams(InferenceParams inferenceParams)
6262
{
6363
_chat.InterferenceParams = inferenceParams;
6464
return this;
6565
}
6666

67-
public IChatCompletionBuilder WithTools(ToolsConfiguration toolsConfiguration)
67+
public IChatConfigurationBuilder WithTools(ToolsConfiguration toolsConfiguration)
6868
{
6969
_chat.ToolsConfiguration = toolsConfiguration;
7070
return this;
7171
}
7272

73-
public IChatCompletionBuilder WithMemoryParams(MemoryParams memoryParams)
73+
public IChatConfigurationBuilder WithMemoryParams(MemoryParams memoryParams)
7474
{
7575
_chat.MemoryParams = memoryParams;
7676
return this;
7777
}
7878

79-
public IChatCompletionBuilder Speak(TextToSpeechParams speechParams)
79+
public IChatConfigurationBuilder Speak(TextToSpeechParams speechParams)
8080
{
8181
_chat.Visual = false;
8282
_chat.TextToSpeechParams = speechParams;
8383
return this;
8484
}
8585

86-
public IChatCompletionBuilder WithBackend(BackendType backendType)
86+
public IChatConfigurationBuilder WithBackend(BackendType backendType)
8787
{
8888
_chat.Backend = backendType;
8989
return this;
9090
}
9191

92-
public IChatCompletionBuilder WithSystemPrompt(string systemPrompt)
92+
public IChatConfigurationBuilder WithSystemPrompt(string systemPrompt)
9393
{
9494
var message = new Message
9595
{
@@ -103,13 +103,13 @@ public IChatCompletionBuilder WithSystemPrompt(string systemPrompt)
103103
return this;
104104
}
105105

106-
public IChatCompletionBuilder WithMessage(string content)
106+
public IChatConfigurationBuilder WithMessage(string content)
107107
{
108108
_chat.Messages.Add(new Message { Role = "User", Content = content, Type = MessageType.LocalLLM, Time = DateTime.Now });
109109
return this;
110110
}
111111

112-
public IChatCompletionBuilder WithMessage(string content, byte[] image)
112+
public IChatConfigurationBuilder WithMessage(string content, byte[] image)
113113
{
114114
var message = new Message
115115
{
@@ -124,28 +124,28 @@ public IChatCompletionBuilder WithMessage(string content, byte[] image)
124124
return this;
125125
}
126126

127-
public IChatCompletionBuilder WithMessages(IEnumerable<Message> messages)
127+
public IChatConfigurationBuilder WithMessages(IEnumerable<Message> messages)
128128
{
129129
_chat.Messages.AddRange(messages);
130130
return this;
131131
}
132132

133-
public IChatCompletionBuilder WithFiles(List<FileStream> file, bool preProcess = false)
133+
public IChatConfigurationBuilder WithFiles(List<FileStream> file, bool preProcess = false)
134134
{
135135
_files = file.Select(f => new FileInfo { Name = Path.GetFileName(f.Name), StreamContent = f, Extension = Path.GetExtension(f.Name) })
136136
.ToList();
137137
_preProcess = preProcess;
138138
return this;
139139
}
140140

141-
public IChatCompletionBuilder WithFiles(List<FileInfo> file, bool preProcess = false)
141+
public IChatConfigurationBuilder WithFiles(List<FileInfo> file, bool preProcess = false)
142142
{
143143
_files = file;
144144
_preProcess = preProcess;
145145
return this;
146146
}
147147

148-
public IChatCompletionBuilder WithFiles(List<string> file, bool preProcess = false)
148+
public IChatConfigurationBuilder WithFiles(List<string> file, bool preProcess = false)
149149
{
150150
_files = file
151151
.Select(path =>
@@ -160,7 +160,7 @@ public IChatCompletionBuilder WithFiles(List<string> file, bool preProcess = fal
160160
return this;
161161
}
162162

163-
public IChatCompletionBuilder DisableCache()
163+
public IChatConfigurationBuilder DisableCache()
164164
{
165165
_chat.Properties.AddProperty(ServiceConstants.Properties.DisableCacheProperty);
166166
return this;
@@ -191,7 +191,7 @@ public async Task<ChatResult> CompleteAsync(
191191
return result;
192192
}
193193

194-
public async Task<IChatCompletionBuilder> FromExisting(string chatId)
194+
public async Task<IChatConfigurationBuilder> FromExisting(string chatId)
195195
{
196196
var existing = await _chatService.GetById(chatId);
197197
return existing == null

src/MaIN.Core/Hub/Contexts/FlowContext.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO.Compression;
22
using System.Text.Json;
3+
using MaIN.Core.Hub.Contexts.Interfaces.FlowContext;
34
using MaIN.Domain.Configuration;
45
using MaIN.Domain.Entities;
56
using MaIN.Domain.Entities.Agents;
@@ -10,7 +11,7 @@
1011

1112
namespace MaIN.Core.Hub.Contexts;
1213

13-
public sealed class FlowContext
14+
public sealed class FlowContext : IFlowContext
1415
{
1516
private readonly IAgentFlowService _flowService;
1617
private readonly IAgentService _agentService;
@@ -36,25 +37,25 @@ internal FlowContext(IAgentFlowService flowService, IAgentService agentService,
3637
_flow = existingFlow;
3738
}
3839

39-
public FlowContext WithId(string id)
40+
public IFlowContext WithId(string id)
4041
{
4142
_flow.Id = id;
4243
return this;
4344
}
4445

45-
public FlowContext WithName(string name)
46+
public IFlowContext WithName(string name)
4647
{
4748
_flow.Name = name;
4849
return this;
4950
}
5051

51-
public FlowContext WithDescription(string description)
52+
public IFlowContext WithDescription(string description)
5253
{
5354
_flow.Description = description;
5455
return this;
5556
}
5657

57-
public FlowContext Save(string path)
58+
public IFlowContext Save(string path)
5859
{
5960
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
6061

@@ -84,7 +85,7 @@ public FlowContext Save(string path)
8485
return this;
8586
}
8687

87-
public FlowContext Load(string path)
88+
public IFlowContext Load(string path)
8889
{
8990
var fileName = Path.GetFileNameWithoutExtension(path);
9091
string description = "";
@@ -133,7 +134,7 @@ public FlowContext Load(string path)
133134
return this;
134135
}
135136

136-
public FlowContext AddAgent(Agent agent)
137+
public IFlowContext AddAgent(Agent agent)
137138
{
138139
_flow.Agents.Add(agent);
139140
return this;
@@ -190,7 +191,7 @@ public async Task<ChatResult> ProcessAsync(Message message, bool translate = fal
190191
};
191192
}
192193

193-
public FlowContext AddAgents(IEnumerable<Agent> agents)
194+
public IFlowContext AddAgents(IEnumerable<Agent> agents)
194195
{
195196
foreach (var agent in agents)
196197
{
@@ -229,7 +230,7 @@ public async Task<List<AgentFlow>> GetAllFlows()
229230
}
230231

231232
// Static factory methods
232-
public async Task<FlowContext> FromExisting(string flowId)
233+
public async Task<IFlowContext> FromExisting(string flowId)
233234
{
234235
var existingFlow = await _flowService.GetFlowById(flowId);
235236
return existingFlow == null

src/MaIN.Core/Hub/Contexts/Interfaces/ChatContext/IChatBuilderEntryPoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public interface IChatBuilderEntryPoint : IChatActions
2626
/// Loads an existing chat session from the database using its unique identifier.
2727
/// </summary>
2828
/// <param name="chatId">The GUID of the existing chat.</param>
29-
Task<IChatCompletionBuilder> FromExisting(string chatId);
29+
Task<IChatConfigurationBuilder> FromExisting(string chatId);
3030
}

src/MaIN.Core/Hub/Contexts/Interfaces/ChatContext/IChatCompletionBuilder.cs renamed to src/MaIN.Core/Hub/Contexts/Interfaces/ChatContext/IChatConfigurationBuilder.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,70 @@
77

88
namespace MaIN.Core.Hub.Contexts.Interfaces.ChatContext;
99

10-
public interface IChatCompletionBuilder : IChatActions
10+
public interface IChatConfigurationBuilder : IChatActions
1111
{
1212
/// <summary>
1313
/// Configures low-level LLM parameters like temperature, context size, max tokens etc.
1414
/// </summary>
1515
/// <param name="inferenceParams">An object containing detailed inference settings for the LLM.</param>
16-
IChatCompletionBuilder WithInferenceParams(InferenceParams inferenceParams);
16+
IChatConfigurationBuilder WithInferenceParams(InferenceParams inferenceParams);
1717

1818
/// <summary>
1919
/// Attaches external tools/functions that the model can invoke during the conversation.
2020
/// </summary>
2121
/// <param name="toolsConfiguration">Configuration defining available tools and their execution modes.</param>
22-
IChatCompletionBuilder WithTools(ToolsConfiguration toolsConfiguration);
22+
IChatConfigurationBuilder WithTools(ToolsConfiguration toolsConfiguration);
2323

2424
/// <summary>
2525
/// Defines memory parameters for the chat.
2626
/// </summary>
2727
/// <param name="memoryParams">Configuration for how the chat context and memory should be handled.</param>
28-
IChatCompletionBuilder WithMemoryParams(MemoryParams memoryParams);
28+
IChatConfigurationBuilder WithMemoryParams(MemoryParams memoryParams);
2929

3030
/// <summary>
3131
/// Configures the session to use Text-to-Speech for the model's responses.
3232
/// </summary>
3333
/// <param name="speechParams">Parameters for the voice synthesis.</param>
34-
IChatCompletionBuilder Speak(TextToSpeechParams speechParams);
34+
IChatConfigurationBuilder Speak(TextToSpeechParams speechParams);
3535

3636
/// <summary>
3737
/// Sets the specific execution backend for the inference (e.g., Local, Cloud).
3838
/// </summary>
3939
/// <param name="backendType">The type of backend to be used for processing the request.</param>
40-
IChatCompletionBuilder WithBackend(BackendType backendType);
40+
IChatConfigurationBuilder WithBackend(BackendType backendType);
4141

4242
/// <summary>
4343
/// Sets a system-level prompt to guide the model's behavior, persona, and constraints.
4444
/// </summary>
4545
/// <param name="systemPrompt">The text content of the system instructions.</param>
46-
IChatCompletionBuilder WithSystemPrompt(string systemPrompt);
46+
IChatConfigurationBuilder WithSystemPrompt(string systemPrompt);
4747

4848
/// <summary>
4949
/// Attaches a list of files provided as <see cref="FileStream"/> to the message context.
5050
/// </summary>
5151
/// <param name="file">A list of open file streams to be uploaded or analyzed.</param>
5252
/// <param name="preProcess">If true, the files will be pre-processed (e.g., indexed) before sending.</param>
53-
IChatCompletionBuilder WithFiles(List<FileStream> file, bool preProcess = false);
53+
IChatConfigurationBuilder WithFiles(List<FileStream> file, bool preProcess = false);
5454

5555
/// <summary>
5656
/// Attaches a list of files provided as <see cref="FileInfo"/> objects to the message context.
5757
/// </summary>
5858
/// <param name="file">A list of file metadata and content references.</param>
5959
/// <param name="preProcess">If true, the files will be pre-processed (e.g., indexed) before sending.</param>
60-
IChatCompletionBuilder WithFiles(List<FileInfo> file, bool preProcess = false);
60+
IChatConfigurationBuilder WithFiles(List<FileInfo> file, bool preProcess = false);
6161

6262
/// <summary>
6363
/// Attaches a list of files from provided local system paths to the message context.
6464
/// </summary>
6565
/// <param name="file">A list of absolute or relative paths to the files.</param>
6666
/// <param name="preProcess">If true, the files will be pre-processed (e.g., indexed) before sending.</param>
67-
IChatCompletionBuilder WithFiles(List<string> file, bool preProcess = false);
67+
/// <returns>The builder instance implementing <see cref="IChatConfigurationBuilder"/> to enable method chaining.</returns>
68+
IChatConfigurationBuilder WithFiles(List<string> file, bool preProcess = false);
6869

6970
/// <summary>
7071
/// Disables the internal caching mechanism for the upcoming request.
7172
/// </summary>
72-
IChatCompletionBuilder DisableCache();
73+
IChatConfigurationBuilder DisableCache();
7374

7475
/// <summary>
7576
/// Sends the configured chat context to the service for completion.

src/MaIN.Core/Hub/Contexts/Interfaces/ChatContext/IChatMessageBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ public interface IChatMessageBuilder : IChatActions
1313
/// Adds a single text message to the chat context.
1414
/// </summary>
1515
/// <param name="content">The text content of the message.</param>
16-
IChatCompletionBuilder WithMessage(string content);
16+
IChatConfigurationBuilder WithMessage(string content);
1717

1818
/// <summary>
1919
/// Adds a message containing both text and image data.
2020
/// </summary>
2121
/// <param name="content">The text description or prompt.</param>
2222
/// <param name="image">The byte array containing image data.</param>
23-
IChatCompletionBuilder WithMessage(string content, byte[] image);
23+
IChatConfigurationBuilder WithMessage(string content, byte[] image);
2424

2525
/// <summary>
2626
/// Appends a collection of messages to the chat.
2727
/// </summary>
2828
/// <param name="messages">An enumerable list of message objects.</param>
29-
IChatCompletionBuilder WithMessages(IEnumerable<Message> messages);
29+
IChatConfigurationBuilder WithMessages(IEnumerable<Message> messages);
3030
}

0 commit comments

Comments
 (0)