Skip to content

Commit

Permalink
fix: Inject kg context even if kg query result is empty (#198)
Browse files Browse the repository at this point in the history
* fix some bugs in reflexion agent

* fix an vectorstore issue

* introduce use_reflexion to kg RagAgent

* prompt LLM not to generate cypher marker

* fix test error

* change vectorstore collection names to apply previous fix of collection field max length issue

* phrasing, formatting, parameter explanations

* fix type hinting

* prompt LLM even if kg query result is empty

---------

Co-authored-by: fengsh <shaohong.feng.78@gmail.com>
Co-authored-by: slobentanzer <sebastian.lobentanzer@gmail.com>
  • Loading branch information
3 people authored Aug 20, 2024
1 parent fa5e582 commit d082030
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions biochatter/database_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d082030

Please sign in to comment.