Gets the KernelPlugins instance.
Gets the ServiceProvider instance.
Adds a plugin to the kernel.
The plugin to add.
The kernel.
Adds a service to the kernel.
The kernel.
Invokes a KernelFunction.
The parameters for the kernel function.
Optionalargs?: KernelArguments<Schema, Args>The arguments to pass to the kernel function (optional).
OptionalexecutionSettings?: The execution settings to pass to the kernel function (optional).
The kernel function to invoke.
The result of the KernelFunction.
Invokes a prompt.
Prompt to invoke.
Optionalparams: {The parameters for the prompt.
The result of the prompt invocation.
Invokes a streaming prompt.
Prompt to invoke.
Optionalparams: {The parameters for the prompt.
A stream of ChatResponseUpdate objects.
Internal method to handle function invocation with filters.
Internal method to handle prompt rendering with filters.
Adds a function invocation filter to the kernel. These filters allow you to intercept and modify function execution operations using a middleware pattern. Filters are executed in registration order.
The callback function that will be invoked when a function is executed. This function receives a KernelFunctionInvocationContext and a next function. Call next(context) to continue to the next filter or actual function execution. Omit calling next() to short-circuit the pipeline.
// Add a performance monitoring filter
kernel.useFunctionInvocation(async (context, next) => {
const start = Date.now();
console.log(`Starting: ${context.function.metadata.name}`);
await next(context);
const duration = Date.now() - start;
console.log(`Completed ${context.function.metadata.name} in ${duration}ms`);
});
// Add an error handling filter
kernel.useFunctionInvocation(async (context, next) => {
try {
await next(context);
} catch (error) {
console.error(`Function ${context.function.metadata.name} failed:`, error);
throw error;
}
});
Adds a prompt rendering filter to the kernel. These filters allow you to intercept and modify prompt rendering operations using a middleware pattern. Filters are executed in registration order.
The callback function that will be invoked when a prompt is rendered. This function receives a PromptRenderContext and a next function. Call next(context) to continue to the next filter or actual prompt rendering. Omit calling next() to short-circuit the pipeline.
// Add a logging filter
kernel.usePromptRender(async (context, next) => {
console.log('Rendering prompt for:', context.function.metadata.name);
await next(context);
console.log('Rendered prompt:', context.renderedPrompt);
});
// Add a prompt modification filter
kernel.usePromptRender(async (context, next) => {
await next(context);
if (context.renderedPrompt) {
context.renderedPrompt += '\nPlease provide a helpful response.';
}
});
Represents a kernel.