Skip to content

Commit

Permalink
Fix bug relating to keyword extraction chain
Browse files Browse the repository at this point in the history
  • Loading branch information
jaiamin committed Oct 13, 2023
1 parent d52e459 commit decf8c2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rest/clients/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def keywords_extraction(self, user_input: str, model: str = "gpt-3.5-turbo"):
)
chain = create_extraction_chain(schema, llm)
keywords_extracted = list(chain.run(user_input))
if any(isinstance(item, str) for item in keywords_extracted):
keywords_extracted = [{key: ""} for key in schema["properties"]]
return self.prepare_keywords_for_semantic_search(keywords_extracted)


Expand Down

1 comment on commit decf8c2

@jaiamin
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to be that shorter queries (e.g. "rat") tend to lead to a schema of empty properties (no keywords can be extracted). Therefore, we should have a way to handle such cases so errors are not thrown (e.g. display message that no keywords could be extracted).

Please sign in to comment.