langroid 0.16.6__py3-none-any.whl → 0.17.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 +45 -21
- langroid/agent/chat_agent.py +22 -14
- langroid/agent/chat_document.py +22 -13
- langroid/agent/tool_message.py +11 -11
- langroid/agent/tools/file_tools.py +234 -0
- langroid/agent/xml_tool_message.py +239 -0
- langroid/language_models/openai_gpt.py +4 -2
- langroid/utils/constants.py +2 -0
- langroid/utils/git_utils.py +251 -0
- langroid/utils/system.py +78 -0
- {langroid-0.16.6.dist-info → langroid-0.17.0.dist-info}/METADATA +6 -3
- {langroid-0.16.6.dist-info → langroid-0.17.0.dist-info}/RECORD +15 -16
- pyproject.toml +3 -2
- langroid/agent/tools/extract_tool.py +0 -96
- langroid/agent/tools/generator_tool.py +0 -20
- langroid/agent/tools/note_tool.py +0 -0
- langroid/agent/tools/run_python_code.py +0 -60
- {langroid-0.16.6.dist-info → langroid-0.17.0.dist-info}/LICENSE +0 -0
- {langroid-0.16.6.dist-info → langroid-0.17.0.dist-info}/WHEEL +0 -0
@@ -1,11 +1,11 @@
|
|
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=hX_IGnEWcIhFGaLyhkZr6HWe_nQ4y6ERko-2H9mTkhM,64047
|
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=Qedk1-CBCgo9PdaIa7AboLBFCTgAMg9q5nGmoqpZ378,22050
|
7
|
-
langroid/agent/chat_agent.py,sha256=
|
8
|
-
langroid/agent/chat_document.py,sha256=
|
7
|
+
langroid/agent/chat_agent.py,sha256=m1fs-XsBzusRicwBETId3dpTQG8qEaS0yym_o4mfAI0,49931
|
8
|
+
langroid/agent/chat_document.py,sha256=FZ_PkeKU5OVp1IUlMvspfqxIXzlyd7J_F32DSYrxQ7E,17651
|
9
9
|
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
|
@@ -34,21 +34,19 @@ langroid/agent/special/sql/utils/tools.py,sha256=vFYysk6Vi7HJjII8B4RitA3pt_z3gkS
|
|
34
34
|
langroid/agent/special/table_chat_agent.py,sha256=d9v2wsblaRx7oMnKhLV7uO_ujvk9gh59pSGvBXyeyNc,9659
|
35
35
|
langroid/agent/structured_message.py,sha256=y7pud1EgRNeTFZlJmBkLmwME3yQJ_IYik-Xds9kdZbY,282
|
36
36
|
langroid/agent/task.py,sha256=GDnP24wsoXSZbwlG0g-OmKWM_pY-G4KGUgnCEbCsrYM,84660
|
37
|
-
langroid/agent/tool_message.py,sha256=
|
37
|
+
langroid/agent/tool_message.py,sha256=jkN7uq7YwUC_wBcSCNUYjrB_His2YCfQay_lqIa4Tww,10498
|
38
38
|
langroid/agent/tools/__init__.py,sha256=IMgCte-_ZIvCkozGQmvMqxIw7_nKLKzD78ccJL1bnQU,804
|
39
39
|
langroid/agent/tools/duckduckgo_search_tool.py,sha256=NhsCaGZkdv28nja7yveAhSK_w6l_Ftym8agbrdzqgfo,1935
|
40
|
-
langroid/agent/tools/
|
41
|
-
langroid/agent/tools/generator_tool.py,sha256=y0fB0ZObjA0b3L0uSTtrqRCKHDUR95arBftqiUeKD2o,663
|
40
|
+
langroid/agent/tools/file_tools.py,sha256=GjPB5YDILucYapElnvvoYpGJuZQ25ecLs2REv7edPEo,7292
|
42
41
|
langroid/agent/tools/google_search_tool.py,sha256=y7b-3FtgXf0lfF4AYxrZ3K5pH2dhidvibUOAGBE--WI,1456
|
43
42
|
langroid/agent/tools/metaphor_search_tool.py,sha256=qj4gt453cLEX3EGW7nVzVu6X7LCdrwjSlcNY0qJW104,2489
|
44
|
-
langroid/agent/tools/note_tool.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
43
|
langroid/agent/tools/orchestration.py,sha256=afIt8Ah0dfrY2TQ7aNrkxUFLV288VTQ0L40Yse_-HeY,10785
|
46
44
|
langroid/agent/tools/recipient_tool.py,sha256=0m2kQhYKTeGujAxhSPqH5z6hSAhVB_Dqour6uul2U30,9427
|
47
45
|
langroid/agent/tools/retrieval_tool.py,sha256=2q2pfoYbZNfbWQ0McxrtmfF0ekGglIgRl-6uF26pa-E,871
|
48
46
|
langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
|
49
|
-
langroid/agent/tools/run_python_code.py,sha256=BvoxYzzHijU-p4703n2iVlt5BCieR1oMSy50w0tQZAg,1787
|
50
47
|
langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
|
51
48
|
langroid/agent/typed_task.py,sha256=oxja0Z3uLTv0BcR1xIMqDpo85MIGOruz4XsZ4ghjsW4,689
|
49
|
+
langroid/agent/xml_tool_message.py,sha256=W4mjZlvizuYRDGOtttoIzJjfB8wRcV87nE8ZGfg_hqs,9043
|
52
50
|
langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
51
|
langroid/cachedb/__init__.py,sha256=icAT2s7Vhf-ZGUeqpDQGNU6ob6o0aFEyjwcxxUGRFjg,225
|
54
52
|
langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
|
@@ -72,7 +70,7 @@ langroid/language_models/azure_openai.py,sha256=G4le3j4YLHV7IwgB2C37hO3MKijZ1Kjy
|
|
72
70
|
langroid/language_models/base.py,sha256=3DjxxVL7heuTLYRvNMjaIKS-eP8pMDvu8Gbkb6N3B0U,22286
|
73
71
|
langroid/language_models/config.py,sha256=9Q8wk5a7RQr8LGMT_0WkpjY8S4ywK06SalVRjXlfCiI,378
|
74
72
|
langroid/language_models/mock_lm.py,sha256=HuiAvjHiCfffYF5xjFJUq945HVTW0QPbeUUctOnNCzQ,3868
|
75
|
-
langroid/language_models/openai_gpt.py,sha256=
|
73
|
+
langroid/language_models/openai_gpt.py,sha256=haPcPe3CXAXpdU39rxGThObfv_YV0UivnL2hEdyyaHk,64810
|
76
74
|
langroid/language_models/prompt_formatter/__init__.py,sha256=2-5cdE24XoFDhifOLl8yiscohil1ogbP1ECkYdBlBsk,372
|
77
75
|
langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
|
78
76
|
langroid/language_models/prompt_formatter/hf_formatter.py,sha256=PVJppmjRvD-2DF-XNC6mE05vTZ9wbu37SmXwZBQhad0,5055
|
@@ -113,8 +111,9 @@ langroid/utils/__init__.py,sha256=Sruos2tB4G7Tn0vlblvYlX9PEGR0plI2uE0PJ4d_EC4,35
|
|
113
111
|
langroid/utils/algorithms/__init__.py,sha256=WylYoZymA0fnzpB4vrsH_0n7WsoLhmuZq8qxsOCjUpM,41
|
114
112
|
langroid/utils/algorithms/graph.py,sha256=JbdpPnUOhw4-D6O7ou101JLA3xPCD0Lr3qaPoFCaRfo,2866
|
115
113
|
langroid/utils/configuration.py,sha256=LgjHGB0qgKKTwBaVt84APiqvJbz6pLwylUvHWYmzyP0,3303
|
116
|
-
langroid/utils/constants.py,sha256=
|
114
|
+
langroid/utils/constants.py,sha256=vKIdkAJwyPT-bRA5MDPiOl7-EppBRmewRBIOcdXi4I4,959
|
117
115
|
langroid/utils/docker.py,sha256=kJQOLTgM0x9j9pgIIqp0dZNZCTvoUDhp6i8tYBq1Jr0,1105
|
116
|
+
langroid/utils/git_utils.py,sha256=lNvUd612NhOGNS1l7rN_JV6reoKf8BuJjNwedRTZvS8,7909
|
118
117
|
langroid/utils/globals.py,sha256=Az9dOFqR6n9CoTYSqa2kLikQWS0oCQ9DFQIQAnG-2q8,1355
|
119
118
|
langroid/utils/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
120
119
|
langroid/utils/llms/strings.py,sha256=CSAX9Z6FQOLXOzbLMe_Opqtc3ruDAKTTk7cPqc6Blh0,263
|
@@ -126,7 +125,7 @@ langroid/utils/output/printing.py,sha256=yzPJZN-8_jyOJmI9N_oLwEDfjMwVgk3IDiwnZ4e
|
|
126
125
|
langroid/utils/output/status.py,sha256=rzbE7mDJcgNNvdtylCseQcPGCGghtJvVq3lB-OPJ49E,1049
|
127
126
|
langroid/utils/pandas_utils.py,sha256=UctS986Jtl_MvU5rA7-GfrjEHXP7MNu8ePhepv0bTn0,755
|
128
127
|
langroid/utils/pydantic_utils.py,sha256=iRy7uQhHhQmIDZTTPNX5jXb6fqefMe9N67p3fPfOmTI,20624
|
129
|
-
langroid/utils/system.py,sha256=
|
128
|
+
langroid/utils/system.py,sha256=CZKEnERYMzFLdb2vBE5SfQRX5yeG-2AnezjmycsvQAU,7651
|
130
129
|
langroid/utils/types.py,sha256=4GrOnU3HLWh-UwaUPp7LlB3V413q3K5OSzc0ggDoQ6A,2510
|
131
130
|
langroid/utils/web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
132
131
|
langroid/utils/web/login.py,sha256=1iz9eUAHa87vpKIkzwkmFa00avwFWivDSAr7QUhK7U0,2528
|
@@ -138,8 +137,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
|
|
138
137
|
langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
|
139
138
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
140
139
|
langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
|
141
|
-
pyproject.toml,sha256=
|
142
|
-
langroid-0.
|
143
|
-
langroid-0.
|
144
|
-
langroid-0.
|
145
|
-
langroid-0.
|
140
|
+
pyproject.toml,sha256=olj3ishnFpF3nPogWJJYBDdduQUnRQiWD1qM08LKna0,7179
|
141
|
+
langroid-0.17.0.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
142
|
+
langroid-0.17.0.dist-info/METADATA,sha256=3PBPiOQIuduXHEPuZEqnPV3OjgnfIJpxc33dONV2GM0,56325
|
143
|
+
langroid-0.17.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
144
|
+
langroid-0.17.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.17.0"
|
4
4
|
description = "Harness LLMs with Multi-Agent Programming"
|
5
5
|
authors = ["Prasad Chalasani <pchalasani@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -87,8 +87,9 @@ nest-asyncio = "^1.6.0"
|
|
87
87
|
async-generator = "^1.10"
|
88
88
|
|
89
89
|
python-magic = "^0.4.27"
|
90
|
-
json-repair = "^0.29.
|
90
|
+
json-repair = "^0.29.9"
|
91
91
|
cerebras-cloud-sdk = "^1.1.0"
|
92
|
+
gitpython = "^3.1.43"
|
92
93
|
|
93
94
|
|
94
95
|
[tool.poetry.extras]
|
@@ -1,96 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
A tool to extract portions from previous (numbered) messages in
|
3
|
-
the chat history.
|
4
|
-
The idea is that when an LLM wants to (or is asked to) simply extract
|
5
|
-
portions of a message verbatim, it should use this tool/function to
|
6
|
-
SPECIFY what should be extracted, rather than actually extracting it.
|
7
|
-
This will usually be much cheaper and faster than actually writing out the extracted
|
8
|
-
text. The handler of this tool/function will then extract the text and send it back.
|
9
|
-
"""
|
10
|
-
|
11
|
-
from typing import Protocol, no_type_check
|
12
|
-
|
13
|
-
from jinja2 import DictLoader, Environment
|
14
|
-
|
15
|
-
from langroid.agent.tool_message import ToolMessage
|
16
|
-
from langroid.language_models.base import LLMMessage
|
17
|
-
|
18
|
-
|
19
|
-
def extract_between(value: str, start_word: str, end_word: str) -> str:
|
20
|
-
"""
|
21
|
-
Extract the substring between two words in a string.
|
22
|
-
NOTE: If there are multiple occurrences of the start_word, the first one is used,
|
23
|
-
and if there are multiple occurrences of the end_word, the first one after the
|
24
|
-
start_word is used.
|
25
|
-
|
26
|
-
We do not handle the case of multiple occurrences of the start_word, followed by
|
27
|
-
multiple occurrences of the end_word
|
28
|
-
|
29
|
-
Args:
|
30
|
-
value (str): the string to extract from
|
31
|
-
start_word (str): the word that starts the substring
|
32
|
-
end_word (str): the word that ends the substring
|
33
|
-
|
34
|
-
Returns:
|
35
|
-
str: the substring between the two words
|
36
|
-
"""
|
37
|
-
try:
|
38
|
-
start_index = value.index(start_word) + len(start_word)
|
39
|
-
end_index = value.index(end_word, start_index)
|
40
|
-
return value[start_index:end_index].strip()
|
41
|
-
except ValueError:
|
42
|
-
return ""
|
43
|
-
|
44
|
-
|
45
|
-
class HasMessageHistory(Protocol):
|
46
|
-
"""
|
47
|
-
Defines the fields expected in a class that enables this tool.
|
48
|
-
"""
|
49
|
-
|
50
|
-
message_history: list[LLMMessage]
|
51
|
-
|
52
|
-
|
53
|
-
class ExtractTool(ToolMessage):
|
54
|
-
request: str = "extract"
|
55
|
-
purpose: str = """
|
56
|
-
To generate a message in the form of a <jinja_template>,
|
57
|
-
using the Jinja templating language, where the
|
58
|
-
the i'th message is referred to as msg[i], and integer indices are used
|
59
|
-
to specify which part of the message to extract, e.g. msg[2][13:45].
|
60
|
-
"""
|
61
|
-
jinja_template: str
|
62
|
-
|
63
|
-
@classmethod
|
64
|
-
def instructions(cls) -> str:
|
65
|
-
return """
|
66
|
-
In a conversation with the user, your responses may sometimes use verbatim
|
67
|
-
extracts of previous messages in the conversation. You are an expert at
|
68
|
-
Jinja templating syntax, and you will rely on this syntax whenever you find
|
69
|
-
yourself wanting to repeat verbatim text from earlier parts of the
|
70
|
-
conversation.
|
71
|
-
In your Jinja templates you can use references like {{msg[3][3:100]}} to
|
72
|
-
indicate that the user should substitute the content of message number 3
|
73
|
-
(assume first msg is number 1), starting at position 3 and ending at 100.
|
74
|
-
|
75
|
-
For example you may respond with something like:
|
76
|
-
|
77
|
-
The story started like this: {{msg[5][45:89]}}. Then John came home and
|
78
|
-
{{msg[2][4:19}}.
|
79
|
-
|
80
|
-
VERY IMPORTANT --
|
81
|
-
(a) your FIRST priority is to generate messages that would sound natural
|
82
|
-
when the jinja templates are rendered.
|
83
|
-
|
84
|
-
(b) your NEXT priority is to ALWAYS RELY on the above JINJA scheme when
|
85
|
-
your intended message would contain verbatim text from previous messages.
|
86
|
-
|
87
|
-
(c) Do not simply use large verbatim parts of previous messages, when doing
|
88
|
-
so may not result in natural responses.
|
89
|
-
"""
|
90
|
-
|
91
|
-
@no_type_check
|
92
|
-
def handle(self: HasMessageHistory) -> str:
|
93
|
-
msg = self.message_history
|
94
|
-
env = Environment(loader=DictLoader({"base": self.jinja_template}))
|
95
|
-
template = env.get_template("base")
|
96
|
-
return template.render(msg=msg)
|
@@ -1,20 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
A tool to generate a message from previous (numbered) messages in the chat history.
|
3
|
-
The idea is that when an LLM is generating text that is a deterministic transformation
|
4
|
-
of a previous message, then specifying the transformation can be much cheaper
|
5
|
-
than actually generating the transformation.
|
6
|
-
"""
|
7
|
-
|
8
|
-
from langroid.agent.tool_message import ToolMessage
|
9
|
-
|
10
|
-
|
11
|
-
class GeneratorTool(ToolMessage):
|
12
|
-
request: str = ""
|
13
|
-
purpose: str = """
|
14
|
-
To generate a message where the parts within curly braces specify
|
15
|
-
what should be inserted, using a substitution specification.
|
16
|
-
"""
|
17
|
-
rules: str
|
18
|
-
|
19
|
-
def handle(self) -> None:
|
20
|
-
pass
|
File without changes
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import io
|
2
|
-
import sys
|
3
|
-
from typing import List, Tuple
|
4
|
-
|
5
|
-
from langroid.agent.tool_message import ToolMessage
|
6
|
-
|
7
|
-
|
8
|
-
class RunPythonCodeTool(ToolMessage):
|
9
|
-
"""
|
10
|
-
Tool/function to run code generated by the LLM.
|
11
|
-
The code is assumed to be self-contained, i.e. it contains all necessary imports
|
12
|
-
and does not depend on any external variables.
|
13
|
-
"""
|
14
|
-
|
15
|
-
request: str = "run_python_code"
|
16
|
-
purpose: str = """
|
17
|
-
To run python <code> and return the results to answer a question.
|
18
|
-
"""
|
19
|
-
code: str
|
20
|
-
|
21
|
-
@classmethod
|
22
|
-
def examples(cls) -> List["ToolMessage" | Tuple[str, "ToolMessage"]]:
|
23
|
-
return [
|
24
|
-
cls(code="import numpy as np\nnp.square(9)"),
|
25
|
-
]
|
26
|
-
|
27
|
-
def handle(self) -> str:
|
28
|
-
"""
|
29
|
-
Handle a RunPythonCodeTool message by running the code and returning the result.
|
30
|
-
Returns:
|
31
|
-
str: The result of running the code along with any print output.
|
32
|
-
"""
|
33
|
-
code = self.code
|
34
|
-
|
35
|
-
# Create a string-based I/O stream
|
36
|
-
code_out = io.StringIO()
|
37
|
-
|
38
|
-
# Temporarily redirect standard output to our string-based I/O stream
|
39
|
-
sys.stdout = code_out
|
40
|
-
|
41
|
-
try:
|
42
|
-
eval_result = eval(code, {})
|
43
|
-
except Exception as e:
|
44
|
-
eval_result = f"ERROR: {type(e)}: {e}"
|
45
|
-
|
46
|
-
if eval_result is None:
|
47
|
-
eval_result = ""
|
48
|
-
|
49
|
-
# Always restore the original standard output
|
50
|
-
sys.stdout = sys.__stdout__
|
51
|
-
|
52
|
-
# Get the resulting string from the I/O stream
|
53
|
-
print_result = code_out.getvalue() or ""
|
54
|
-
sep = "\n" if print_result else ""
|
55
|
-
# Combine the print and eval results
|
56
|
-
result = f"{print_result}{sep}{eval_result}"
|
57
|
-
if result == "":
|
58
|
-
result = "No result"
|
59
|
-
# Return the result
|
60
|
-
return result
|
File without changes
|
File without changes
|