From 70c42a58bfe685ed850851a20314ac5e1d3eaaa3 Mon Sep 17 00:00:00 2001 From: Ulises M <30765968+lbux@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:42:52 -0800 Subject: [PATCH] Allow passing in required project_name 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", ) --- .../components/evaluators/uptrain/evaluator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py index 4e7307602..8c31162ce 100644 --- a/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py +++ b/integrations/uptrain/src/haystack_integrations/components/evaluators/uptrain/evaluator.py @@ -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. @@ -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 @@ -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 = [