Skip to content

Commit b317df0

Browse files
authored
update docs to show the funciton overload usecase (#21)
1 parent 8f369e2 commit b317df0

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

docs/advanced-features.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This section covers the advanced capabilities of SemanticPluginForge:
1717
| Function Suppression | Hide entire functions from plugin consumers | Deprecating functions, conditional availability |
1818
| Parameter Suppression | Hide specific parameters while providing defaults | Simplifying interfaces, context injection |
1919
| CLR Type Support | Use any .NET class as a plugin | Legacy code integration, external libraries |
20-
| Function Name Override | Change function names without code modification | Better naming conventions, API versioning |
20+
| Function Name Override | Change function names without code modification | Better AI naming conventions, method overload disambiguation, API versioning |
2121
| Default Value Override | Set parameter defaults through metadata | Configuration-driven defaults, environment-specific values |
2222

2323
## Quick Examples
@@ -76,12 +76,39 @@ kernelBuilder.Plugins.AddFromClrTypeWithMetadata<DateUtility>("DateUtils");
7676
```csharp
7777
public FunctionMetadata? GetFunctionMetadata(KernelPlugin plugin, KernelFunctionMetadata metadata)
7878
{
79-
if (plugin.Name == "MyPlugin" && metadata.Name == "GetCurrentUsername")
79+
if (plugin.Name == "RandomPlugin")
8080
{
81-
return new FunctionMetadata(metadata.Name)
82-
{
83-
OverrideFunctionName = "GetUser"
84-
};
81+
// Handle function overloads by examining parameter signature
82+
if (metadata.Name == "Next")
83+
{
84+
// Different overrides based on parameter count
85+
var paramCount = metadata.Parameters.Count;
86+
87+
if (paramCount == 0)
88+
{
89+
return new FunctionMetadata(metadata.Name)
90+
{
91+
OverrideFunctionName = "GetRandomNumber",
92+
Description = "Generates a random non-negative integer"
93+
};
94+
}
95+
else if (paramCount == 1 && metadata.Parameters[0].Name == "maxValue")
96+
{
97+
return new FunctionMetadata(metadata.Name)
98+
{
99+
OverrideFunctionName = "GetRandomNumberWithMaxValue",
100+
Description = "Generates a random integer between 0 and maxValue (exclusive)"
101+
};
102+
}
103+
else if (paramCount == 2)
104+
{
105+
return new FunctionMetadata(metadata.Name)
106+
{
107+
OverrideFunctionName = "GetRandomNumberInRange",
108+
Description = "Generates a random integer between minValue and maxValue"
109+
};
110+
}
111+
}
85112
}
86113
return null;
87114
}

0 commit comments

Comments
 (0)