langroid 0.1.167__py3-none-any.whl → 0.1.169__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 +3 -2
- langroid/agent/chat_agent.py +7 -3
- langroid/agent/chat_document.py +3 -0
- langroid/agent/special/neo4j/__init__.py +0 -0
- langroid/agent/special/neo4j/neo4j_chat_agent.py +8 -8
- langroid/agent/special/neo4j/utils/__init__.py +0 -0
- langroid/agent/special/neo4j/utils/tools.py +2 -2
- langroid/agent/task.py +1 -5
- langroid/utils/logging.py +2 -1
- {langroid-0.1.167.dist-info → langroid-0.1.169.dist-info}/METADATA +1 -1
- {langroid-0.1.167.dist-info → langroid-0.1.169.dist-info}/RECORD +13 -11
- {langroid-0.1.167.dist-info → langroid-0.1.169.dist-info}/LICENSE +0 -0
- {langroid-0.1.167.dist-info → langroid-0.1.169.dist-info}/WHEEL +0 -0
langroid/agent/base.py
CHANGED
@@ -21,6 +21,7 @@ from typing import (
|
|
21
21
|
from pydantic import BaseSettings, ValidationError
|
22
22
|
from rich import print
|
23
23
|
from rich.console import Console
|
24
|
+
from rich.markup import escape
|
24
25
|
from rich.prompt import Prompt
|
25
26
|
|
26
27
|
from langroid.agent.chat_document import ChatDocMetaData, ChatDocument
|
@@ -449,7 +450,7 @@ class Agent(ABC):
|
|
449
450
|
# streaming was enabled, AND we did not find a cached response.
|
450
451
|
# If we are here, it means the response has not yet been displayed.
|
451
452
|
cached = f"[red]{self.indent}(cached)[/red]" if response.cached else ""
|
452
|
-
print(cached + "[green]" + response.message)
|
453
|
+
print(cached + "[green]" + escape(response.message))
|
453
454
|
async with self.lock:
|
454
455
|
self.update_token_usage(
|
455
456
|
response,
|
@@ -522,7 +523,7 @@ class Agent(ABC):
|
|
522
523
|
# If we are here, it means the response has not yet been displayed.
|
523
524
|
cached = f"[red]{self.indent}(cached)[/red]" if response.cached else ""
|
524
525
|
console.print(f"[green]{self.indent}", end="")
|
525
|
-
print(cached + "[green]" + response.message)
|
526
|
+
print(cached + "[green]" + escape(response.message))
|
526
527
|
self.update_token_usage(
|
527
528
|
response,
|
528
529
|
prompt,
|
langroid/agent/chat_agent.py
CHANGED
@@ -6,6 +6,7 @@ from typing import Dict, List, Optional, Set, Tuple, Type, cast
|
|
6
6
|
|
7
7
|
from rich import print
|
8
8
|
from rich.console import Console
|
9
|
+
from rich.markup import escape
|
9
10
|
|
10
11
|
from langroid.agent.base import Agent, AgentConfig
|
11
12
|
from langroid.agent.chat_document import ChatDocument
|
@@ -570,7 +571,10 @@ class ChatAgent(Agent):
|
|
570
571
|
raise ValueError(
|
571
572
|
"""
|
572
573
|
The message history is longer than the max chat context
|
573
|
-
length allowed, and we have run out of messages to drop.
|
574
|
+
length allowed, and we have run out of messages to drop.
|
575
|
+
HINT: In your `OpenAIGPTConfig` object, try increasing
|
576
|
+
`chat_context_length` or decreasing `max_output_tokens`.
|
577
|
+
"""
|
574
578
|
)
|
575
579
|
# drop the second message, i.e. first msg after the sys msg
|
576
580
|
# (typically user msg).
|
@@ -663,7 +667,7 @@ class ChatAgent(Agent):
|
|
663
667
|
else:
|
664
668
|
response_str = response.message
|
665
669
|
if not settings.quiet:
|
666
|
-
print(cached + "[green]" + response_str)
|
670
|
+
print(cached + "[green]" + escape(response_str))
|
667
671
|
self.update_token_usage(
|
668
672
|
response,
|
669
673
|
messages,
|
@@ -706,7 +710,7 @@ class ChatAgent(Agent):
|
|
706
710
|
else:
|
707
711
|
response_str = response.message
|
708
712
|
if not settings.quiet:
|
709
|
-
print(cached + "[green]" + response_str)
|
713
|
+
print(cached + "[green]" + escape(response_str))
|
710
714
|
|
711
715
|
self.update_token_usage(
|
712
716
|
response,
|
langroid/agent/chat_document.py
CHANGED
@@ -144,6 +144,9 @@ class ChatDocument(Document):
|
|
144
144
|
ChatDocument: ChatDocument representation of this LLMResponse.
|
145
145
|
"""
|
146
146
|
recipient, message = response.get_recipient_and_message()
|
147
|
+
message = message.strip()
|
148
|
+
if message in ["''", '""']:
|
149
|
+
message = ""
|
147
150
|
return ChatDocument(
|
148
151
|
content=message,
|
149
152
|
function_call=response.function_call,
|
File without changes
|
@@ -17,8 +17,8 @@ from langroid.agent.special.neo4j.utils.system_message import (
|
|
17
17
|
SCHEMA_TOOLS_SYS_MSG,
|
18
18
|
)
|
19
19
|
from langroid.agent.special.neo4j.utils.tools import (
|
20
|
-
|
21
|
-
|
20
|
+
CypherQueryTool,
|
21
|
+
GraphSchemaTool,
|
22
22
|
)
|
23
23
|
from langroid.mytypes import Entity
|
24
24
|
|
@@ -226,12 +226,12 @@ class Neo4jChatAgent(ChatAgent):
|
|
226
226
|
else:
|
227
227
|
print("[red]Database is not deleted!")
|
228
228
|
|
229
|
-
def make_query(self, msg:
|
229
|
+
def make_query(self, msg: CypherQueryTool) -> str:
|
230
230
|
""" "
|
231
231
|
Handle a GenerateCypherQueries message by executing a Cypher query and
|
232
232
|
returning the result.
|
233
233
|
Args:
|
234
|
-
msg (
|
234
|
+
msg (CypherQueryTool): The tool-message to handle.
|
235
235
|
|
236
236
|
Returns:
|
237
237
|
str: The result of executing the Cypherquery.
|
@@ -247,12 +247,12 @@ class Neo4jChatAgent(ChatAgent):
|
|
247
247
|
# The current query works well. But we could use the queries here:
|
248
248
|
# https://github.com/neo4j/NaLLM/blob/1af09cd117ba0777d81075c597a5081583568f9f/api/
|
249
249
|
# src/driver/neo4j.py#L30
|
250
|
-
def get_schema(self, msg:
|
250
|
+
def get_schema(self, msg: GraphSchemaTool | None) -> str:
|
251
251
|
"""
|
252
252
|
Retrieves the schema of a Neo4j graph database.
|
253
253
|
|
254
254
|
Args:
|
255
|
-
msg (
|
255
|
+
msg (GraphSchemaTool): An instance of GraphDatabaseSchema, typically
|
256
256
|
containing information or parameters needed for the database query.
|
257
257
|
|
258
258
|
Returns:
|
@@ -275,8 +275,8 @@ class Neo4jChatAgent(ChatAgent):
|
|
275
275
|
message = self._format_message()
|
276
276
|
self.config.system_message = self.config.system_message.format(mode=message)
|
277
277
|
super().__init__(self.config)
|
278
|
-
self.enable_message(
|
279
|
-
self.enable_message(
|
278
|
+
self.enable_message(CypherQueryTool)
|
279
|
+
self.enable_message(GraphSchemaTool)
|
280
280
|
|
281
281
|
def _format_message(self) -> str:
|
282
282
|
if self.driver is None:
|
File without changes
|
@@ -1,13 +1,13 @@
|
|
1
1
|
from langroid.agent.tool_message import ToolMessage
|
2
2
|
|
3
3
|
|
4
|
-
class
|
4
|
+
class CypherQueryTool(ToolMessage):
|
5
5
|
request: str = "make_query"
|
6
6
|
purpose: str = """Use this tool to send me the Generated Cypher query based on
|
7
7
|
text description and schema that I will provide you."""
|
8
8
|
cypherQuery: str
|
9
9
|
|
10
10
|
|
11
|
-
class
|
11
|
+
class GraphSchemaTool(ToolMessage):
|
12
12
|
request: str = "get_schema"
|
13
13
|
purpose: str = """Use this tool to get me the schema of the graph database."""
|
langroid/agent/task.py
CHANGED
@@ -1013,11 +1013,7 @@ class Task:
|
|
1013
1013
|
return (
|
1014
1014
|
result is not None
|
1015
1015
|
and not self._is_empty_message(result)
|
1016
|
-
|
1017
|
-
# # controller is stuck and we are done with task loop
|
1018
|
-
# NO_ANSWER not in result.content
|
1019
|
-
# or result.metadata.sender == self.controller
|
1020
|
-
# )
|
1016
|
+
and NO_ANSWER not in result.content
|
1021
1017
|
)
|
1022
1018
|
|
1023
1019
|
def log_message(
|
langroid/utils/logging.py
CHANGED
@@ -4,6 +4,7 @@ from typing import no_type_check
|
|
4
4
|
|
5
5
|
import colorlog
|
6
6
|
from rich.console import Console
|
7
|
+
from rich.markup import escape
|
7
8
|
|
8
9
|
|
9
10
|
# Define a function to set up the colored logger
|
@@ -125,6 +126,6 @@ class RichFileLogger:
|
|
125
126
|
with open(self.log_file, "a") as f:
|
126
127
|
if self.color:
|
127
128
|
console = Console(file=f, force_terminal=True, width=200)
|
128
|
-
console.print(message)
|
129
|
+
console.print(escape(message))
|
129
130
|
else:
|
130
131
|
print(message, file=f)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
langroid/__init__.py,sha256=I9edNDkpmfd5C4WvTONaGaTFzIlvFyp5GpFEaMCAKMk,778
|
2
2
|
langroid/agent/__init__.py,sha256=w2pap-rHrp41gMzdtzur2YY_m62LqQhF2Du-AmoIQi4,752
|
3
|
-
langroid/agent/base.py,sha256=
|
3
|
+
langroid/agent/base.py,sha256=X_B9WxTwRfTNTkDwNGzGU-tvgdwJ6AnW22vL0kl_97g,33285
|
4
4
|
langroid/agent/batch.py,sha256=Cg7Qv1yGi_M9rMl38_4-hjXPsoLlZrOSXDhbOFqUcKY,5593
|
5
|
-
langroid/agent/chat_agent.py,sha256=
|
6
|
-
langroid/agent/chat_document.py,sha256=
|
5
|
+
langroid/agent/chat_agent.py,sha256=vLHFUPzOVQlGfeXCOMxLi5gtTGOHX7q6JKf_926TFmg,35261
|
6
|
+
langroid/agent/chat_document.py,sha256=MRp2YCy5f3Q_yPoFXVyr1vGu48wz33UGxAUtMn7MJpo,7958
|
7
7
|
langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
langroid/agent/junk,sha256=LxfuuW7Cijsg0szAzT81OjWWv1PMNI-6w_-DspVIO2s,339
|
9
9
|
langroid/agent/openai_assistant.py,sha256=yBtxis64XOnxtJzlkwUoTm-wCyvKr4DGo9-laXYMok0,32654
|
@@ -15,9 +15,11 @@ langroid/agent/special/lance_rag/critic_agent.py,sha256=9izW4keCxVZEqrFOgyVUHD7N
|
|
15
15
|
langroid/agent/special/lance_rag/lance_rag_task.py,sha256=l_HQgrYY-CX2FwIsS961aEF3bYog3GDYo98fj0C0mSk,2889
|
16
16
|
langroid/agent/special/lance_rag/lance_tools.py,sha256=WypIS-3ZMDqY_PZEGB2K80-o4RfS43_OnER0dyFlsDY,1339
|
17
17
|
langroid/agent/special/lance_rag/query_planner_agent.py,sha256=dZXVano2NbRZy91nBcEW6LrvedsHfxL1oNCgMQEHZ-U,8016
|
18
|
-
langroid/agent/special/neo4j/
|
18
|
+
langroid/agent/special/neo4j/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
|
+
langroid/agent/special/neo4j/neo4j_chat_agent.py,sha256=XGAUft3IxzwuRze8rFJKuaJHhLVJxT478HCY3QYXC_4,11395
|
20
|
+
langroid/agent/special/neo4j/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
21
|
langroid/agent/special/neo4j/utils/system_message.py,sha256=7rwq4CYpb1-1AvGLJBI6-X8UIu5RP5LiWU9re-umXxs,1959
|
20
|
-
langroid/agent/special/neo4j/utils/tools.py,sha256=
|
22
|
+
langroid/agent/special/neo4j/utils/tools.py,sha256=mZWrfh-OMY96S947_sazwZuYPEYULKhnUkynHYtrdc0,440
|
21
23
|
langroid/agent/special/relevance_extractor_agent.py,sha256=lychVpSEhMzi_CdeLN1yO-O2AVOe2W0F3Ha8aC3nd9M,4624
|
22
24
|
langroid/agent/special/retriever_agent.py,sha256=uu6vqFg85uCVM-_DrXesYe2gH_-WcoHhlsKRlLuZPXk,1867
|
23
25
|
langroid/agent/special/sql/__init__.py,sha256=qUM-b4FfvIt0gYWP7_niyqR3OwVMMkuK2SyqUYWjyxs,207
|
@@ -28,7 +30,7 @@ langroid/agent/special/sql/utils/populate_metadata.py,sha256=zRjw31a1ZXvpx9bcmbt
|
|
28
30
|
langroid/agent/special/sql/utils/system_message.py,sha256=qKLHkvQWRQodTtPLPxr1GSLUYUFASZU8x-ybV67cB68,1885
|
29
31
|
langroid/agent/special/sql/utils/tools.py,sha256=6uB2424SLtmapui9ggcEr0ZTiB6_dL1-JRGgN8RK9Js,1332
|
30
32
|
langroid/agent/special/table_chat_agent.py,sha256=Gj_Iuq21_Ldyvzc8qhgsVuBLKqt0VIqivxCw_tH9Cu4,7772
|
31
|
-
langroid/agent/task.py,sha256=
|
33
|
+
langroid/agent/task.py,sha256=MU7IEY7131Q5I1BQmBl_7aTW2hGMu8TeqhMPBnEqdRo,46354
|
32
34
|
langroid/agent/tool_message.py,sha256=ngmWdiqMYbjF4Am0hsLyA9zK0Q9QF2ziec6FW0lPD90,7399
|
33
35
|
langroid/agent/tools/__init__.py,sha256=q-maq3k2BXhPAU99G0H6-j_ozoRvx15I1RFpPVicQIU,304
|
34
36
|
langroid/agent/tools/extract_tool.py,sha256=u5lL9rKBzaLBOrRyLnTAZ97pQ1uxyLP39XsWMnpaZpw,3789
|
@@ -90,7 +92,7 @@ langroid/utils/docker.py,sha256=kJQOLTgM0x9j9pgIIqp0dZNZCTvoUDhp6i8tYBq1Jr0,1105
|
|
90
92
|
langroid/utils/globals.py,sha256=VkTHhlqSz86oOPq65sjul0XU8I52UNaFC5vwybMQ74w,1343
|
91
93
|
langroid/utils/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
92
94
|
langroid/utils/llms/strings.py,sha256=CSAX9Z6FQOLXOzbLMe_Opqtc3ruDAKTTk7cPqc6Blh0,263
|
93
|
-
langroid/utils/logging.py,sha256=
|
95
|
+
langroid/utils/logging.py,sha256=CXe8w2gjFhhvgyGr1iwU--Je916H2rOrDNJosv5Tl3Y,3956
|
94
96
|
langroid/utils/output/__init__.py,sha256=Z58-2ZKnGpGNaKw_nEjHV_CHTzjMz-WRSRQnazTLrWU,289
|
95
97
|
langroid/utils/output/printing.py,sha256=5EsYB1O4qKhocW19aebOUzK82RD9U5nygbY21yo8gfg,2872
|
96
98
|
langroid/utils/pandas_utils.py,sha256=nSA1tIgOUTkRDn-IKq7HP8XGJcL6bA110LcPfRF7h8I,707
|
@@ -107,7 +109,7 @@ langroid/vector_store/meilisearch.py,sha256=d2huA9P-NoYRuAQ9ZeXJmMKr7ry8u90RUSR2
|
|
107
109
|
langroid/vector_store/momento.py,sha256=j6Eo6oIDN2fe7lsBOlCXJn3uvvERHHTFL5QJfeREeOM,10044
|
108
110
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
109
111
|
langroid/vector_store/qdrantdb.py,sha256=qt7Dye6rcgoe0551WzmOxRGIlJfL87D4MX7HdqxuEok,13393
|
110
|
-
langroid-0.1.
|
111
|
-
langroid-0.1.
|
112
|
-
langroid-0.1.
|
113
|
-
langroid-0.1.
|
112
|
+
langroid-0.1.169.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
113
|
+
langroid-0.1.169.dist-info/METADATA,sha256=tSniCcftzCMGcRzoLTV51kw7hGdTTM2afbNernwwl70,43613
|
114
|
+
langroid-0.1.169.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
115
|
+
langroid-0.1.169.dist-info/RECORD,,
|
File without changes
|
File without changes
|