langroid 0.6.3__py3-none-any.whl → 0.6.5__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.
@@ -265,10 +265,25 @@ class Neo4jChatAgent(ChatAgent):
265
265
  Returns:
266
266
  str: The result of executing the cypher_query.
267
267
  """
268
+ if not self.tried_schema:
269
+ return """
270
+ You did not yet use the `get_schema` tool to get the schema
271
+ of the neo4j knowledge-graph db. Use that tool first before using
272
+ the `retrieval_query` tool, to ensure you know all the correct
273
+ node labels, relationship types, and property keys available in
274
+ the database.
275
+ """
268
276
  query = msg.cypher_query
269
277
 
270
278
  logger.info(f"Executing Cypher query: {query}")
271
279
  response = self.read_query(query)
280
+ if isinstance(response.data, list) and len(response.data) == 0:
281
+ return """
282
+ No results found; check if your query used the right label names --
283
+ remember these are case sensitive, so you have to use the exact label
284
+ names you found in the schema.
285
+ Or retry using one of the RETRY-SUGGESTIONS in your instructions.
286
+ """
272
287
  if response.success:
273
288
  return json.dumps(response.data)
274
289
  else:
@@ -316,6 +331,7 @@ class Neo4jChatAgent(ChatAgent):
316
331
  behavior of 'self.read_query' method, which might raise exceptions related
317
332
  to database connectivity or query execution.
318
333
  """
334
+ self.tried_schema = True
319
335
  schema_result = self.read_query("CALL db.schema.visualization()")
320
336
  if schema_result.success:
321
337
  # ther is a possibility that the schema is empty, which is a valid response
@@ -326,6 +342,7 @@ class Neo4jChatAgent(ChatAgent):
326
342
 
327
343
  def _init_tool_messages(self) -> None:
328
344
  """Initialize message tools used for chatting."""
345
+ self.tried_schema = False
329
346
  message = self._format_message()
330
347
  self.config.system_message = self.config.system_message.format(mode=message)
331
348
  if self.config.addressing_prefix != "":
@@ -1,24 +1,29 @@
1
1
  DEFAULT_SYS_MSG = """You are a data scientist and expert in Knowledge Graphs,
2
2
  with expertise in answering questions by interacting with a Neo4j graph database.
3
3
 
4
- The schema maps the Neo4j database structure. node labels, relationship types,
5
- and property keys available in your Neo4j database.
4
+ The schema below describes the Neo4j database structure, node labels,
5
+ relationship types, and property keys available in your Neo4j database.
6
6
  {schema}
7
7
  Do not make assumptions about the database schema before using the tools.
8
- Use the tool/function to learn more about the database schema."""
8
+ Use the tools/functions to learn more about the database schema."""
9
9
 
10
10
  SCHEMA_TOOLS_SYS_MSG = """You are a data scientist and expert in Knowledge Graphs,
11
11
  with expertise in answering questions by querying Neo4j database.
12
- You have access to the following tools:
13
- - `retrieval_query` tool/function-call to retreive infomration from the graph 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
14
21
  to answer questions.
15
22
 
16
23
  - `create_query` tool/function-call to execute cypher query that creates
17
24
  entities/relationships in the graph database.
18
25
 
19
- - `get_schema` tool/function-call to get all the node labels, relationship
20
- types, and property keys available in your Neo4j database.
21
-
26
+
22
27
  You must be smart about using the right node labels, relationship types, and property
23
28
  keys based on the english description. If you are thinking of using a node label,
24
29
  relationship type, or property key that does not exist, you are probably on the wrong
