forked from phoenix-oss/llama-stack-mirror
pre
This commit is contained in:
parent
a69759613a
commit
e860c536da
3 changed files with 8 additions and 22 deletions
|
@ -135,9 +135,7 @@ class Eval(Protocol):
|
||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
@webmethod(
|
@webmethod(route="/eval/benchmarks/{benchmark_id}/jobs/{job_id}/result", method="GET")
|
||||||
route="/eval/benchmarks/{benchmark_id}/jobs/{job_id}/result", method="GET"
|
|
||||||
)
|
|
||||||
async def job_result(self, benchmark_id: str, job_id: str) -> EvaluateResponse:
|
async def job_result(self, benchmark_id: str, job_id: str) -> EvaluateResponse:
|
||||||
"""Get the result of a job.
|
"""Get the result of a job.
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ from typing import (
|
||||||
Literal,
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
Protocol,
|
Protocol,
|
||||||
runtime_checkable,
|
|
||||||
Union,
|
Union,
|
||||||
|
runtime_checkable,
|
||||||
)
|
)
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
|
@ -117,9 +117,7 @@ class EnvVarError(Exception):
|
||||||
def __init__(self, var_name: str, path: str = ""):
|
def __init__(self, var_name: str, path: str = ""):
|
||||||
self.var_name = var_name
|
self.var_name = var_name
|
||||||
self.path = path
|
self.path = path
|
||||||
super().__init__(
|
super().__init__(f"Environment variable '{var_name}' not set or empty{f' at {path}' if path else ''}")
|
||||||
f"Environment variable '{var_name}' not set or empty{f' at {path}' if path else ''}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def redact_sensitive_fields(data: Dict[str, Any]) -> Dict[str, Any]:
|
def redact_sensitive_fields(data: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
@ -210,9 +208,7 @@ def validate_env_pair(env_pair: str) -> tuple[str, str]:
|
||||||
if not key:
|
if not key:
|
||||||
raise ValueError(f"Empty key in environment variable pair: {env_pair}")
|
raise ValueError(f"Empty key in environment variable pair: {env_pair}")
|
||||||
if not all(c.isalnum() or c == "_" for c in key):
|
if not all(c.isalnum() or c == "_" for c in key):
|
||||||
raise ValueError(
|
raise ValueError(f"Key must contain only alphanumeric characters and underscores: {key}")
|
||||||
f"Key must contain only alphanumeric characters and underscores: {key}"
|
|
||||||
)
|
|
||||||
return key, value
|
return key, value
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
@ -225,20 +221,14 @@ def validate_env_pair(env_pair: str) -> tuple[str, str]:
|
||||||
async def construct_stack(
|
async def construct_stack(
|
||||||
run_config: StackRunConfig, provider_registry: Optional[ProviderRegistry] = None
|
run_config: StackRunConfig, provider_registry: Optional[ProviderRegistry] = None
|
||||||
) -> Dict[Api, Any]:
|
) -> Dict[Api, Any]:
|
||||||
dist_registry, _ = await create_dist_registry(
|
dist_registry, _ = await create_dist_registry(run_config.metadata_store, run_config.image_name)
|
||||||
run_config.metadata_store, run_config.image_name
|
impls = await resolve_impls(run_config, provider_registry or get_provider_registry(), dist_registry)
|
||||||
)
|
|
||||||
impls = await resolve_impls(
|
|
||||||
run_config, provider_registry or get_provider_registry(), dist_registry
|
|
||||||
)
|
|
||||||
await register_resources(run_config, impls)
|
await register_resources(run_config, impls)
|
||||||
return impls
|
return impls
|
||||||
|
|
||||||
|
|
||||||
def get_stack_run_config_from_template(template: str) -> StackRunConfig:
|
def get_stack_run_config_from_template(template: str) -> StackRunConfig:
|
||||||
template_path = (
|
template_path = importlib.resources.files("llama_stack") / f"templates/{template}/run.yaml"
|
||||||
importlib.resources.files("llama_stack") / f"templates/{template}/run.yaml"
|
|
||||||
)
|
|
||||||
|
|
||||||
with importlib.resources.as_file(template_path) as path:
|
with importlib.resources.as_file(template_path) as path:
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
|
@ -281,9 +271,7 @@ def run_config_from_adhoc_config_spec(
|
||||||
|
|
||||||
# call method "sample_run_config" on the provider spec config class
|
# call method "sample_run_config" on the provider spec config class
|
||||||
provider_config_type = instantiate_class_type(provider_spec.config_class)
|
provider_config_type = instantiate_class_type(provider_spec.config_class)
|
||||||
provider_config = replace_env_vars(
|
provider_config = replace_env_vars(provider_config_type.sample_run_config(__distro_dir__=distro_dir))
|
||||||
provider_config_type.sample_run_config(__distro_dir__=distro_dir)
|
|
||||||
)
|
|
||||||
|
|
||||||
provider_configs_by_api[api_str] = [
|
provider_configs_by_api[api_str] = [
|
||||||
Provider(
|
Provider(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue