Dependency injections
2024-09-13 -- Dependency injections for langgraph related stuff.
DI for langgraph is a little bit different since it's not always possible to pass arbitrary objects (like UOWs etc.)
through the config when building or invoking the graphs.
This module centralizes the default dependency injections used within langgraph nodes. This should make it easier to refactor in the future if necessary.
Note: For local testing, it IS possible to pass arbitrary objects through the config["configurable"] dict.
logger = logging.getLogger(__name__)
module-attribute
DependencyOverrides
Bases: TypedDict
github_adapter_getter
instance-attribute
github_parsing_uow_factory
instance-attribute
llm_provider
instance-attribute
qdrant_factory
instance-attribute
read_only_uow_factory
instance-attribute
tavily_client
instance-attribute
GithubAdapterGetterProtocol
Bases: Protocol
__call__
instance-attribute
LanggraphDependencies
github_parsing_uow
property
github_search_uow
property
llm_provider = llm_provider
instance-attribute
message_search_uow
property
read_only_uow
property
tavily_client = tavily_client
instance-attribute
__init__(llm_provider, tavily_client, read_only_uow_factory, qdrant_factory, github_adapter_getter, github_parsing_uow_factory, _allow_init=False)
get_github_adapter()
async
Get the user specific github adapter (using their api key) or return a default one.
Intended to act somewhat like a property, but requires async call for db access.
get_langgraph_dependencies(user_pk_id, deps_from_testing=None)
Set up dependency injections that will be available for any langgraph node to use.
Accessed via conf.di (where conf should be an instance of FullConfig).
NOTE: This is called at EVERY node, so initialization should be lazy where possible
| PARAMETER | DESCRIPTION |
|---|---|
user_pk_id
|
The user's primary key ID in the database. (E.g. for getting user specific api keys)
TYPE:
|
deps_from_testing
|
dictionary that can contain overrides to the default dependency injections used during testing.
TYPE:
|
initialize()
Initialize services for langgraph nodes.