langroid 0.19.5__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.
- langroid/agent/base.py +19 -13
- langroid/agent/special/arangodb/arangodb_agent.py +514 -0
- langroid/agent/special/arangodb/system_messages.py +157 -0
- langroid/agent/special/arangodb/tools.py +39 -0
- langroid/agent/special/neo4j/neo4j_chat_agent.py +120 -54
- langroid/agent/special/neo4j/system_messages.py +120 -0
- langroid/agent/special/neo4j/tools.py +32 -0
- langroid/agent/special/sql/sql_chat_agent.py +8 -3
- langroid/agent/task.py +1 -1
- langroid/parsing/parser.py +6 -0
- {langroid-0.19.5.dist-info → langroid-0.20.0.dist-info}/METADATA +5 -1
- {langroid-0.19.5.dist-info → langroid-0.20.0.dist-info}/RECORD +16 -12
- pyproject.toml +7 -1
- langroid/agent/special/neo4j/utils/system_message.py +0 -64
- /langroid/agent/special/{neo4j/utils → arangodb}/__init__.py +0 -0
- {langroid-0.19.5.dist-info → langroid-0.20.0.dist-info}/LICENSE +0 -0
- {langroid-0.19.5.dist-info → langroid-0.20.0.dist-info}/WHEEL +0 -0
@@ -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,7 +1226,6 @@ class Task:
|
|
1226
1226
|
# reset stuck counter since we made progress
|
1227
1227
|
self.n_stalled_steps = 0
|
1228
1228
|
|
1229
|
-
|
1230
1229
|
if self.pending_message is not None:
|
1231
1230
|
if (
|
1232
1231
|
self._is_done_response(result, r)
|
@@ -1906,6 +1905,7 @@ class Task:
|
|
1906
1905
|
# user, then wait for user response
|
1907
1906
|
self.pending_message is not None
|
1908
1907
|
and self.pending_message.metadata.recipient == Entity.USER
|
1908
|
+
and not self.agent.has_tool_message_attempt(self.pending_message)
|
1909
1909
|
)
|
1910
1910
|
|
1911
1911
|
def _can_respond(self, e: Responder) -> bool:
|
langroid/parsing/parser.py
CHANGED
@@ -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.
|
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=
|
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=
|
23
|
-
langroid/agent/special/neo4j/
|
24
|
-
langroid/agent/special/neo4j/
|
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=
|
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,7 +37,7 @@ 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=
|
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
|
@@ -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=
|
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=
|
141
|
-
langroid-0.
|
142
|
-
langroid-0.
|
143
|
-
langroid-0.
|
144
|
-
langroid-0.
|
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.
|
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
|
-
"""
|
File without changes
|
File without changes
|
File without changes
|