File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 22import sys
33
44from huggingface_hub import InferenceClient
5- from requests import HTTPError
5+ from huggingface_hub . errors import HfHubHTTPError
66
77import datachain as dc
88
@@ -45,7 +45,7 @@ def eval_dialog(
4545 "json_schema" : {"schema" : DialogEval .model_json_schema ()},
4646 },
4747 )
48- except HTTPError as e :
48+ except HfHubHTTPError as e :
4949 return DialogEval (result = "Error" , reason = str (e ))
5050
5151 message = completion .choices [0 ].message
@@ -69,12 +69,15 @@ def eval_dialog(
6969 .to_parquet ("hf://datasets/dvcorg/test-datachain-llm-eval/data.parquet" )
7070)
7171
72+ result = dc .read_parquet (
73+ "hf://datasets/dvcorg/test-datachain-llm-eval/data.parquet" , source = False
74+ )
75+ errors = result .filter (dc .C ("response.result" ) == "Error" )
76+
77+ if result .count () == errors .count ():
78+ errors .show (3 )
79+ raise RuntimeError ("All Hugging Face inference requests failed." )
80+
7281# Read it back to filter and show.
7382# It restores the Pydantic model from Parquet under the hood.
74- (
75- dc .read_parquet (
76- "hf://datasets/dvcorg/test-datachain-llm-eval/data.parquet" , source = False
77- )
78- .filter (dc .C ("response.result" ) == "Failure" )
79- .show (3 )
80- )
83+ result .filter (dc .C ("response.result" ) == "Failure" ).show (3 )
You can’t perform that action at this time.
0 commit comments