Skip to content

Commit

Permalink
treating weird openrouter response when getting the answer
Browse files Browse the repository at this point in the history
  • Loading branch information
PsicoThePato committed Aug 15, 2024
1 parent 3daeade commit 0b23279
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/synthia/validator/text_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ async def _get_miner_prediction(
val_info: ValidationDataset,
miner_info: tuple[list[str], Ss58Address],
) -> tuple[str | None, ValidationDataset]:
miner_answer = None
miner_answer: str | None | list[str] = None

try:
connection, miner_key = miner_info
Expand All @@ -291,7 +291,13 @@ async def _get_miner_prediction(
"generate", miner_key, {"prompt": question}, timeout=self.call_timeout
)
miner_answer = response.get("answer")
if isinstance(miner_answer, list):
if len(miner_answer) == 0:
miner_answer = None
else:
miner_answer = miner_answer[0]
except Exception as e:
miner_answer = None
log(f"Miner {module_ip}:{module_port} failed to generate an answer: {e}")

# This is needed, so truly nothing can get propagated through the call stack
Expand Down

0 comments on commit 0b23279

Please sign in to comment.