Bring agentic system api to toolchain

Add adapter dependencies and resolve adapters using a topological sort
This commit is contained in:
Ashwin Bharambe 2024-08-04 10:53:38 -07:00
parent b0e5340645
commit be19b22391
31 changed files with 2740 additions and 25 deletions

View file

@ -8,7 +8,7 @@ import asyncio
import importlib
from typing import Any, Dict
from .datatypes import SourceAdapter
from .datatypes import Adapter, PassthroughApiAdapter, SourceAdapter
def instantiate_class_type(fully_qualified_name):
@ -18,9 +18,17 @@ def instantiate_class_type(fully_qualified_name):
# returns a class implementing the protocol corresponding to the ApiSurface
def instantiate_adapter(adapter: SourceAdapter, adapter_config: Dict[str, Any]):
def instantiate_adapter(
adapter: SourceAdapter, adapter_config: Dict[str, Any], deps: Dict[str, Adapter]
):
module = importlib.import_module(adapter.module)
config_type = instantiate_class_type(adapter.config_class)
config = config_type(**adapter_config)
return asyncio.run(module.get_adapter_impl(config))
return asyncio.run(module.get_adapter_impl(config, deps))
def instantiate_client(adapter: PassthroughApiAdapter, base_url: str):
module = importlib.import_module(adapter.module)
return asyncio.run(module.get_client_impl(base_url))