@@ -30,11 +35,14 @@ DEFAULT_NEO4J_CHAT_SYSTEM_MESSAGE = """
30
35
 
31
36
  You do not need to attempt answering a question with just one query.
32
37
  You could make a sequence of Neo4j queries to help you write the final query.
33
- Also if you receive a null or other unexpected result,
38
+
39
+ RETRY-SUGGESTIONS:
40
+ If you receive a null or other unexpected result,
34
41
  (a) make sure you use the available TOOLs correctly,
35
42
  (b) USE `get_schema` tool/function-call to get all the node labels, relationship
36
43
  types, and property keys available in your Neo4j database.
37
- (c) LABELS may be CASE-SENSITIVE, so try using CASE-INSENSITIVE MATCHES,
44
+ (c) LABELS are CASE-SENSITIVE -- make sure you adhere to the exact label name
45
+ you found in the schema.
38
46
  (d) see if you have made an assumption in your Neo4j query, and try another way,
39
47
  or use `retrieval_query` to explore the database contents before submitting your
40
48
  final query.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
@@ -23,9 +23,9 @@ langroid/agent/special/lance_rag_new/query_planner_agent.py,sha256=JqO_5fKW8HPn-
23
23
  langroid/agent/special/lance_tools.py,sha256=BznV_r3LAFyybvBRa9KQ0oU7mPM3uQVfri7PFp7M_qc,1894
24
24
  langroid/agent/special/neo4j/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  langroid/agent/special/neo4j/csv_kg_chat.py,sha256=dRsAgMBa1H_EMI2YYgJR2Xyv1D7e4o3G9M64mTewq_c,6409
26
- langroid/agent/special/neo4j/neo4j_chat_agent.py,sha256=B5y4he__9QjNrjNyngv4rlfVx7QezQ4Turom-l_zjCg,12572
26
+ langroid/agent/special/neo4j/neo4j_chat_agent.py,sha256=xlyIxG3-OQhp6l-dW01HxkehPKMzv2Laqp0DcBJRSrM,13439
27
27
  langroid/agent/special/neo4j/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- langroid/agent/special/neo4j/utils/system_message.py,sha256=TxxA5RIYaTUIv6p2xubqUBuVgBLCfZNrHGOdX--OLVg,2625
28
+ langroid/agent/special/neo4j/utils/system_message.py,sha256=_2NKX2Sx_7nLGNk_0rUyDkgTHZJuKm_DgtG7M_BFPkY,2920
29
29
  langroid/agent/special/relevance_extractor_agent.py,sha256=zIx8GUdVo1aGW6ASla0NPQjYYIpmriK_TYMijqAx3F8,4796
30
30
  langroid/agent/special/retriever_agent.py,sha256=lvMvf-u9rSosg4YASuFdUbGLgkzLPknXAbJZfZ1LZCc,1868
31
31
  langroid/agent/special/sql/__init__.py,sha256=mWfmm1QpXCezpFOS2eI57M0L_Ok3q5_ukG8tXBnBrEA,319
@@ -134,8 +134,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
134
134
  langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
135
135
  langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
136
136
  langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
137
- pyproject.toml,sha256=A63IQrki6kjMdP3gnIaZJmd500tm1rYcajBojMoC3xE,7063
138
- langroid-0.6.3.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
139
- langroid-0.6.3.dist-info/METADATA,sha256=nQGYokvPMKhMUENLf7qw4IpW7tCgu4RvssqQQ20m-so,54402
140
- langroid-0.6.3.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
141
- langroid-0.6.3.dist-info/RECORD,,
137
+ pyproject.toml,sha256=DzLYdTaZkEq7skUJyKoSIG57xLpZlLmL7ws2KwYPBe4,7063
138
+ langroid-0.6.5.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
139
+ langroid-0.6.5.dist-info/METADATA,sha256=rSOgUJQHwzIdMef_inx5Up7kT9BUUrbroPVr-fg_9zo,54402
140
+ langroid-0.6.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
141
+ langroid-0.6.5.dist-info/RECORD,,
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langroid"
3
- version = "0.6.3"
3
+ version = "0.6.5"
4
4
  description = "Harness LLMs with Multi-Agent Programming"
5
5
  authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
6
6
  readme = "README.md"