mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-06 04:34:57 +00:00
feat: Updating files/content response to return additional fields
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
e12524af85
commit
a19c16428f
143 changed files with 6907 additions and 15104 deletions
|
@ -82,8 +82,7 @@ def wait_for_server_ready(base_url: str, timeout: int = 30, process: subprocess.
|
|||
return False
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def provider_data():
|
||||
def get_provider_data():
|
||||
# TODO: this needs to be generalized so each provider can have a sample provider data just
|
||||
# like sample run config on which we can do replace_env_vars()
|
||||
keymap = {
|
||||
|
@ -178,8 +177,19 @@ def skip_if_no_model(request):
|
|||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def llama_stack_client(request, provider_data):
|
||||
config = request.config.getoption("--stack-config")
|
||||
def llama_stack_client(request):
|
||||
# ideally, we could do this in session start given all the complex logs during initialization
|
||||
# don't clobber the test one-liner outputs. however, this also means all tests in a sub-directory
|
||||
# would be forced to use llama_stack_client, which is not what we want.
|
||||
print("\ninstantiating llama_stack_client")
|
||||
start_time = time.time()
|
||||
client = instantiate_llama_stack_client(request.session)
|
||||
print(f"llama_stack_client instantiated in {time.time() - start_time:.3f}s")
|
||||
return client
|
||||
|
||||
|
||||
def instantiate_llama_stack_client(session):
|
||||
config = session.config.getoption("--stack-config")
|
||||
if not config:
|
||||
config = get_env_or_fail("LLAMA_STACK_CONFIG")
|
||||
|
||||
|
@ -212,13 +222,13 @@ def llama_stack_client(request, provider_data):
|
|||
print(f"Server is ready at {base_url}")
|
||||
|
||||
# Store process for potential cleanup (pytest will handle termination at session end)
|
||||
request.session._llama_stack_server_process = server_process
|
||||
session._llama_stack_server_process = server_process
|
||||
else:
|
||||
print(f"Port {port} is already in use, assuming server is already running...")
|
||||
|
||||
return LlamaStackClient(
|
||||
base_url=base_url,
|
||||
provider_data=provider_data,
|
||||
provider_data=get_provider_data(),
|
||||
timeout=int(os.environ.get("LLAMA_STACK_CLIENT_TIMEOUT", "30")),
|
||||
)
|
||||
|
||||
|
@ -228,7 +238,7 @@ def llama_stack_client(request, provider_data):
|
|||
if parsed_url.scheme and parsed_url.netloc:
|
||||
return LlamaStackClient(
|
||||
base_url=config,
|
||||
provider_data=provider_data,
|
||||
provider_data=get_provider_data(),
|
||||
)
|
||||
except Exception:
|
||||
# If URL parsing fails, treat as non-URL config
|
||||
|
@ -243,7 +253,7 @@ def llama_stack_client(request, provider_data):
|
|||
|
||||
client = LlamaStackAsLibraryClient(
|
||||
config,
|
||||
provider_data=provider_data,
|
||||
provider_data=get_provider_data(),
|
||||
skip_logger_removal=True,
|
||||
)
|
||||
if not client.initialize():
|
||||
|
@ -258,8 +268,17 @@ def openai_client(client_with_models):
|
|||
return OpenAI(base_url=base_url, api_key="fake")
|
||||
|
||||
|
||||
@pytest.fixture(params=["openai_client", "llama_stack_client"])
|
||||
def compat_client(request):
|
||||
@pytest.fixture(params=["openai_client", "client_with_models"])
|
||||
def compat_client(request, client_with_models):
|
||||
if isinstance(client_with_models, LlamaStackAsLibraryClient):
|
||||
# OpenAI client expects a server, so unless we also rewrite OpenAI client's requests
|
||||
# to go via the Stack library client (which itself rewrites requests to be served inline),
|
||||
# we cannot do this.
|
||||
#
|
||||
# This means when we are using Stack as a library, we will test only via the Llama Stack client.
|
||||
# When we are using a server setup, we can exercise both OpenAI and Llama Stack clients.
|
||||
pytest.skip("(OpenAI) Compat client cannot be used with Stack library client")
|
||||
|
||||
return request.getfixturevalue(request.param)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue