Class FunctionInvocation<T>
- java.lang.Object
-
- reactor.core.publisher.Mono<FunctionResult<T>>
-
- com.microsoft.semantickernel.orchestration.FunctionInvocation<T>
-
- Type Parameters:
T- The type of the result of the function invocation.
- All Implemented Interfaces:
org.reactivestreams.Publisher<FunctionResult<T>>,reactor.core.CorePublisher<FunctionResult<T>>
public class FunctionInvocation<T> extends reactor.core.publisher.Mono<FunctionResult<T>>
FunctionInvocationsupports fluent invocation of a function in the kernel.
-
-
Constructor Summary
Constructors Constructor Description FunctionInvocation(Kernel kernel, KernelFunction<?> function, ContextVariableType<T> resultType)Create a new function invocation.FunctionInvocation(Kernel kernel, KernelFunction<T> function)Create a new function invocation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FunctionInvocation<T>addKernelHook(KernelHook<?> hook)Add a kernel hook to the function invocation.FunctionInvocation<T>addKernelHooks(KernelHooks hooks)Add kernel hooks to the function invocation.voidsubscribe(reactor.core.CoreSubscriber<? super FunctionResult<T>> coreSubscriber)This method handles the reactive stream when the KernelFunction is invoked.FunctionInvocation<T>withArguments(KernelFunctionArguments arguments)Supply arguments to the function invocation.FunctionInvocation<T>withInvocationContext(InvocationContext invocationContext)Use an invocation context variable to supply the types, tool call behavior, prompt execution settings, and kernel hooks to the function invocation.FunctionInvocation<T>withPromptExecutionSettings(PromptExecutionSettings promptExecutionSettings)Supply prompt execution settings to the function invocation.<U> FunctionInvocation<U>withResultType(ContextVariableType<U> resultType)Supply the result type of function invocation.<U> FunctionInvocation<U>withResultType(Class<U> resultType)Supply the result type of function invocation.FunctionInvocation<T>withToolCallBehavior(ToolCallBehavior toolCallBehavior)Supply tool call behavior to the function invocation.FunctionInvocation<T>withTypeConverter(ContextVariableTypeConverter<?> typeConverter)Supply a type converter to the function invocation.FunctionInvocation<T>withTypes(ContextVariableTypes contextVariableTypes)Supply a context variable type to the function invocation.-
Methods inherited from class reactor.core.publisher.Mono
and, as, block, block, blockOptional, blockOptional, cache, cache, cache, cache, cache, cacheInvalidateIf, cacheInvalidateWhen, cacheInvalidateWhen, cancelOn, cast, checkpoint, checkpoint, checkpoint, concatWith, contextWrite, contextWrite, create, defaultIfEmpty, defer, deferContextual, deferWithContext, delay, delay, delayElement, delayElement, delaySubscription, delaySubscription, delaySubscription, delayUntil, dematerialize, doAfterSuccessOrError, doAfterTerminate, doFinally, doFirst, doOnCancel, doOnDiscard, doOnEach, doOnError, doOnError, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnSuccess, doOnSuccessOrError, doOnTerminate, elapsed, elapsed, empty, error, error, expand, expand, expandDeep, expandDeep, filter, filterWhen, first, first, firstWithSignal, firstWithSignal, firstWithValue, firstWithValue, flatMap, flatMapIterable, flatMapMany, flatMapMany, flux, from, fromCallable, fromCompletionStage, fromCompletionStage, fromDirect, fromFuture, fromFuture, fromFuture, fromFuture, fromRunnable, fromSupplier, handle, hasElement, hide, ignoreElement, ignoreElements, just, justOrEmpty, justOrEmpty, log, log, log, log, log, log, map, mapNotNull, materialize, mergeWith, metrics, name, never, ofType, onErrorComplete, onErrorComplete, onErrorComplete, onErrorContinue, onErrorContinue, onErrorContinue, onErrorMap, onErrorMap, onErrorMap, onErrorResume, onErrorResume, onErrorResume, onErrorReturn, onErrorReturn, onErrorReturn, onErrorStop, onTerminateDetach, or, publish, publishOn, repeat, repeat, repeat, repeat, repeatWhen, repeatWhenEmpty, repeatWhenEmpty, retry, retry, retryWhen, sequenceEqual, sequenceEqual, sequenceEqual, share, single, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscriberContext, subscriberContext, subscriberContext, subscribeWith, switchIfEmpty, tag, take, take, takeUntilOther, then, then, thenEmpty, thenMany, thenReturn, timed, timed, timeout, timeout, timeout, timeout, timeout, timeout, timestamp, timestamp, toFuture, toProcessor, toString, transform, transformDeferred, transformDeferredContextual, using, using, usingWhen, usingWhen, when, when, whenDelayError, whenDelayError, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipDelayError, zipWhen, zipWhen, zipWith, zipWith
-
-
-
-
Constructor Detail
-
FunctionInvocation
public FunctionInvocation(Kernel kernel, KernelFunction<T> function)
Create a new function invocation.- Parameters:
kernel- The kernel to invoke the function on.function- The function to invoke.
-
FunctionInvocation
public FunctionInvocation(Kernel kernel, KernelFunction<?> function, @Nullable ContextVariableType<T> resultType)
Create a new function invocation.- Parameters:
kernel- The kernel to invoke the function on.function- The function to invoke.resultType- The type of the result of the function invocation.
-
-
Method Detail
-
withArguments
public FunctionInvocation<T> withArguments(@Nullable KernelFunctionArguments arguments)
Supply arguments to the function invocation.- Parameters:
arguments- The arguments to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withResultType
public <U> FunctionInvocation<U> withResultType(ContextVariableType<U> resultType)
Supply the result type of function invocation.- Type Parameters:
U- The type of the result of the function invocation.- Parameters:
resultType- The arguments to supply to the function invocation.- Returns:
- A new
FunctionInvocationfor fluent chaining.
-
withResultType
public <U> FunctionInvocation<U> withResultType(Class<U> resultType)
Supply the result type of function invocation. Uses the global context variable types.- Type Parameters:
U- The type of the result of the function invocation.- Parameters:
resultType- The arguments to supply to the function invocation.- Returns:
- A new
FunctionInvocationfor fluent chaining.
-
addKernelHook
public FunctionInvocation<T> addKernelHook(@Nullable KernelHook<?> hook)
Add a kernel hook to the function invocation.- Parameters:
hook- The kernel hook to add.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
addKernelHooks
public FunctionInvocation<T> addKernelHooks(@Nullable KernelHooks hooks)
Add kernel hooks to the function invocation.- Parameters:
hooks- The kernel hooks to add.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withPromptExecutionSettings
public FunctionInvocation<T> withPromptExecutionSettings(@Nullable PromptExecutionSettings promptExecutionSettings)
Supply prompt execution settings to the function invocation.- Parameters:
promptExecutionSettings- The prompt execution settings to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withToolCallBehavior
public FunctionInvocation<T> withToolCallBehavior(@Nullable ToolCallBehavior toolCallBehavior)
Supply tool call behavior to the function invocation.- Parameters:
toolCallBehavior- The tool call behavior to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withTypeConverter
public FunctionInvocation<T> withTypeConverter(ContextVariableTypeConverter<?> typeConverter)
Supply a type converter to the function invocation.- Parameters:
typeConverter- The type converter to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withTypes
public FunctionInvocation<T> withTypes(ContextVariableTypes contextVariableTypes)
Supply a context variable type to the function invocation.- Parameters:
contextVariableTypes- The context variable types to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
withInvocationContext
public FunctionInvocation<T> withInvocationContext(@Nullable InvocationContext invocationContext)
Use an invocation context variable to supply the types, tool call behavior, prompt execution settings, and kernel hooks to the function invocation.- Parameters:
invocationContext- The invocation context to supply to the function invocation.- Returns:
- this
FunctionInvocationfor fluent chaining.
-
subscribe
public void subscribe(reactor.core.CoreSubscriber<? super FunctionResult<T>> coreSubscriber)
This method handles the reactive stream when the KernelFunction is invoked.- Specified by:
subscribein interfacereactor.core.CorePublisher<T>- Specified by:
subscribein classreactor.core.publisher.Mono<FunctionResult<T>>- Parameters:
coreSubscriber- The subscriber to subscribe to the function invocation.
-
-