ContextVariable<T> Class
- java.
lang. Object - com.
microsoft. semantickernel. contextvariables. ContextVariable<T>
- com.
Type Parameters
- T
the type of the context variable
public class ContextVariable<T>
A context variable wraps an arbitrary value and a ContextVariableType. ContextVariableType is used throughout the Semantic Kernel for passing arguments to functions and as function return types.
Constructor Summary
| Constructor | Description |
|---|---|
| ContextVariable(ContextVariableType<T> type, T value) |
Creates a new instance of the ContextVariable<T> class. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
static
Context |
<T,U>convert(U it, ContextVariableType<T> requestedResultType)
Converts the given value to the requested result type. |
|
static
Context |
<T,U>convert(U it, Class<T> requestedResultType, ContextVariableTypes contextVariableTypes)
Converts the given value to the requested result type. |
|
static
Context |
of(T value, ContextVariableTypeConverter<T> converter)
Creates a new instance of the ContextVariable<T> class. |
| U |
getValue(Class<U> clazz)
Get the value of the context variable. |
|
Context |
getType()
Get the type of the context variable. |
| T |
getValue()
Get the value of the context variable. |
| boolean |
isEmpty()
Returns true if the value of this |
|
static
Context |
of(CompletionsUsage x)
Convenience method for creating a |
|
static
Context |
of(String value)
Convenience method for creating a |
|
static
Context |
of(OffsetDateTime x)
Convenience method for creating a |
|
static
Context |
ofGlobalType(Object x)
Convenience method for creating a |
| java.lang.String |
toPromptString()
Use the given |
| java.lang.String |
toPromptString(ContextVariableTypes types)
Use the given |
| java.lang.String |
toPromptString(ContextVariableTypes types, ContextVariableTypeConverter<T> converter)
Use the given |
|
static
Context |
untypedOf(Object value, Class<?> clazz, ContextVariableTypes types)
Creates a new instance of the ContextVariable<T> class without using strong typing. |
Methods inherited from java.lang.Object
Constructor Details
ContextVariable
public ContextVariable(ContextVariableType
Creates a new instance of the ContextVariable<T> class.
Parameters:
Method Details
<T,U>convert
public static ContextVariable
Converts the given value to the requested result type.
Parameters:
Returns:
<T,U>convert
public static ContextVariable
Converts the given value to the requested result type. The ContextVariableTypes parameter is used to find the appropriate converter for the input value and the requested result type.
Parameters:
Returns:
of
public static ContextVariable
Creates a new instance of the ContextVariable<T> class.
Parameters:
Returns:
getValue
public U getValue(Class clazz)
Get the value of the context variable.
Parameters:
Returns:
getType
public ContextVariableType
Get the type of the context variable.
Returns:
getValue
public T getValue()
Get the value of the context variable.
Returns:
isEmpty
public boolean isEmpty()
Returns true if the value of this ContextVariable is null or empty.
Returns:
null or emptyof
public static ContextVariable
Convenience method for creating a ContextVariable from the given CompletionsUsage instance.
Parameters:
Returns:
of
public static ContextVariable
Convenience method for creating a ContextVariable from the given String instance.
Parameters:
Returns:
of
public static ContextVariable
Convenience method for creating a ContextVariable from the given OffsetDateTime instance.
Parameters:
Returns:
ofGlobalType
public static ContextVariable