diff --git a/biochatter/database_agent.py b/biochatter/database_agent.py index c9b85434..23695524 100644 --- a/biochatter/database_agent.py +++ b/biochatter/database_agent.py @@ -115,6 +115,21 @@ def get_query_results(self, query: str, k: int = 3) -> list[Document]: # than k if results is None or len(results) == 0 or results[0] is None: return [] + if len(results[0]) == 0: + return [ + Document( + page_content = ( + "I didn't find any result in knowledge graph, " + f"but here is the query I used: {cypher_query}. " + "You can ask user to refine the question, " + "but don't make up anything." + ), + metadata={ + "cypher_query": cypher_query, + }, + ) + ] + for result in results[0]: documents.append( Document(