Skip to content

Commit

Permalink
Catch ValueError in SPIRES engine when returned value is empty in a s…
Browse files Browse the repository at this point in the history
…ingle line (#491)
  • Loading branch information
caufieldjh authored Dec 11, 2024
2 parents 6fe7d08 + 9e2074c commit 51b0413
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ontogpt/engines/spires_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,15 @@ def _parse_line_to_dict(
if cls is None:
cls = self.template_class
sv = self.schemaview
# each line is a key-value pair
# each line is a key-value pair, with key as field
# and value as val. An error gets raised if the value is empty
logging.info(f"PARSING LINE: {line}")
field, val = line.split(":", 1)
# Field nornalization:
try:
field, val = line.split(":", 1)
except ValueError:
field = line.split(":", 1)[0]
val = ""
# Field normalization:
# The LLM may mutate the output format somewhat,
# randomly pluralizing or replacing spaces with underscores
field = field.lower().replace(" ", "_")
Expand Down

0 comments on commit 51b0413

Please sign in to comment.