score batch impl

This commit is contained in:
Xi Yan 2024-10-23 16:19:25 -07:00
parent 4b1d7da030
commit eb572faf6f
5 changed files with 38 additions and 7 deletions

View file

@ -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))