Skip to content

Commit

Permalink
FalkorDB Engine: Add checker before delete()
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentGenie committed Dec 12, 2024
1 parent 5f6d1f1 commit 59b03a7
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions notebook/agentchat_graph_rag_falkordb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"\n",
Expand Down Expand Up @@ -108,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -127,23 +118,23 @@
"--------------------------------------------------------------------------------\n",
"\u001b[33muser_proxy\u001b[0m (to matrix_agent):\n",
"\n",
"Who else acted in The Matrix?\n",
"Any additional actors?\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mmatrix_agent\u001b[0m (to user_proxy):\n",
"\n",
"Based on the provided information, there is no additional data about other actors who acted in 'The Matrix' outside of Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\n",
"I'm sorry, but I don't have information about any additional actors from 'The Matrix' beyond Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
},
{
"data": {
"text/plain": [
"ChatResult(chat_id=None, chat_history=[{'content': \"Name a few actors who've played in 'The Matrix'\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are a few actors who've played in 'The Matrix'.\", 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Who else acted in The Matrix?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Based on the provided information, there is no additional data about other actors who acted in 'The Matrix' outside of Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\", 'role': 'user', 'name': 'matrix_agent'}], summary=\"Based on the provided information, there is no additional data about other actors who acted in 'The Matrix' outside of Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\", cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['Who else acted in The Matrix?', 'exit'])"
"ChatResult(chat_id=None, chat_history=[{'content': \"Name a few actors who've played in 'The Matrix'\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are a few actors who've played in 'The Matrix'.\", 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Any additional actors?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"I'm sorry, but I don't have information about any additional actors from 'The Matrix' beyond Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\", 'role': 'user', 'name': 'matrix_agent'}], summary=\"I'm sorry, but I don't have information about any additional actors from 'The Matrix' beyond Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\", cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['Any additional actors?', 'exit'])"
]
},
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -161,7 +152,7 @@
"# Create FalkorGraphQueryEngine\n",
"query_engine = FalkorGraphQueryEngine(\n",
" name=\"The_Matrix_Auto\",\n",
" host=\"172.18.0.3\", # Change\n",
" host=\"172.17.0.4\", # Change\n",
" port=6379, # if needed\n",
")\n",
"\n",
Expand Down Expand Up @@ -197,7 +188,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -219,7 +210,7 @@
"\n",
"query_engine = FalkorGraphQueryEngine(\n",
" name=\"IMDB\",\n",
" host=\"172.18.0.3\", # Change\n",
" host=\"172.17.0.4\", # Change\n",
" port=6379, # if needed\n",
" ontology=movie_ontology,\n",
")\n",
Expand All @@ -240,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -254,7 +245,7 @@
"--------------------------------------------------------------------------------\n",
"\u001b[33mmatrix_agent\u001b[0m (to user_proxy):\n",
"\n",
"Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are some of the actors who have played in \"The Matrix\".\n",
"Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving have played in 'The Matrix'.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33muser_proxy\u001b[0m (to matrix_agent):\n",
Expand All @@ -264,7 +255,7 @@
"--------------------------------------------------------------------------------\n",
"\u001b[33mmatrix_agent\u001b[0m (to user_proxy):\n",
"\n",
"No other actors are listed as having acted in \"The Matrix\" beyond Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.\n",
"Based on the provided information, Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are the actors listed for 'The Matrix'. No additional actors are mentioned in the data.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33muser_proxy\u001b[0m (to matrix_agent):\n",
Expand All @@ -282,10 +273,10 @@
{
"data": {
"text/plain": [
"ChatResult(chat_id=None, chat_history=[{'content': \"Name a few actors who've played in 'The Matrix'\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are some of the actors who have played in \"The Matrix\".', 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Who else acted in The Matrix?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'No other actors are listed as having acted in \"The Matrix\" beyond Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving.', 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Where was The Matrix filmed?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'I am sorry, I could not find the answer to your question', 'role': 'user', 'name': 'matrix_agent'}], summary='I am sorry, I could not find the answer to your question', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['Who else acted in The Matrix?', 'Where was The Matrix filmed?', 'exit'])"
"ChatResult(chat_id=None, chat_history=[{'content': \"Name a few actors who've played in 'The Matrix'\", 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving have played in 'The Matrix'.\", 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Who else acted in The Matrix?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': \"Based on the provided information, Keanu Reeves, Laurence Fishburne, Carrie-Anne Moss, and Hugo Weaving are the actors listed for 'The Matrix'. No additional actors are mentioned in the data.\", 'role': 'user', 'name': 'matrix_agent'}, {'content': 'Where was The Matrix filmed?', 'role': 'assistant', 'name': 'user_proxy'}, {'content': 'I am sorry, I could not find the answer to your question', 'role': 'user', 'name': 'matrix_agent'}], summary='I am sorry, I could not find the answer to your question', cost={'usage_including_cached_inference': {'total_cost': 0}, 'usage_excluding_cached_inference': {'total_cost': 0}}, human_input=['Who else acted in The Matrix?', 'Where was The Matrix filmed?', 'exit'])"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -326,6 +317,16 @@
"- There is inbuilt awareness of answers it has provided previously\n",
"- It can't answer any questions outside of the actors and movies entities as we didn't include anything else in the ontology"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Remove graph from database:\n",
"query_engine.delete()"
]
}
],
"metadata": {
Expand Down

0 comments on commit 59b03a7

Please sign in to comment.