Skip to content

Commit

Permalink
Fix Guideline Adherence (uptrain-ai#677)
Browse files Browse the repository at this point in the history
* Fix Guideline Adherence

* Fix col_out
  • Loading branch information
Dominastorm authored Apr 4, 2024
1 parent 0d69e3d commit 37a9e5f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions uptrain/operators/language/guideline.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
self.col_out = f"score_{self.guideline_name}_adherence"
if self.settings.evaluate_locally and (
self.settings.uptrain_access_token is None
or not len(self.settings.uptrain_access_token)
Expand Down Expand Up @@ -178,15 +179,15 @@ def evaluate_local(self, data):
for res in output_payloads:
idx = res.metadata["index"]
output = {
"score_guideline_adherence": None,
"explanation_guideline_adherence": None,
f"score_{self.guideline_name}_adherence": None,
f"explanation_{self.guideline_name}_adherence": None,
}
try:
score = self.score_mapping[
json.loads(res.response.choices[0].message.content)["Choice"]
]
output["score_guideline_adherence"] = float(score)
output["explanation_guideline_adherence"] = res.response.choices[
output[f"score_{self.guideline_name}_adherence"] = float(score)
output[f"explanation_{self.guideline_name}_adherence"] = res.response.choices[
0
].message.content
except Exception:
Expand Down

0 comments on commit 37a9e5f

Please sign in to comment.