Skip to content

Commit df01a7d

Browse files
committed
Improve XML docs
1 parent 6b2beb2 commit df01a7d

24 files changed

Lines changed: 587 additions & 33 deletions

ChatAIze.PluginApi/ActionResult.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
namespace ChatAIze.PluginApi;
44

55
/// <summary>
6-
/// Represents the result of an action execution, including its identifier, outcome value, and success flag.
6+
/// Serializable action result value object (id + result payload + success flag).
77
/// </summary>
8+
/// <remarks>
9+
/// <para>
10+
/// This type is primarily a convenience DTO for plugin authors (for example: returning a list of results from a custom tool/function).
11+
/// </para>
12+
/// <para>
13+
/// In ChatAIze.Chatbot, workflow execution produces results implementing <see cref="ChatAIze.Abstractions.Chat.IActionResult"/>.
14+
/// While this <see cref="ActionResult"/> record does not implement that interface, it intentionally mirrors the same shape and
15+
/// is safe to serialize.
16+
/// </para>
17+
/// </remarks>
818
public record ActionResult
919
{
1020
/// <summary>

ChatAIze.PluginApi/ChatFunction.cs

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,45 @@
77
namespace ChatAIze.PluginApi;
88

99
/// <summary>
10-
/// Represents a chatbot function implementation that includes its name, description, execution delegate, parameters, and behavioral flags.
10+
/// Convenience implementation of <see cref="IChatFunction"/> used to expose plugin capabilities as LLM tools.
1111
/// </summary>
12+
/// <remarks>
13+
/// <para>
14+
/// In ChatAIze.Chatbot, functions returned by <see cref="ChatAIze.Abstractions.Plugins.IChatbotPlugin.FunctionsCallback"/> become model-callable tools.
15+
/// When a tool call happens, the host invokes <see cref="IChatFunction.Callback"/> using
16+
/// <see cref="ChatAIze.Utilities.Extensions.DelegateExtensions.InvokeForStringResultAsync(Delegate, string, IFunctionContext?, CancellationToken)"/>.
17+
/// </para>
18+
/// <para>
19+
/// Parameter schema:
20+
/// <list type="bullet">
21+
/// <item><description>If <see cref="Parameters"/> is provided (non-null), the host uses it to build the JSON schema shown to the model.</description></item>
22+
/// <item><description>If <see cref="Parameters"/> is <see langword="null"/>, the schema is derived from <see cref="Callback"/> via reflection.</description></item>
23+
/// </list>
24+
/// </para>
25+
/// <para>
26+
/// If your delegate accepts injected parameters, prefer supplying an explicit <see cref="Parameters"/> list so injected parameters are not
27+
/// presented as user-provided inputs.
28+
/// Note: the current schema serializer excludes <see cref="CancellationToken"/> automatically, but it does not exclude
29+
/// <see cref="IFunctionContext"/>. If your callback accepts <see cref="IFunctionContext"/>, you should provide <see cref="Parameters"/> explicitly
30+
/// to avoid confusing tool schemas.
31+
/// </para>
32+
/// <para>
33+
/// When relying on reflection-based schemas, you can improve the model-visible descriptions and constraints by annotating your callback with:
34+
/// <list type="bullet">
35+
/// <item><description><see cref="DescriptionAttribute"/> on the method and/or parameters,</description></item>
36+
/// <item><description>data annotations such as <c>[Required]</c>, <c>[MinLength]</c>, <c>[MaxLength]</c>, <c>[StringLength]</c> on string parameters.</description></item>
37+
/// </list>
38+
/// </para>
39+
/// <para>
40+
/// Return values: if the callback returns a non-string value, the host serializes it to JSON for tool output using snake_case property names.
41+
/// </para>
42+
/// <para>
43+
/// Error handling (provider-specific):
44+
/// tool execution is considered successful by the OpenAI provider when the returned string does not start with <c>"Error:"</c>
45+
/// (case-insensitive). This convention is used to decide whether any tool call "succeeded" in a completion.
46+
/// For recoverable failures, prefer returning <c>"Error: ..."</c> instead of throwing, so the model can retry with corrected input.
47+
/// </para>
48+
/// </remarks>
1249
public class ChatFunction : IChatFunction
1350
{
1451
/// <summary>
@@ -21,8 +58,8 @@ public ChatFunction() { }
2158
/// </summary>
2259
/// <param name="callback">The delegate that contains the function logic.</param>
2360
/// <remarks>
24-
/// The function name is inferred from the delegate method name. If the method is decorated with a <see cref="DescriptionAttribute"/>,
25-
/// its description is used automatically.
61+
/// The function name is inferred from the delegate method name (using ChatAIze normalization).
62+
/// If the method is decorated with a <see cref="DescriptionAttribute"/>, its description is used automatically.
2663
/// </remarks>
2764
[SetsRequiredMembers]
2865
public ChatFunction(Delegate callback)
@@ -37,9 +74,9 @@ public ChatFunction(Delegate callback)
3774
/// </summary>
3875
/// <param name="name">The unique name of the function.</param>
3976
/// <param name="description">Optional description for the function.</param>
40-
/// <param name="requiresDoubleCheck">A flag indicating whether double confirmation is required before execution.</param>
77+
/// <param name="requiresDoubleCheck">A flag indicating whether the model should be asked to confirm by calling the function twice.</param>
4178
/// <param name="callback">The delegate that contains the function's logic.</param>
42-
/// <param name="parameters">Optional parameters expected by the function.</param>
79+
/// <param name="parameters">Optional explicit parameters expected by the function (controls schema generation).</param>
4380
[SetsRequiredMembers]
4481
public ChatFunction(
4582
string name,
@@ -56,12 +93,20 @@ public ChatFunction(
5693
}
5794

5895
/// <inheritdoc />
96+
/// <remarks>
97+
/// In ChatAIze.Chatbot the name is normalized to snake_case when exposed to the model.
98+
/// Choose a stable, unique name across all installed plugins.
99+
/// </remarks>
59100
public virtual required string Name { get; set; }
60101

61102
/// <inheritdoc />
62103
public virtual string? Description { get; set; }
63104

64105
/// <inheritdoc />
106+
/// <remarks>
107+
/// In the OpenAI and Gemini providers, enabling this flag causes an extra model round-trip:
108+
/// the model is instructed to call the function again to confirm intent before the callback is executed.
109+
/// </remarks>
65110
public virtual bool RequiresDoubleCheck { get; set; }
66111

67112
/// <inheritdoc />
@@ -70,6 +115,16 @@ public ChatFunction(
70115
/// <summary>
71116
/// Gets or sets the list of parameters expected by this function.
72117
/// </summary>
118+
/// <remarks>
119+
/// Provide this list when you want full control over:
120+
/// <list type="bullet">
121+
/// <item><description>names and descriptions shown to the model,</description></item>
122+
/// <item><description>which parameters are required,</description></item>
123+
/// <item><description>enum value lists,</description></item>
124+
/// <item><description>and avoiding injected parameters (for example <see cref="IFunctionContext"/>).</description></item>
125+
/// </list>
126+
/// When <see langword="null"/>, the host derives the schema from <see cref="Callback"/> parameters.
127+
/// </remarks>
73128
public virtual ICollection<IFunctionParameter>? Parameters { get; set; }
74129

75130
/// <inheritdoc />

ChatAIze.PluginApi/ChatbotPlugin.cs

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,39 @@
88
namespace ChatAIze.PluginApi;
99

1010
/// <summary>
11-
/// Represents a chatbot plugin implementation that provides settings, functions, actions, and conditions to extend chatbot capabilities.
11+
/// Convenience base implementation of <see cref="IChatbotPlugin"/> for ChatAIze.Chatbot plugins.
1212
/// </summary>
13+
/// <remarks>
14+
/// <para>
15+
/// In ChatAIze.Chatbot, plugins are loaded from a DLL in the <c>plugins</c> folder (or uploaded through the dashboard).
16+
/// The host discovers a plugin in this order:
17+
/// <list type="number">
18+
/// <item><description>a type implementing <see cref="IAsyncPluginLoader"/> (async factory),</description></item>
19+
/// <item><description>a type implementing <see cref="IPluginLoader"/> (sync factory),</description></item>
20+
/// <item><description>any non-abstract type implementing <see cref="IChatbotPlugin"/> (created via <c>Activator.CreateInstance</c>).</description></item>
21+
/// </list>
22+
/// </para>
23+
/// <para>
24+
/// A plugin instance is typically a singleton for the lifetime of the host process. Your callbacks and delegates can be invoked
25+
/// concurrently for multiple chats/users. Avoid storing per-user/per-chat state on the plugin instance; prefer using the
26+
/// supplied <see cref="IChatContext"/>, <see cref="IChatbotContext"/>, <see cref="IFunctionContext"/>, <see cref="IActionContext"/>,
27+
/// and <see cref="IConditionContext"/> objects.
28+
/// </para>
29+
/// <para>
30+
/// Settings in ChatAIze.Chatbot are stored in a single key/value dictionary (<see cref="IPluginSettings"/>). Because keys are shared
31+
/// across all plugins, use stable, globally-unique setting ids (for example: <c>"com.example.my_plugin:api_key"</c>).
32+
/// </para>
33+
/// </remarks>
1334
public class ChatbotPlugin : IChatbotPlugin, IEditableSettingsContainer
1435
{
1536
/// <summary>
1637
/// Initializes a new instance of the <see cref="ChatbotPlugin"/> class with default callbacks.
1738
/// </summary>
39+
/// <remarks>
40+
/// The default behavior of this type is "static": each callback returns the corresponding in-memory collection
41+
/// (<see cref="Settings"/>, <see cref="Functions"/>, <see cref="Actions"/>, <see cref="Conditions"/>).
42+
/// Override the callback properties if you need context-dependent definitions.
43+
/// </remarks>
1844
public ChatbotPlugin()
1945
{
2046
SettingsCallback ??= _ => ValueTask.FromResult((IReadOnlyCollection<ISetting>)Settings);
@@ -24,7 +50,7 @@ public ChatbotPlugin()
2450
}
2551

2652
/// <summary>
27-
/// Initializes a new instance of the <see cref="ChatbotPlugin"/> class with metadata and content.
53+
/// Initializes a new instance of the <see cref="ChatbotPlugin"/> class with metadata and initial collections.
2854
/// </summary>
2955
/// <param name="id">The unique identifier of the plugin.</param>
3056
/// <param name="title">The display title of the plugin.</param>
@@ -35,10 +61,18 @@ public ChatbotPlugin()
3561
/// <param name="version">Optional version information (defaults to 1.0.0.0).</param>
3662
/// <param name="releaseTime">Optional initial release timestamp.</param>
3763
/// <param name="lastUpdateTime">Optional timestamp of the most recent update.</param>
38-
/// <param name="settings">Optional collection of plugin-level settings.</param>
39-
/// <param name="functions">Optional collection of chatbot functions provided by the plugin.</param>
40-
/// <param name="actions">Optional collection of reusable function actions.</param>
41-
/// <param name="conditions">Optional collection of conditional rules used before function execution.</param>
64+
/// <param name="settings">Optional collection of plugin-level settings (rendered in the dashboard).</param>
65+
/// <param name="functions">Optional collection of chatbot functions (tools) provided by the plugin.</param>
66+
/// <param name="actions">Optional collection of reusable workflow actions provided by the plugin.</param>
67+
/// <param name="conditions">Optional collection of reusable workflow conditions provided by the plugin.</param>
68+
/// <remarks>
69+
/// In ChatAIze.Chatbot:
70+
/// <list type="bullet">
71+
/// <item><description><see cref="SettingsCallback"/> is used to render plugin settings in the dashboard.</description></item>
72+
/// <item><description><see cref="FunctionsCallback"/> is used to surface functions as LLM tools (and executed via <see cref="ChatAIze.Utilities.Extensions.DelegateExtensions"/> when <see cref="IChatFunction.Callback"/> is provided).</description></item>
73+
/// <item><description><see cref="ActionsCallback"/> / <see cref="ConditionsCallback"/> are used by the workflow engine.</description></item>
74+
/// </list>
75+
/// </remarks>
4276
[SetsRequiredMembers]
4377
public ChatbotPlugin(
4478
string id,
@@ -101,48 +135,87 @@ public ChatbotPlugin(
101135
/// <summary>
102136
/// Gets or sets the collection of settings exposed by the plugin.
103137
/// </summary>
138+
/// <remarks>
139+
/// In ChatAIze.Chatbot, settings are rendered in the dashboard and persisted as JSON under <see cref="ISetting.Id"/>.
140+
/// Prefer stable ids and prefix them with your plugin id to avoid collisions with other plugins.
141+
/// </remarks>
104142
public virtual ICollection<ISetting> Settings { get; set; } = [];
105143

106144
/// <summary>
107145
/// Gets or sets the collection of chatbot functions exposed by the plugin.
108146
/// </summary>
147+
/// <remarks>
148+
/// These functions are surfaced to the language model as callable tools.
149+
/// <para>
150+
/// In ChatAIze.Chatbot, a function is only executable if <see cref="IChatFunction.Callback"/> is set (otherwise the host falls back
151+
/// to a default callback intended for "integration functions" configured in the dashboard).
152+
/// </para>
153+
/// </remarks>
109154
public virtual ICollection<IChatFunction> Functions { get; set; } = [];
110155

111156
/// <summary>
112-
/// Gets or sets the collection of reusable function actions provided by the plugin.
157+
/// Gets or sets the collection of reusable workflow actions provided by the plugin.
113158
/// </summary>
159+
/// <remarks>
160+
/// Actions are building blocks used by ChatAIze.Chatbot "integration functions". They are not surfaced to the model directly.
161+
/// </remarks>
114162
public virtual ICollection<IFunctionAction> Actions { get; set; } = [];
115163

116164
/// <summary>
117-
/// Gets or sets the collection of preconditions that can be applied before function execution.
165+
/// Gets or sets the collection of reusable workflow conditions provided by the plugin.
118166
/// </summary>
167+
/// <remarks>
168+
/// Conditions can be attached to integration functions to allow/deny execution based on settings and chat context.
169+
/// </remarks>
119170
public virtual ICollection<IFunctionCondition> Conditions { get; set; } = [];
120171

121172
/// <inheritdoc />
173+
/// <remarks>
174+
/// In ChatAIze.Chatbot this callback is invoked while rendering the plugin settings page and when plugin settings change.
175+
/// It should be fast and should return deterministic ids.
176+
/// </remarks>
122177
public virtual Func<IChatbotContext, ValueTask<IReadOnlyCollection<ISetting>>> SettingsCallback { get; set; }
123178

124179
/// <inheritdoc />
180+
/// <remarks>
181+
/// In ChatAIze.Chatbot this callback is invoked when building the tool list for a completion. Return only functions that should be
182+
/// available for the current chat/user.
183+
/// </remarks>
125184
public virtual Func<IChatContext, ValueTask<IReadOnlyCollection<IChatFunction>>> FunctionsCallback { get; set; }
126185

127186
/// <inheritdoc />
187+
/// <remarks>
188+
/// In ChatAIze.Chatbot this callback is invoked when the dashboard or workflow engine needs the list of available actions.
189+
/// </remarks>
128190
public virtual Func<IChatbotContext, ValueTask<IReadOnlyCollection<IFunctionAction>>> ActionsCallback { get; set; }
129191

130192
/// <inheritdoc />
193+
/// <remarks>
194+
/// In ChatAIze.Chatbot this callback is invoked when the dashboard or workflow engine needs the list of available conditions.
195+
/// </remarks>
131196
public virtual Func<IChatbotContext, ValueTask<IReadOnlyCollection<IFunctionCondition>>> ConditionsCallback { get; set; }
132197

133198
/// <summary>
134-
/// Adds a setting to the plugin.
199+
/// Adds a setting definition to <see cref="Settings"/>.
135200
/// </summary>
136201
/// <param name="setting">The setting to add.</param>
202+
/// <remarks>
203+
/// Note: the method name contains a historical typo (<c>AddSetttng</c>). It is kept for backwards compatibility.
204+
/// You can also add settings via <see cref="IEditableSettingsContainer.Settings"/> or the extension methods in
205+
/// <see cref="ChatAIze.PluginApi.Settings.StringSettingExtensions"/>.
206+
/// </remarks>
137207
public virtual void AddSetttng(ISetting setting)
138208
{
139209
Settings.Add(setting);
140210
}
141211

142212
/// <summary>
143-
/// Adds a chatbot function to the plugin.
213+
/// Adds a chatbot function (tool) to <see cref="Functions"/>.
144214
/// </summary>
145215
/// <param name="function">The function to register.</param>
216+
/// <remarks>
217+
/// In ChatAIze.Chatbot, functions should provide a non-null <see cref="IChatFunction.Callback"/> for the host to execute them.
218+
/// </remarks>
146219
public virtual void AddFunction(IChatFunction function)
147220
{
148221
Functions.Add(function);
@@ -152,13 +225,27 @@ public virtual void AddFunction(IChatFunction function)
152225
/// Adds a chatbot function by wrapping a raw delegate.
153226
/// </summary>
154227
/// <param name="function">The function delegate to wrap.</param>
228+
/// <remarks>
229+
/// This overload creates a <see cref="ChatFunction"/> which:
230+
/// <list type="bullet">
231+
/// <item><description>derives <see cref="IChatFunction.Name"/> from the method name,</description></item>
232+
/// <item><description>uses <see cref="System.ComponentModel.DescriptionAttribute"/> (when present) as the description,</description></item>
233+
/// <item><description>stores the delegate as <see cref="IChatFunction.Callback"/> so the host can execute it.</description></item>
234+
/// </list>
235+
/// The delegate is invoked using ChatAIze's standard binding rules (snake_case arguments, optional <see cref="IFunctionContext"/> and <see cref="CancellationToken"/> injection).
236+
/// <para>
237+
/// For best results, prefer using a named method. If you pass a lambda or local function, the compiler-generated method name may be unstable;
238+
/// ChatAIze attempts to normalize such names but can throw if the pattern is not recognized. If you need full control over the tool name,
239+
/// construct a <see cref="ChatFunction"/> with an explicit <see cref="IChatFunction.Name"/> instead.
240+
/// </para>
241+
/// </remarks>
155242
public virtual void AddFunction(Delegate function)
156243
{
157244
Functions.Add(new ChatFunction(function));
158245
}
159246

160247
/// <summary>
161-
/// Adds a reusable action to the plugin.
248+
/// Adds a reusable workflow action to <see cref="Actions"/>.
162249
/// </summary>
163250
/// <param name="action">The function action to register.</param>
164251
public virtual void AddAction(IFunctionAction action)
@@ -167,7 +254,7 @@ public virtual void AddAction(IFunctionAction action)
167254
}
168255

169256
/// <summary>
170-
/// Adds a condition that can be used to restrict function execution.
257+
/// Adds a reusable workflow condition to <see cref="Conditions"/>.
171258
/// </summary>
172259
/// <param name="condition">The function condition to register.</param>
173260
public virtual void AddCondition(IFunctionCondition condition)

ChatAIze.PluginApi/Databases/DatabaseFilter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
namespace ChatAIze.PluginApi.Databases;
66

77
/// <summary>
8-
/// Represents a filter condition used in a database query, including the property, type of comparison, value, and optional modifiers.
8+
/// Concrete <see cref="IDatabaseFilter"/> used to describe a single filter predicate in a database query.
99
/// </summary>
10+
/// <remarks>
11+
/// Use this type with database APIs that accept <see cref="IDatabaseFilter"/> (for example via <see cref="ChatAIze.Abstractions.Databases.IDatabaseManager"/>).
12+
/// The meaning of <see cref="Property"/> and supported <see cref="FilterType"/> values depend on the underlying database/provider.
13+
/// </remarks>
1014
public record DatabaseFilter : IDatabaseFilter
1115
{
1216
/// <summary>

ChatAIze.PluginApi/Databases/DatabaseSorting.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
namespace ChatAIze.PluginApi.Databases;
66

77
/// <summary>
8-
/// Represents a sorting rule used to order database query results by a specified property and sort direction.
8+
/// Concrete <see cref="IDatabaseSorting"/> used to describe a sort order in a database query.
99
/// </summary>
10+
/// <remarks>
11+
/// Use this type with database APIs that accept <see cref="IDatabaseSorting"/> (for example via <see cref="ChatAIze.Abstractions.Databases.IDatabaseManager"/>).
12+
/// The meaning of <see cref="Property"/> and supported fields depend on the underlying database/provider.
13+
/// </remarks>
1014
public record DatabaseSorting : IDatabaseSorting
1115
{
1216
/// <summary>

0 commit comments

Comments
 (0)