mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-04 12:07:34 +00:00
bunch more work to make adapters work
This commit is contained in:
parent
68f3db62e9
commit
c4fe72c3a3
20 changed files with 461 additions and 173 deletions
|
@ -30,7 +30,27 @@ def instantiate_provider(
|
|||
return asyncio.run(module.get_provider_impl(config, deps))
|
||||
|
||||
|
||||
def instantiate_client(provider_spec: RemoteProviderSpec, base_url: str):
|
||||
def instantiate_client(
|
||||
provider_spec: RemoteProviderSpec, provider_config: Dict[str, Any]
|
||||
):
|
||||
module = importlib.import_module(provider_spec.module)
|
||||
|
||||
return asyncio.run(module.get_client_impl(base_url))
|
||||
adapter = provider_spec.adapter
|
||||
if adapter is not None:
|
||||
if "adapter" not in provider_config:
|
||||
raise ValueError(
|
||||
f"Adapter is specified but not present in provider config: {provider_config}"
|
||||
)
|
||||
adapter_config = provider_config["adapter"]
|
||||
|
||||
config_type = instantiate_class_type(adapter.config_class)
|
||||
if not issubclass(config_type, RemoteProviderConfig):
|
||||
raise ValueError(
|
||||
f"Config class {adapter.config_class} does not inherit from RemoteProviderConfig"
|
||||
)
|
||||
|
||||
config = config_type(**adapter_config)
|
||||
else:
|
||||
config = RemoteProviderConfig(**provider_config)
|
||||
|
||||
return asyncio.run(module.get_adapter_impl(config))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue