langroid 0.19.4__py3-none-any.whl → 0.20.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ from rich import print
14
14
  from rich.console import Console
15
15
 
16
16
  from langroid.exceptions import LangroidImportError
17
- from langroid.utils.constants import DONE
17
+ from langroid.utils.constants import DONE, SEND_TO
18
18
 
19
19
  try:
20
20
  from sqlalchemy import MetaData, Row, create_engine, inspect, text
@@ -96,7 +96,7 @@ class SQLChatAgentConfig(ChatAgentConfig):
96
96
  context_descriptions: Dict[str, Dict[str, Union[str, Dict[str, str]]]] = {}
97
97
  use_schema_tools: bool = False
98
98
  multi_schema: bool = False
99
- addressing_prefix: str = ""
99
+ addressing_prefix: str = SEND_TO
100
100
 
101
101
  """
102
102
  Optional, but strongly recommended, context descriptions for tables, columns,
@@ -257,6 +257,7 @@ class SQLChatAgent(ChatAgent):
257
257
  self, message: Optional[str | ChatDocument] = None
258
258
  ) -> Optional[ChatDocument]:
259
259
  self.llm_responded = True
260
+ self.used_run_query = False
260
261
  return super().llm_response(message)
261
262
 
262
263
  def user_response(
@@ -270,7 +271,11 @@ class SQLChatAgent(ChatAgent):
270
271
  def handle_message_fallback(
271
272
  self, msg: str | ChatDocument
272
273
  ) -> str | ChatDocument | None:
273
-
274
+ """
275
+ Handle the scenario where current msg is not a tool.
276
+ Special handling is only needed if the message was from the LLM
277
+ (as indicated by self.llm_responded).
278
+ """
274
279
  if not self.llm_responded:
275
280
  return None
276
281
  if self.used_run_query:
langroid/agent/task.py CHANGED
@@ -1226,8 +1226,22 @@ class Task:
1226
1226
  # reset stuck counter since we made progress
1227
1227
  self.n_stalled_steps = 0
1228
1228
 
1229
- # update counters for infinite loop detection
1230
1229
  if self.pending_message is not None:
1230
+ if (
1231
+ self._is_done_response(result, r)
1232
+ and self._level == 0
1233
+ and self.only_user_quits_root
1234
+ and self._user_can_respond()
1235
+ ):
1236
+ # We're ignoring the DoneTools (if any) in this case,
1237
+ # so remove them from the pending msg, to ensure
1238
+ # they don't affect the next step.
1239
+ self.pending_message.tool_messages = [
1240
+ t
1241
+ for t in self.pending_message.tool_messages
1242
+ if not isinstance(t, (DoneTool, AgentDoneTool))
1243
+ ]
1244
+ # update counters for infinite loop detection
1231
1245
  hashed_msg = hash(str(self.pending_message))
1232
1246
  self.message_counter.update([hashed_msg])
1233
1247
  self.history.append(hashed_msg)
@@ -1520,6 +1534,7 @@ class Task:
1520
1534
  content = to_string(t.content)
1521
1535
  content_any = t.content
1522
1536
  if isinstance(t, AgentDoneTool):
1537
+ # AgentDoneTool may have tools, unlike DoneTool
1523
1538
  tool_messages = t.tools
1524
1539
  break
1525
1540
  # drop the "Done" tools since they should not be part of the task result,
@@ -1890,6 +1905,7 @@ class Task:
1890
1905
  # user, then wait for user response
1891
1906
  self.pending_message is not None
1892
1907
  and self.pending_message.metadata.recipient == Entity.USER
1908
+ and not self.agent.has_tool_message_attempt(self.pending_message)
1893
1909
  )
1894
1910
 
1895
1911
  def _can_respond(self, e: Responder) -> bool:
@@ -115,7 +115,7 @@ class FinalResultTool(ToolMessage):
115
115
  Note:
116
116
  - when defining a tool handler or agent_response, you can directly return
117
117
  FinalResultTool(field1 = val1, ...),
118
- where the values can be aribitrary data structures, including nested
118
+ where the values can be arbitrary data structures, including nested
119
119
  Pydantic objs, or you can define a subclass of FinalResultTool with the
120
120
  fields you want to return.
121
121
  - This is a special ToolMessage that is NOT meant to be used or handled
@@ -6,6 +6,15 @@ the method `_get_tool_list()`).
6
6
 
7
7
  See usage examples in `tests/main/test_multi_agent_complex.py` and
8
8
  `tests/main/test_recipient_tool.py`.
9
+
10
+ A simpler alternative to this tool is `SendTool`, see here:
11
+ https://github.com/langroid/langroid/blob/main/langroid/agent/tools/orchestration.py
12
+
13
+ You can also define your own XML-based variant of this tool:
14
+ https://github.com/langroid/langroid/blob/main/examples/basic/xml-tool.py
15
+ which uses XML rather than JSON, and can be more reliable than JSON,
16
+ especially with weaker LLMs.
17
+
9
18
  """
