Class FunctionCallMiddleware
The middleware that process function call message that both send to an agent or reply from an agent.
If the last message is Tool
Otherwise, the message will be sent to the inner agent. In this situation
if the reply from the inner agent is Tool
If the reply from the inner agent is Tool
When used as a streaming middleware, if the streaming reply from the inner agent is Tool
- Inheritance
-
Function
Call Middleware
- Implements
- Inherited Members
Constructors
FunctionCallMiddleware(IEnumerable<FunctionContract>?, IDictionary<string, Func<string, Task<string>>>?, string?)
public FunctionCallMiddleware(IEnumerable<FunctionContract>? functions = null, IDictionary<string, Func<string, Task<string>>>? functionMap = null, string? name = null)
Parameters
functions
IEnumerable<FunctionContract >functionMap
IDictionary<string, Func<string, Task<string>>>name
string
FunctionCallMiddleware(IEnumerable<AIFunction>, string?)
Create a new instance of Function
Parameters
functions
IEnumerable<AIFunction>function list
name
stringoptional middleware name. If not provided, the class name Function
Call will be used.Middleware
Properties
Name
the name of the middleware
Property Value
Methods
InvokeAsync(MiddlewareContext, IAgent, CancellationToken)
The method to invoke the middleware
public Task<IMessage> InvokeAsync(MiddlewareContext context, IAgent agent, CancellationToken cancellationToken = default)
Parameters
context
MiddlewareContext agent
IAgentcancellationToken
CancellationToken
Returns
InvokeAsync(MiddlewareContext, IStreamingAgent, CancellationToken)
The streaming version of Invoke
public IAsyncEnumerable<IMessage> InvokeAsync(MiddlewareContext context, IStreamingAgent agent, CancellationToken cancellationToken = default)
Parameters
context
MiddlewareContext agent
IStreamingAgent cancellationToken
CancellationToken