mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-08 19:10:56 +00:00
wip api
This commit is contained in:
parent
7143ecfc0d
commit
8339b2cef3
10 changed files with 174 additions and 51 deletions
57
llama_stack/apis/evals/client.py
Normal file
57
llama_stack/apis/evals/client.py
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# 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.
|
||||
|
||||
import asyncio
|
||||
|
||||
import fire
|
||||
import httpx
|
||||
from termcolor import cprint
|
||||
|
||||
from .evals import * # noqa: F403
|
||||
|
||||
|
||||
class EvaluationClient(Evals):
|
||||
def __init__(self, base_url: str):
|
||||
self.base_url = base_url
|
||||
|
||||
async def initialize(self) -> None:
|
||||
pass
|
||||
|
||||
async def shutdown(self) -> None:
|
||||
pass
|
||||
|
||||
async def run_evals(self, model: str, dataset: str, task: str) -> EvaluateResponse:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.base_url}/evals/run",
|
||||
json={
|
||||
"model": model,
|
||||
"dataset": dataset,
|
||||
"task": task,
|
||||
},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
response.raise_for_status()
|
||||
return EvaluateResponse(**response.json())
|
||||
|
||||
|
||||
async def run_main(host: str, port: int):
|
||||
client = EvaluationClient(f"http://{host}:{port}")
|
||||
|
||||
response = await client.run_evals(
|
||||
"Llama3.1-8B-Instruct",
|
||||
"mmlu.csv",
|
||||
"mmlu",
|
||||
)
|
||||
cprint(f"evaluate response={response}", "green")
|
||||
|
||||
|
||||
def main(host: str, port: int):
|
||||
asyncio.run(run_main(host, port))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
fire.Fire(main)
|
||||
Loading…
Add table
Add a link
Reference in a new issue