You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ChatAIze.PluginApi/ChatFunction.cs
+60-5Lines changed: 60 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,45 @@
7
7
namespaceChatAIze.PluginApi;
8
8
9
9
/// <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.
11
11
/// </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
/// <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>
12
49
publicclassChatFunction:IChatFunction
13
50
{
14
51
/// <summary>
@@ -21,8 +58,8 @@ public ChatFunction() { }
21
58
/// </summary>
22
59
/// <param name="callback">The delegate that contains the function logic.</param>
23
60
/// <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.
26
63
/// </remarks>
27
64
[SetsRequiredMembers]
28
65
publicChatFunction(Delegatecallback)
@@ -37,9 +74,9 @@ public ChatFunction(Delegate callback)
37
74
/// </summary>
38
75
/// <param name="name">The unique name of the function.</param>
39
76
/// <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>
41
78
/// <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>
43
80
[SetsRequiredMembers]
44
81
publicChatFunction(
45
82
stringname,
@@ -56,12 +93,20 @@ public ChatFunction(
56
93
}
57
94
58
95
/// <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>
59
100
publicvirtualrequiredstringName{get;set;}
60
101
61
102
/// <inheritdoc />
62
103
publicvirtualstring?Description{get;set;}
63
104
64
105
/// <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>
65
110
publicvirtualboolRequiresDoubleCheck{get;set;}
66
111
67
112
/// <inheritdoc />
@@ -70,6 +115,16 @@ public ChatFunction(
70
115
/// <summary>
71
116
/// Gets or sets the list of parameters expected by this function.
72
117
/// </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.
Copy file name to clipboardExpand all lines: ChatAIze.PluginApi/ChatbotPlugin.cs
+99-12Lines changed: 99 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,39 @@
8
8
namespaceChatAIze.PluginApi;
9
9
10
10
/// <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.
12
12
/// </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
/// <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>
42
76
[SetsRequiredMembers]
43
77
publicChatbotPlugin(
44
78
stringid,
@@ -101,48 +135,87 @@ public ChatbotPlugin(
101
135
/// <summary>
102
136
/// Gets or sets the collection of settings exposed by the plugin.
103
137
/// </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.
@@ -152,13 +225,27 @@ public virtual void AddFunction(IChatFunction function)
152
225
/// Adds a chatbot function by wrapping a raw delegate.
153
226
/// </summary>
154
227
/// <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>
155
242
publicvirtualvoidAddFunction(Delegatefunction)
156
243
{
157
244
Functions.Add(newChatFunction(function));
158
245
}
159
246
160
247
/// <summary>
161
-
/// Adds a reusable action to the plugin.
248
+
/// Adds a reusable workflow action to <see cref="Actions"/>.
162
249
/// </summary>
163
250
/// <param name="action">The function action to register.</param>
164
251
publicvirtualvoidAddAction(IFunctionActionaction)
@@ -167,7 +254,7 @@ public virtual void AddAction(IFunctionAction action)
167
254
}
168
255
169
256
/// <summary>
170
-
/// Adds a condition that can be used to restrict function execution.
257
+
/// Adds a reusable workflow condition to <see cref="Conditions"/>.
171
258
/// </summary>
172
259
/// <param name="condition">The function condition to register.</param>
Copy file name to clipboardExpand all lines: ChatAIze.PluginApi/Databases/DatabaseFilter.cs
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,12 @@
5
5
namespaceChatAIze.PluginApi.Databases;
6
6
7
7
/// <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.
9
9
/// </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.
Copy file name to clipboardExpand all lines: ChatAIze.PluginApi/Databases/DatabaseSorting.cs
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,12 @@
5
5
namespaceChatAIze.PluginApi.Databases;
6
6
7
7
/// <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.
9
9
/// </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.
0 commit comments