Skip to content

Commit

Permalink
adding error checking for fields coming from llm that aren't strings
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Mar 26, 2024
1 parent 2730218 commit 5923994
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions parsers/LitCoin/src/loadLitCoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ def parse_llm_output(self, llm_output):
LLM_SUBJECT_TYPE,
LLM_OBJECT_NAME,
LLM_OBJECT_TYPE,
LLM_RELATIONSHIP,
# LLM_MAIN_FINDING # this isn't coming from the llm output currently
LLM_RELATIONSHIP
]
matches = re.findall(r'\{([^\}]*)\}', llm_output)
valid_responses = []
Expand All @@ -248,7 +247,10 @@ def parse_llm_output(self, llm_output):
continue
for field in required_fields:
if field not in cur_response_dict:
self.logger.info(f'Missing field {field} in response: {cur_response_dict}')
self.logger.warning(f'Missing field {field} in response: {cur_response_dict}')
break
if not isinstance(cur_response_dict[field], str):
self.logger.warning(f'Non-string field {field} in response: {cur_response_dict}')
break
else: # only add the fields which have all the fields
valid_responses.append(cur_response_dict)
Expand Down

0 comments on commit 5923994

Please sign in to comment.