Skip to content

Commit 2407b88

Browse files
committed
add event lopping
1 parent d7bc592 commit 2407b88

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cleanlab_codex/validator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,16 @@ def validate(
139139
- 'is_bad_response': True if the response is flagged as potentially bad (when True, a lookup in Codex is performed), False otherwise.
140140
- Additional keys: Various keys from a [`ThresholdedTrustworthyRAGScore`](/cleanlab_codex/types/validator/#class-thresholdedtrustworthyragscore) dictionary, with raw scores from [TrustworthyRAG](/tlm/api/python/utils.rag/#class-trustworthyrag) for each evaluation metric. `is_bad` indicating whether the score is below the threshold.
141141
"""
142-
expert_task = asyncio.create_task(self.remediate_async(query))
142+
loop = asyncio.get_event_loop()
143+
expert_task = loop.create_task(self.remediate_async(query))
143144
scores, is_bad_response = self.detect(query, context, response, prompt, form_prompt)
144-
expert_answer, maybe_entry = asyncio.run(expert_task)
145+
expert_answer, maybe_entry = loop.run_until_complete(expert_task)
146+
145147
if is_bad_response:
146148
if expert_answer == None:
147-
self._project.add_entries([maybe_entry])
149+
self._project._sdk_client.projects.entries.add_question(
150+
self._project._id, question=query,
151+
).model_dump()
148152
else:
149153
expert_answer = None
150154

0 commit comments

Comments
 (0)