tools.dependency_injection
BaseContext
Base class for context classes.
This is the base class for defining various context types that may be used throughout the application. It serves as a parent for specific context classes.
ChatContext
ChatContext class that extends BaseContext.
This class is used to represent a chat context that holds a list of messages.
It inherits from BaseContext
and adds the messages
attribute.
Depends
Creates a dependency for injection based on the provided context or type.
Arguments:
x
- The context or dependency to be injected.
Returns:
A FastDepends object that will resolve the dependency for injection.
Field
Represents a description field for use in type annotations.
This class is used to store a description for an annotated field, often used for documenting or validating fields in a context or data model.
__init__
Initializes the Field with a description.
Arguments:
description
- The description text for the field.
inject_params
Injects parameters into a function, removing injected dependencies from its signature.
This function is used to modify a function by injecting dependencies and removing injected parameters from the function’s signature.
Arguments:
f
- The function to modify with dependency injection.
Returns:
The modified function with injected dependencies and updated signature.