[API Updates] Model / shield / memory-bank routing + agent persistence + support for private headers (#92)

This is yet another of those large PRs (hopefully we will have less and less of them as things mature fast). This one introduces substantial improvements and some simplifications to the stack.

Most important bits:

* Agents reference implementation now has support for session / turn persistence. The default implementation uses sqlite but there's also support for using Redis.

* We have re-architected the structure of the Stack APIs to allow for more flexible routing. The motivating use cases are:
  - routing model A to ollama and model B to a remote provider like Together
  - routing shield A to local impl while shield B to a remote provider like Bedrock
  - routing a vector memory bank to Weaviate while routing a keyvalue memory bank to Redis

* Support for provider specific parameters to be passed from the clients. A client can pass data using `x_llamastack_provider_data` parameter which can be type-checked and provided to the Adapter implementations.
This commit is contained in:
Ashwin Bharambe 2024-09-23 14:22:22 -07:00 committed by GitHub
parent 8bf8c07eb3
commit ec4fc800cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
130 changed files with 9701 additions and 11227 deletions

View file

@ -112,7 +112,9 @@ class StackBuild(Subcommand):
to_write = json.loads(json.dumps(build_config.dict(), cls=EnumEncoder))
f.write(yaml.dump(to_write, sort_keys=False))
build_image(build_config, build_file_path)
return_code = build_image(build_config, build_file_path)
if return_code != 0:
return
cprint(
f"Build spec configuration saved at {str(build_file_path)}",
@ -125,7 +127,7 @@ class StackBuild(Subcommand):
else (f"llamastack-{build_config.name}")
)
cprint(
f"You may now run `llama stack configure {configure_name}` or `llama stack configure {str(build_file_path)}`",
f"You can now run `llama stack configure {configure_name}`",
color="green",
)
@ -160,7 +162,11 @@ class StackBuild(Subcommand):
def _run_stack_build_command(self, args: argparse.Namespace) -> None:
import yaml
from llama_stack.distribution.distribution import Api, api_providers
from llama_stack.distribution.distribution import (
Api,
api_providers,
builtin_automatically_routed_apis,
)
from llama_stack.distribution.utils.dynamic import instantiate_class_type
from prompt_toolkit import prompt
from prompt_toolkit.validation import Validator
@ -213,8 +219,15 @@ class StackBuild(Subcommand):
)
providers = dict()
all_providers = api_providers()
routing_table_apis = set(
x.routing_table_api for x in builtin_automatically_routed_apis()
)
for api in Api:
all_providers = api_providers()
if api in routing_table_apis:
continue
providers_for_api = all_providers[api]
api_provider = prompt(