10
19
 
11
20
  from typing import List, Type
@@ -66,6 +66,12 @@ class Parser:
66
66
  tokens = self.tokenizer.encode(text)
67
67
  return len(tokens)
68
68
 
69
+ def truncate_tokens(self, text: str, max_tokens: int) -> str:
70
+ tokens = self.tokenizer.encode(text)
71
+ if len(tokens) <= max_tokens:
72
+ return text
73
+ return self.tokenizer.decode(tokens[:max_tokens])
74
+
69
75
  def add_window_ids(self, chunks: List[Document]) -> None:
70
76
  """Chunks may belong to multiple docs, but for each doc,
71
77
  they appear consecutively. Add window_ids in metadata"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.19.4
3
+ Version: 0.20.0
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Provides-Extra: all
15
+ Provides-Extra: arango
15
16
  Provides-Extra: chainlit
16
17
  Provides-Extra: chromadb
17
18
  Provides-Extra: db
@@ -35,7 +36,9 @@ Provides-Extra: sql
35
36
  Provides-Extra: transformers
36
37
  Provides-Extra: unstructured
37
38
  Provides-Extra: vecdbs
39
+ Requires-Dist: adb-cloud-connector (>=1.0.2,<2.0.0)
38
40
  Requires-Dist: aiohttp (>=3.9.1,<4.0.0)
41
+ Requires-Dist: arango-datasets (>=1.2.2,<2.0.0) ; extra == "all" or extra == "arango"
39
42
  Requires-Dist: async-generator (>=1.10,<2.0)
40
43
  Requires-Dist: bs4 (>=0.0.1,<0.0.2)
41
44
  Requires-Dist: cerebras-cloud-sdk (>=1.1.0,<2.0.0)
@@ -82,6 +85,7 @@ Requires-Dist: pymysql (>=1.1.0,<2.0.0) ; extra == "db" or extra == "all" or ext
82
85
  Requires-Dist: pyparsing (>=3.0.9,<4.0.0)
83
86
  Requires-Dist: pypdf (>=3.12.2,<4.0.0) ; extra == "doc-chat" or extra == "all" or extra == "pdf-parsers"
84
87
  Requires-Dist: pytesseract (>=0.3.10,<0.4.0) ; extra == "doc-chat" or extra == "all" or extra == "pdf-parsers"
88
+ Requires-Dist: python-arango (>=8.1.2,<9.0.0) ; extra == "all" or extra == "arango"
85
89
  Requires-Dist: python-docx (>=1.1.0,<2.0.0) ; extra == "doc-chat" or extra == "all" or extra == "docx"
86
90
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
87
91
  Requires-Dist: python-magic (>=0.4.27,<0.5.0)
@@ -1,6 +1,6 @@
1
1
  langroid/__init__.py,sha256=z_fCOLQJPOw3LLRPBlFB5-2HyCjpPgQa4m4iY5Fvb8Y,1800
2
2
  langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
3
- langroid/agent/base.py,sha256=swttuRRJKdDt-GUFsBNKHn1MQRj29b2f2U7Tuw5V5pk,64793
3
+ langroid/agent/base.py,sha256=uCjFJ0Mjm6hu4MSCsz7vzGwzpbkrxddDIduhxS24jps,65034
4
4
  langroid/agent/batch.py,sha256=QZdlt1563hx4l3AXrCaGovE-PNG93M3DsvQAbDzdiS8,13705
5
5
  langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  langroid/agent/callbacks/chainlit.py,sha256=JJXI3UGTyTDg2FFath4rqY1GyUo_0pbVBt8CZpvdtn4,23289
@@ -10,6 +10,10 @@ langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  langroid/agent/junk,sha256=LxfuuW7Cijsg0szAzT81OjWWv1PMNI-6w_-DspVIO2s,339
11
11
  langroid/agent/openai_assistant.py,sha256=2rjCZw45ysNBEGNzQM4uf0bTC4KkatGYAWcVcW4xcek,34337
12
12
  langroid/agent/special/__init__.py,sha256=gik_Xtm_zV7U9s30Mn8UX3Gyuy4jTjQe9zjiE3HWmEo,1273
13
+ langroid/agent/special/arangodb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ langroid/agent/special/arangodb/arangodb_agent.py,sha256=5X8yQr1MdTLchNK6L7g3gArFYVEiql4g35YPMw_4TIU,19579
15
+ langroid/agent/special/arangodb/system_messages.py,sha256=j-vNz4SLKzE6-1a31ZFw7NHMD_uBepS8vxJ_bsjgMC4,5801
16
+ langroid/agent/special/arangodb/tools.py,sha256=3CW2HsLqcM0JGemHsmihm8F5zZwwbFvAwyHzzaJ2S90,1319
13
17
  langroid/agent/special/doc_chat_agent.py,sha256=xIqBOyLax_jMU0UevxqXf_aQUrRkW6MQUKpKnKvaqkQ,59281
14
18
  langroid/agent/special/lance_doc_chat_agent.py,sha256=s8xoRs0gGaFtDYFUSIRchsgDVbS5Q3C2b2mr3V1Fd-Q,10419
15
19
  langroid/agent/special/lance_rag/__init__.py,sha256=QTbs0IVE2ZgDg8JJy1zN97rUUg4uEPH7SLGctFNumk4,174
@@ -19,13 +23,13 @@ langroid/agent/special/lance_rag/query_planner_agent.py,sha256=5YPeliCjlRk1LEDe5
19
23
  langroid/agent/special/lance_tools.py,sha256=qS8x4wi8mrqfbYV2ztFzrcxyhHQ0ZWOc-zkYiH7awj0,2105
20
24
  langroid/agent/special/neo4j/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
25
  langroid/agent/special/neo4j/csv_kg_chat.py,sha256=dRsAgMBa1H_EMI2YYgJR2Xyv1D7e4o3G9M64mTewq_c,6409
22
- langroid/agent/special/neo4j/neo4j_chat_agent.py,sha256=2r9kZ1AH3AxvJ6BZn0BZLhz-Bw8b7xUBlRv86gSEE8s,13542
23
- langroid/agent/special/neo4j/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- langroid/agent/special/neo4j/utils/system_message.py,sha256=_2NKX2Sx_7nLGNk_0rUyDkgTHZJuKm_DgtG7M_BFPkY,2920
26
+ langroid/agent/special/neo4j/neo4j_chat_agent.py,sha256=1RMKupJra0KZ-hA7AiiR662STJyYDZi8ZnAnnXF8oCA,16726
27
+ langroid/agent/special/neo4j/system_messages.py,sha256=m2jsVayey6E_88F5B_gW2WbWKBJvIeDUoVCRBbNs97o,4522
28
+ langroid/agent/special/neo4j/tools.py,sha256=Vw3HvtDfG2c4_bUHgt4_ZbJq48lpIQstbjjwhh1BjrQ,905
25
29
  langroid/agent/special/relevance_extractor_agent.py,sha256=zIx8GUdVo1aGW6ASla0NPQjYYIpmriK_TYMijqAx3F8,4796
26
30
  langroid/agent/special/retriever_agent.py,sha256=lvMvf-u9rSosg4YASuFdUbGLgkzLPknXAbJZfZ1LZCc,1868
27
31
  langroid/agent/special/sql/__init__.py,sha256=mWfmm1QpXCezpFOS2eI57M0L_Ok3q5_ukG8tXBnBrEA,319
28
- langroid/agent/special/sql/sql_chat_agent.py,sha256=PArNz9up0atw0cJet1LOfWlpW6xgofVBDR7Z3xvpzHk,16592
32
+ langroid/agent/special/sql/sql_chat_agent.py,sha256=LVTuOlaY6m5DpsMFLFv00eOz04y6vKeO4mfGLIUp6AY,16844
29
33
  langroid/agent/special/sql/utils/__init__.py,sha256=JFif6CRTrN-bc91uuAI4K9fe2ndIWSNMVxJ0WA68--M,446
30
34
  langroid/agent/special/sql/utils/description_extractors.py,sha256=cX8TIpmTPXZXQTMpIi3OUFwFsPywxFFdurpx717Kq0I,6529
31
35
  langroid/agent/special/sql/utils/populate_metadata.py,sha256=1J22UsyEPKzwK0XlJZtYn9r6kYc0FXIr8-lZrndYlhc,3131
@@ -33,15 +37,15 @@ langroid/agent/special/sql/utils/system_message.py,sha256=qKLHkvQWRQodTtPLPxr1GS
33
37
  langroid/agent/special/sql/utils/tools.py,sha256=vFYysk6Vi7HJjII8B4RitA3pt_z3gkSglDNdhNVMiFc,1332
34
38
  langroid/agent/special/table_chat_agent.py,sha256=d9v2wsblaRx7oMnKhLV7uO_ujvk9gh59pSGvBXyeyNc,9659
35
39
  langroid/agent/structured_message.py,sha256=y7pud1EgRNeTFZlJmBkLmwME3yQJ_IYik-Xds9kdZbY,282
36
- langroid/agent/task.py,sha256=GDnP24wsoXSZbwlG0g-OmKWM_pY-G4KGUgnCEbCsrYM,84660
40
+ langroid/agent/task.py,sha256=p7YsccpRIZcX0dFo5ll9EAaetWUcxZnCZal0i7Xsl1Y,85433
37
41
  langroid/agent/tool_message.py,sha256=jkN7uq7YwUC_wBcSCNUYjrB_His2YCfQay_lqIa4Tww,10498
38
42
  langroid/agent/tools/__init__.py,sha256=IMgCte-_ZIvCkozGQmvMqxIw7_nKLKzD78ccJL1bnQU,804
39
43
  langroid/agent/tools/duckduckgo_search_tool.py,sha256=NhsCaGZkdv28nja7yveAhSK_w6l_Ftym8agbrdzqgfo,1935
40
44
  langroid/agent/tools/file_tools.py,sha256=GjPB5YDILucYapElnvvoYpGJuZQ25ecLs2REv7edPEo,7292
41
45
  langroid/agent/tools/google_search_tool.py,sha256=y7b-3FtgXf0lfF4AYxrZ3K5pH2dhidvibUOAGBE--WI,1456
42
46
  langroid/agent/tools/metaphor_search_tool.py,sha256=qj4gt453cLEX3EGW7nVzVu6X7LCdrwjSlcNY0qJW104,2489
43
- langroid/agent/tools/orchestration.py,sha256=u_iQDwD5L9JgE39pCemmIRG3MxyrBsw6KpQYf7pH-Ek,10881
44
- langroid/agent/tools/recipient_tool.py,sha256=0m2kQhYKTeGujAxhSPqH5z6hSAhVB_Dqour6uul2U30,9427
47
+ langroid/agent/tools/orchestration.py,sha256=vp2Qx-DYPtDnACosxKqwHGy6DeD1QnEllWz0Ht81Cyc,10880
48
+ langroid/agent/tools/recipient_tool.py,sha256=dr0yTxgNEIoxUYxH6TtaExC4G_8WdJ0xGohIa4dFLhY,9808
45
49
  langroid/agent/tools/retrieval_tool.py,sha256=2q2pfoYbZNfbWQ0McxrtmfF0ekGglIgRl-6uF26pa-E,871
46
50
  langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
47
51
  langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
@@ -86,7 +90,7 @@ langroid/parsing/document_parser.py,sha256=ZGxgG4ytnCIah4HWk3ZrK3EGAMXDjAzI9KaPE
86
90
  langroid/parsing/image_text.py,sha256=sbLIQ5nHe2UnYUksBaQsmZGaX-X0qgEpPd7CEzi_z5M,910
87
91
  langroid/parsing/para_sentence_split.py,sha256=AJBzZojP3zpB-_IMiiHismhqcvkrVBQ3ZINoQyx_bE4,2000
88
92
  langroid/parsing/parse_json.py,sha256=aADo38bAHQhC8on4aWZZzVzSDy-dK35vRLZsFI2ewh8,4756
89
- langroid/parsing/parser.py,sha256=AgtmlVUvrkSG1l7-YZPX8rlldgXjh_HqXAMqpXkBxUo,11746
93
+ langroid/parsing/parser.py,sha256=bTG5TO2CEwGdLf9979j9_dFntKX5FloGF8vhts6ObU0,11978
90
94
  langroid/parsing/repo_loader.py,sha256=3GjvPJS6Vf5L6gV2zOU8s-Tf1oq_fZm-IB_RL_7CTsY,29373
91
95
  langroid/parsing/routing.py,sha256=-FcnlqldzL4ZoxuDwXjQPNHgBe9F9-F4R6q7b_z9CvI,1232
92
96
  langroid/parsing/search.py,sha256=0i_r0ESb5HEQfagA2g7_uMQyxYPADWVbdcN9ixZhS4E,8992
@@ -137,8 +141,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
137
141
  langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
138
142
  langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
139
143
  langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
140
- pyproject.toml,sha256=lidhX-USXT61UtttKdG0y4Y7pZhnfJCliByisRnsGD0,7251
141
- langroid-0.19.4.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
142
- langroid-0.19.4.dist-info/METADATA,sha256=abQ0VzdRQdcxtXfZ9KnexfvOeqKLC8jTl8vEl3Wpz1s,56513
143
- langroid-0.19.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
144
- langroid-0.19.4.dist-info/RECORD,,
144
+ pyproject.toml,sha256=DQbq0Xo4Bc3sJYF2-1qA9qnnKT0X-x5BzC99OrxcTNg,7488
145
+ langroid-0.20.0.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
146
+ langroid-0.20.0.dist-info/METADATA,sha256=5uni8xDGH809QGehHz0YfMguGFtvKDSJ9A7CfbduDnE,56758
147
+ langroid-0.20.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
148
+ langroid-0.20.0.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.19.4"
3
+ version = "0.20.0"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"
@@ -90,6 +90,9 @@ python-magic = "^0.4.27"
90
90
  json-repair = "^0.29.9"
91
91
  cerebras-cloud-sdk = "^1.1.0"
92
92
  gitpython = "^3.1.43"
93
+ python-arango = {version="^8.1.2", optional=true}
94
+ arango-datasets = {version="^1.2.2", optional=true}
95
+ adb-cloud-connector = "^1.0.2"
93
96
 
94
97
 
95
98
  [tool.poetry.extras]
@@ -113,6 +116,7 @@ all = [
113
116
  # "lancedb", "tantivy", "pyarrow",
114
117
  "chromadb",
115
118
  "metaphor-python", "neo4j",
119
+ "python-arango", "arango-datasets",
116
120
  "litellm",
117
121
  "chainlit", "python-socketio",
118
122
  "fastembed"
@@ -130,6 +134,7 @@ mysql = ["pymysql"]
130
134
  sql = ["sqlalchemy", "pymysql", "psycopg2"]
131
135
  litellm = ["litellm"]
132
136
  neo4j = ["neo4j"]
137
+ arango = ["python-arango", "arango-datasets"]
133
138
  metaphor = ["metaphor-python"]
134
139
  chainlit = ["chainlit", "python-socketio"]
135
140
  chromadb = ["chromadb"]
@@ -166,6 +171,7 @@ coverage = "^7.2.5"
166
171
  pytest-xdist = "^3.6.1"
167
172
  pytest-timeout = "^2.3.1"
168
173
  pytest-cov = "^5.0.0"
174
+ docker = "^7.1.0"
169
175
 
170
176
  [tool.poetry.group.docs]
171
177
  optional = true
@@ -1,64 +0,0 @@
1
- DEFAULT_SYS_MSG = """You are a data scientist and expert in Knowledge Graphs,
2
- with expertise in answering questions by interacting with a Neo4j graph database.
3
-
4
- The schema below describes the Neo4j database structure, node labels,
5
- relationship types, and property keys available in your Neo4j database.
6
- {schema}
7
- Do not make assumptions about the database schema before using the tools.
8
- Use the tools/functions to learn more about the database schema."""
9
-
10
- SCHEMA_TOOLS_SYS_MSG = """You are a data scientist and expert in Knowledge Graphs,
11
- with expertise in answering questions by querying Neo4j database.
12
- You have access to the following tools:
13
-
14
- - `get_schema` tool/function-call to get all the node labels, relationship
15
- types, and property keys available in your Neo4j database. You MUST use
16
- this tool BEFORE attempting to use the `retrieval_query` tool/function-call,
17
- to ensure that you are using the correct node labels, relationship types, and
18
- property keys in your `retrieval_query` tool/function-call.
19
-
20
- - `retrieval_query` tool/function-call to retrieve infomration from the graph database
21
- to answer questions.
22
-
23
- - `create_query` tool/function-call to execute cypher query that creates
24
- entities/relationships in the graph database.
25
-
26
-
27
- You must be smart about using the right node labels, relationship types, and property
28
- keys based on the english description. If you are thinking of using a node label,
29
- relationship type, or property key that does not exist, you are probably on the wrong
30
- track, so you should try your best to answer based on an existing table or column.
31
- DO NOT assume any nodes or relationships other than those above."""
32
-
33
- DEFAULT_NEO4J_CHAT_SYSTEM_MESSAGE = """
34
- {mode}
35
-
36
- You do not need to attempt answering a question with just one query.
37
- You could make a sequence of Neo4j queries to help you write the final query.
38
-
39
- RETRY-SUGGESTIONS:
40
- If you receive a null or other unexpected result,
41
- (a) make sure you use the available TOOLs correctly,
42
- (b) USE `get_schema` tool/function-call to get all the node labels, relationship
43
- types, and property keys available in your Neo4j database.
44
- (c) LABELS are CASE-SENSITIVE -- make sure you adhere to the exact label name
45
- you found in the schema.
46
- (d) see if you have made an assumption in your Neo4j query, and try another way,
47
- or use `retrieval_query` to explore the database contents before submitting your
48
- final query.
49
- (e) USE `create_query` tool/function-call to execute cypher query that creates
50
- entities/relationships in the graph database.
51
-
52
- Start by asking what I would like to know about the data.
53
-
54
- """
55
-
56
- ADDRESSING_INSTRUCTION = """
57
- IMPORTANT - Whenever you are NOT writing a CYPHER query, make sure you address the
58
- user using {prefix}User. You MUST use the EXACT syntax {prefix} !!!
59
-
60
- In other words, you ALWAYS write EITHER:
61
- - a CYPHER query using one of the tools,
62
- - OR address the user using {prefix}User.
63
-
64
- """