Types
conatus._types
¶
Types used throughout the library.
TypeOfType
module-attribute
¶
The type of a type hint.
Unfortunately, we have to include object here, since
some of the type hints we deal with (e.g. Annotated)
are a typing special form, meaning that their type
cannot be expressed in a Python file, at least as of Python 3.13.
ParamType
module-attribute
¶
ParamType = object | None
The type of a parameter.
This is essentially a more rigorous version of Any.
FunctionType
module-attribute
¶
FunctionType = (
FunctionType | MethodType | Callable[..., ParamType]
)
The type of a function.
Can be either a Python function or a method.
OptionalArg
module-attribute
¶
Optional argument type.
This is a type that can be either a value or the NotGiven
sentinel object.
CTUS_NOT_GIVEN
module-attribute
¶
CTUS_NOT_GIVEN = NotGiven()
Not given sentinel object, specific to our project.
SimpleDict
module-attribute
¶
SimpleDict = Mapping[
str, PrimitiveType | Mapping[str, PrimitiveType] | None
]
Simple dictionary type with max depth of 2.
ExpectedTaskInputType
module-attribute
¶
The type of the expected task input.
Possible values are:
"none": The task has no input."singleton": The task has a single input."list": The task has a list of inputs."dict": The task has a dictionary of inputs.
ExpectedTaskOutputType
module-attribute
¶
ExpectedTaskOutputType: TypeAlias = ExpectedTaskInputType
The type of the expected task output.
Existing
module-attribute
¶
Existing = Annotated[T, ExistingVariable]
An annotated type to indicate that a variable already exists.
In practice, Existing is a marker class that is used for an Action
or ActionBlueprint
to indicate that only existing
variables should be used. This means, in practice, that an AI will not be
able to pass a value for the variable, even if the type is JSON-compatible.
RawAction
module-attribute
¶
RawAction: TypeAlias = (
"Action | ActionBlueprint | ActionStarterPack | FunctionType"
)
A raw action that can be converted to an action.
Can be either:
- An instance of
Action - An instance of
ActionBlueprint - An instance of
ActionStarterPack - A function, as defined by the
FunctionTypetype.
IteratorAsyncFn
module-attribute
¶
IteratorAsyncFn = Callable[
..., Coroutine[ParamType, ParamType, AsyncIterator[T]]
]
A async function that yields an async iterator.
AsyncFn
module-attribute
¶
A async function that returns a value.
NotGiven
¶
FunctionDefinition
¶
Bases: TypedDict
A function definition mirroring OpenAI's FunctionDefinition.
parameters
instance-attribute
¶
The parameters of the function.
StructuredOutputDefinition
¶
ExistingVariable
¶
An annotation marker to indicate that a variable already exists.