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
{{ message }}
Repository navigation
Commit 9da9b38
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: dotnet/src/SemanticKernel.Abstractions/Functions/KernelFunctionAttribute.cs
+46-12Lines changed: 46 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@
10
10
namespaceMicrosoft.SemanticKernel;
11
11
12
12
/// <summary>
13
-
/// Specifies that a method on a class imported as a plugin with should be included as a <see cref="KernelFunction"/>.
13
+
/// Specifies that a method on a class imported as a plugin should be included as a <see cref="KernelFunction"/> in the resulting <see cref="KernelPlugin"/>.
14
14
/// </summary>
15
15
/// <remarks>
16
16
/// <para>
17
-
/// When the system imports functions from an object, it searches all public methods tagged with this attribute.
17
+
/// When the system imports functions from an object, it searches for all public methods tagged with this attribute.
18
18
/// If a method is not tagged with this attribute, it may still be imported directly via a <see cref="Delegate"/>
19
19
/// or <see cref="MethodInfo"/> referencing the method directly.
/// Functions may have any number of parameters. A given method function may declare at
30
-
/// most one parameter of each of these types - <see cref="Kernel"/>, <see cref="KernelArguments"/>,
31
-
/// <see cref="CancellationToken"/>, <see cref="CultureInfo"/>, <see cref="ILogger"/> or <see cref="ILoggerFactory"/>.
32
-
/// Parameters are populated based on a arguments of the same name. If no argument of the given name is present, but
33
-
/// a default value was specified via either a <see cref="DefaultValueAttribute"/> or an optional value in the signature,
34
-
/// that default value is used instead. If no default value was specified and it's the first parameter, the "input"
35
-
/// argument will be used. Otherwise, if no value is available, the invocation will fail.
29
+
/// Functions may have any number of parameters. In general, arguments to parameters are supplied via the <see cref="KernelArguments"/>
30
+
/// used to invoke the function, with the arguments matched by name to the parameters of the method. If no argument of the given name
31
+
/// is present, but a default value was specified in the method's definition, that default value will be used. If the argument value in
32
+
/// <see cref="KernelArguments"/> is not of the same type as the parameter, the system will attempt to convert the value to the parameter's
33
+
/// type using a <see cref="TypeConverter"/>.
36
34
/// </para>
37
35
/// <para>
38
-
/// For non-string parameters, the argument value is automatically converted to the appropriate type to be passed
39
-
/// in based on the <see cref="TypeConverter"/> for the specified type. Similarly, return values are automatically converted
40
-
/// back to strings via the associated <see cref="TypeConverter"/>.
36
+
/// However, parameters of the following types are treated specially and are supplied from a source other than from the arguments dictionary:
37
+
/// <list type="table">
38
+
/// <item>
39
+
/// <term><see cref="Kernel"/></term>
40
+
/// <description>The <see cref="Kernel"/> supplied when invoking the function.</description>
41
+
/// </item>
42
+
/// <item>
43
+
/// <term><see cref="KernelArguments"/></term>
44
+
/// <description>The <see cref="KernelArguments"/> supplied when invoking the function.</description>
45
+
/// </item>
46
+
/// <item>
47
+
/// <term><see cref="KernelFunction"/></term>
48
+
/// <description>The <see cref="KernelFunction"/> that represents this function being invoked.</description>
49
+
/// </item>
50
+
/// <item>
51
+
/// <term><see cref="CancellationToken"/></term>
52
+
/// <description>The <see cref="CancellationToken"/> supplied when invoking the function.</description>
53
+
/// </item>
54
+
/// <item>
55
+
/// <term><see cref="CultureInfo"/> or <see cref="IFormatProvider"/></term>
56
+
/// <description>The result of <see cref="Kernel.Culture"/> from the <see cref="Kernel"/> used when invoking the function.</description>
57
+
/// </item>
58
+
/// <item>
59
+
/// <term><see cref="ILoggerFactory"/> or <see cref="ILogger"/></term>
60
+
/// <description>The result of <see cref="Kernel.LoggerFactory"/> from the <see cref="Kernel"/> (or an <see cref="ILogger"/> created from it) used when invoking the function.</description>
61
+
/// </item>
62
+
/// <item>
63
+
/// <term><see cref="IAIServiceSelector"/></term>
64
+
/// <description>The result of <see cref="Kernel.ServiceSelector"/> from the <see cref="Kernel"/> used when invoking the function.</description>
65
+
/// </item>
66
+
/// </list>
67
+
/// </para>
68
+
/// <para>
69
+
/// Arguments may also be fulfilled from the associated <see cref="Kernel"/>'s <see cref="Kernel.Services"/> service provider. If a parameter is attributed
70
+
/// with <see cref="FromKernelServicesAttribute"/>, the system will attempt to resolve the parameter by querying the service provider for a service of the
71
+
/// parameter's type. If the service provider does not contain a service of the parameter's type and the parameter is not optional, the invocation will fail.
72
+
/// </para>
73
+
/// <para>
74
+
/// If no value can be derived from any of these means for all parameters, the invocation will fail.
0 commit comments