mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-16 23:03:49 +00:00
score batch impl
This commit is contained in:
parent
4b1d7da030
commit
eb572faf6f
5 changed files with 38 additions and 7 deletions
|
@ -36,7 +36,10 @@ class ScoringClient(Scoring):
|
|||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{self.base_url}/scoring/score_batch",
|
||||
params={},
|
||||
json={
|
||||
"dataset_id": dataset_id,
|
||||
"scoring_functions": scoring_functions,
|
||||
},
|
||||
headers={"Content-Type": "application/json"},
|
||||
timeout=60,
|
||||
)
|
||||
|
@ -44,7 +47,7 @@ class ScoringClient(Scoring):
|
|||
if not response.json():
|
||||
return
|
||||
|
||||
return ScoreResponse(**response.json())
|
||||
return ScoreBatchResponse(**response.json())
|
||||
|
||||
async def score(
|
||||
self, input_rows: List[Dict[str, Any]], scoring_functions: List[str]
|
||||
|
@ -112,6 +115,14 @@ async def run_main(host: str, port: int):
|
|||
)
|
||||
cprint(f"scoring response={response}", "blue")
|
||||
|
||||
# test scoring batch using datasetio api
|
||||
scoring_client = ScoringClient(f"http://{host}:{port}")
|
||||
response = await scoring_client.score_batch(
|
||||
dataset_id="test-dataset",
|
||||
scoring_functions=["equality"],
|
||||
)
|
||||
cprint(f"scoring response={response}", "blue")
|
||||
|
||||
|
||||
def main(host: str, port: int):
|
||||
asyncio.run(run_main(host, port))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue