Skip to content

Commit

Permalink
Allow passing in required project_name
Browse files Browse the repository at this point in the history
UpTrain requires a project_name when using its API whereas openai does not. The integration will crash if no project_name is included.

This will allow for an eval declaration like so:

evaluator = UpTrainEvaluator(
    metric=UpTrainMetric.METRIC,
    api="uptrain",
    project_name="uptrain-project",
)
  • Loading branch information
lbux authored Feb 20, 2024
1 parent e43c12f commit 70c42a5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
api: str = "openai",
api_key: Secret = Secret.from_env_var("OPENAI_API_KEY"),
api_params: Optional[Dict[str, Any]] = None,
project_name: Optional[str] = None,
):
"""
Construct a new UpTrain evaluator.
Expand All @@ -59,6 +60,7 @@ def __init__(
self.api = api
self.api_key = api_key
self.api_params = api_params
self.project_name = project_name

self._init_backend()
expected_inputs = self.descriptor.input_parameters
Expand Down Expand Up @@ -112,7 +114,7 @@ def run(self, **inputs) -> Dict[str, Any]:
if isinstance(self._backend_client, EvalLLM):
results = self._backend_client.evaluate(**eval_args)
else:
results = self._backend_client.log_and_evaluate(**eval_args)
results = self._backend_client.log_and_evaluate(**eval_args, project_name=self.project_name)

OutputConverters.validate_outputs(results)
converted_results = [
Expand Down

0 comments on commit 70c42a5

Please sign in to comment.