forked from phoenix-oss/llama-stack-mirror
# What does this PR do? - Update `/eval-tasks` to `/benchmarks` - ⚠️ Remove differentiation between `app` v.s. `benchmark` eval task config. Now we only have `BenchmarkConfig`. The overloaded `benchmark` is confusing and do not add any value. Backward compatibility is being kept as the "type" is not being used anywhere. [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan - This change is backward compatible - Run notebook test with ``` pytest -v -s --nbval-lax ./docs/getting_started.ipynb pytest -v -s --nbval-lax ./docs/notebooks/Llama_Stack_Benchmark_Evals.ipynb ``` <img width="846" alt="image" src="https://github.com/user-attachments/assets/d2fc06a7-593a-444f-bc1f-10ab9b0c843d" /> [//]: # (## Documentation) [//]: # (- [ ] Added a Changelog entry if the change is significant) --------- Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com> Signed-off-by: Ben Browning <bbrownin@redhat.com> Signed-off-by: Sébastien Han <seb@redhat.com> Signed-off-by: reidliu <reid201711@gmail.com> Co-authored-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com> Co-authored-by: Ben Browning <ben324@gmail.com> Co-authored-by: Sébastien Han <seb@redhat.com> Co-authored-by: Reid <61492567+reidliu41@users.noreply.github.com> Co-authored-by: reidliu <reid201711@gmail.com> Co-authored-by: Yuan Tang <terrytangyuan@gmail.com>
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
from typing import Any, Dict, List, Literal, Optional, Protocol, runtime_checkable
|
|
|
|
from llama_models.schema_utils import json_schema_type, webmethod
|
|
from pydantic import BaseModel, Field
|
|
|
|
from llama_stack.apis.resource import Resource, ResourceType
|
|
|
|
|
|
class CommonBenchmarkFields(BaseModel):
|
|
dataset_id: str
|
|
scoring_functions: List[str]
|
|
metadata: Dict[str, Any] = Field(
|
|
default_factory=dict,
|
|
description="Metadata for this evaluation task",
|
|
)
|
|
|
|
|
|
@json_schema_type
|
|
class Benchmark(CommonBenchmarkFields, Resource):
|
|
type: Literal[ResourceType.benchmark.value] = ResourceType.benchmark.value
|
|
|
|
@property
|
|
def benchmark_id(self) -> str:
|
|
return self.identifier
|
|
|
|
@property
|
|
def provider_benchmark_id(self) -> str:
|
|
return self.provider_resource_id
|
|
|
|
|
|
class BenchmarkInput(CommonBenchmarkFields, BaseModel):
|
|
benchmark_id: str
|
|
provider_id: Optional[str] = None
|
|
provider_benchmark_id: Optional[str] = None
|
|
|
|
|
|
class ListBenchmarksResponse(BaseModel):
|
|
data: List[Benchmark]
|
|
|
|
|
|
@runtime_checkable
|
|
class Benchmarks(Protocol):
|
|
@webmethod(route="/eval/benchmarks", method="GET")
|
|
async def list_benchmarks(self) -> ListBenchmarksResponse: ...
|
|
|
|
@webmethod(route="/eval/benchmarks/{benchmark_id}", method="GET")
|
|
async def get_benchmark(
|
|
self,
|
|
benchmark_id: str,
|
|
) -> Optional[Benchmark]: ...
|
|
|
|
@webmethod(route="/eval/benchmarks", method="POST")
|
|
async def register_benchmark(
|
|
self,
|
|
benchmark_id: str,
|
|
dataset_id: str,
|
|
scoring_functions: List[str],
|
|
provider_benchmark_id: Optional[str] = None,
|
|
provider_id: Optional[str] = None,
|
|
metadata: Optional[Dict[str, Any]] = None,
|
|
) -> None: ...
|
|
|
|
@webmethod(route="/eval-tasks", method="GET")
|
|
async def DEPRECATED_list_eval_tasks(self) -> ListBenchmarksResponse: ...
|
|
|
|
@webmethod(route="/eval-tasks/{task_id}", method="GET")
|
|
async def DEPRECATED_get_eval_task(
|
|
self,
|
|
eval_task_id: str,
|
|
) -> Optional[Benchmark]: ...
|
|
|
|
@webmethod(route="/eval-tasks", method="POST")
|
|
async def DEPRECATED_register_eval_task(
|
|
self,
|
|
eval_task_id: str,
|
|
dataset_id: str,
|
|
scoring_functions: List[str],
|
|
provider_benchmark_id: Optional[str] = None,
|
|
provider_id: Optional[str] = None,
|
|
metadata: Optional[Dict[str, Any]] = None,
|
|
) -> None: ...
|