langroid 0.19.0__py3-none-any.whl → 0.19.1__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/xml_tool_message.py +49 -24
- {langroid-0.19.0.dist-info → langroid-0.19.1.dist-info}/METADATA +3 -2
- {langroid-0.19.0.dist-info → langroid-0.19.1.dist-info}/RECORD +6 -6
- pyproject.toml +1 -1
- {langroid-0.19.0.dist-info → langroid-0.19.1.dist-info}/LICENSE +0 -0
- {langroid-0.19.0.dist-info → langroid-0.19.1.dist-info}/WHEEL +0 -0
@@ -1,4 +1,5 @@
|
|
1
|
-
from
|
1
|
+
from collections.abc import Mapping
|
2
|
+
from typing import Any, Dict, List, Optional, get_args, get_origin
|
2
3
|
|
3
4
|
from lxml import etree
|
4
5
|
|
@@ -133,15 +134,6 @@ class XMLToolMessage(ToolMessage):
|
|
133
134
|
|
134
135
|
@classmethod
|
135
136
|
def format_instructions(cls, tool: bool = False) -> str:
|
136
|
-
"""
|
137
|
-
Instructions to the LLM showing how to use the XML tool.
|
138
|
-
|
139
|
-
Args:
|
140
|
-
tool: Not used in this implementation, kept for compatibility.
|
141
|
-
|
142
|
-
Returns:
|
143
|
-
str: instructions on how to use the XML message
|
144
|
-
"""
|
145
137
|
fields = [
|
146
138
|
f
|
147
139
|
for f in cls.__fields__.keys()
|
@@ -165,35 +157,62 @@ class XMLToolMessage(ToolMessage):
|
|
165
157
|
nonlocal preamble, xml_format
|
166
158
|
current_path = f"{path}.{field_name}" if path else field_name
|
167
159
|
|
168
|
-
|
160
|
+
origin = get_origin(field_type)
|
161
|
+
args = get_args(field_type)
|
162
|
+
|
163
|
+
if (
|
164
|
+
origin is None
|
165
|
+
and isinstance(field_type, type)
|
166
|
+
and issubclass(field_type, BaseModel)
|
167
|
+
):
|
169
168
|
preamble += (
|
170
169
|
f"{field_name.upper()} = [nested structure for {field_name}]\n"
|
171
170
|
)
|
172
171
|
xml_format += f"{indent}<{field_name}>\n"
|
173
172
|
for sub_field, sub_field_info in field_type.__fields__.items():
|
174
173
|
format_field(
|
175
|
-
sub_field,
|
174
|
+
sub_field,
|
175
|
+
sub_field_info.outer_type_,
|
176
|
+
indent + " ",
|
177
|
+
current_path,
|
176
178
|
)
|
177
179
|
xml_format += f"{indent}</{field_name}>\n"
|
178
|
-
elif
|
179
|
-
item_type =
|
180
|
-
|
180
|
+
elif origin in (list, List) or (field_type is list):
|
181
|
+
item_type = args[0] if args else Any
|
182
|
+
if isinstance(item_type, type) and issubclass(item_type, BaseModel):
|
183
|
+
preamble += (
|
184
|
+
f"{field_name.upper()} = "
|
185
|
+
f"[list of nested structures for {field_name}]\n"
|
186
|
+
)
|
187
|
+
else:
|
188
|
+
preamble += (
|
189
|
+
f"{field_name.upper()} = "
|
190
|
+
f"[list of {getattr(item_type, '__name__', str(item_type))} "
|
191
|
+
f"for {field_name}]\n"
|
192
|
+
)
|
181
193
|
xml_format += f"{indent}<{field_name}>\n"
|
182
|
-
xml_format +=
|
194
|
+
xml_format += (
|
195
|
+
f"{indent} <item>"
|
196
|
+
f"[{getattr(item_type, '__name__', str(item_type))} value]"
|
197
|
+
f"</item>\n"
|
198
|
+
)
|
183
199
|
xml_format += f"{indent} ...\n"
|
184
200
|
xml_format += f"{indent}</{field_name}>\n"
|
185
|
-
elif
|
186
|
-
|
201
|
+
elif origin in (dict, Dict) or (
|
202
|
+
isinstance(field_type, type) and issubclass(field_type, Mapping)
|
203
|
+
):
|
204
|
+
key_type, value_type = args if len(args) == 2 else (Any, Any)
|
187
205
|
preamble += (
|
188
206
|
f"{field_name.upper()} = "
|
189
|
-
f"[dictionary with
|
190
|
-
f"{
|
207
|
+
f"[dictionary with "
|
208
|
+
f"{getattr(key_type, '__name__', str(key_type))} keys and "
|
209
|
+
f"{getattr(value_type, '__name__', str(value_type))} values]\n"
|
191
210
|
)
|
192
211
|
xml_format += f"{indent}<{field_name}>\n"
|
193
212
|
xml_format += (
|
194
|
-
f"{indent} <{key_type
|
195
|
-
f"[{value_type
|
196
|
-
f"</{key_type
|
213
|
+
f"{indent} <{getattr(key_type, '__name__', str(key_type))}>"
|
214
|
+
f"[{getattr(value_type, '__name__', str(value_type))} value]"
|
215
|
+
f"</{getattr(key_type, '__name__', str(key_type))}>\n"
|
197
216
|
)
|
198
217
|
xml_format += f"{indent} ...\n"
|
199
218
|
xml_format += f"{indent}</{field_name}>\n"
|
@@ -213,7 +232,10 @@ class XMLToolMessage(ToolMessage):
|
|
213
232
|
verbatim_fields = cls.find_verbatim_fields()
|
214
233
|
|
215
234
|
for field in fields:
|
216
|
-
|
235
|
+
field_info = cls.__fields__[field]
|
236
|
+
field_type = (
|
237
|
+
field_info.outer_type_
|
238
|
+
) # Use outer_type_ to get the actual type including List, etc.
|
217
239
|
format_field(field, field_type)
|
218
240
|
|
219
241
|
xml_format += f"</{cls.Config.root_element}>"
|
@@ -260,6 +282,9 @@ class XMLToolMessage(ToolMessage):
|
|
260
282
|
def create_element(
|
261
283
|
parent: etree._Element, name: str, value: Any, path: str = ""
|
262
284
|
) -> None:
|
285
|
+
if value is None:
|
286
|
+
return
|
287
|
+
|
263
288
|
elem = etree.SubElement(parent, name)
|
264
289
|
current_path = f"{path}.{name}" if path else name
|
265
290
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.19.
|
3
|
+
Version: 0.19.1
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
License: MIT
|
6
6
|
Author: Prasad Chalasani
|
@@ -153,7 +153,8 @@ This Multi-Agent paradigm is inspired by the
|
|
153
153
|
(but you do not need to know anything about this!).
|
154
154
|
|
155
155
|
`Langroid` is a fresh take on LLM app-development, where considerable thought has gone
|
156
|
-
into simplifying the developer experience;
|
156
|
+
into simplifying the developer experience;
|
157
|
+
it does not use `Langchain`, or any other LLM framework.
|
157
158
|
|
158
159
|
:fire: Read the (WIP) [overview of the langroid architecture](https://langroid.github.io/langroid/blog/2024/08/15/overview-of-langroids-multi-agent-architecture-prelim/)
|
159
160
|
|
@@ -46,7 +46,7 @@ langroid/agent/tools/retrieval_tool.py,sha256=2q2pfoYbZNfbWQ0McxrtmfF0ekGglIgRl-
|
|
46
46
|
langroid/agent/tools/rewind_tool.py,sha256=XAXL3BpNhCmBGYq_qi_sZfHJuIw7NY2jp4wnojJ7WRs,5606
|
47
47
|
langroid/agent/tools/segment_extract_tool.py,sha256=__srZ_VGYLVOdPrITUM8S0HpmX4q7r5FHWMDdHdEv8w,1440
|
48
48
|
langroid/agent/typed_task.py,sha256=oxja0Z3uLTv0BcR1xIMqDpo85MIGOruz4XsZ4ghjsW4,689
|
49
|
-
langroid/agent/xml_tool_message.py,sha256=
|
49
|
+
langroid/agent/xml_tool_message.py,sha256=OwmHqHqagJOvC7U000z767WOqWztlJXa7A5gK0csfck,14429
|
50
50
|
langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
51
51
|
langroid/cachedb/__init__.py,sha256=icAT2s7Vhf-ZGUeqpDQGNU6ob6o0aFEyjwcxxUGRFjg,225
|
52
52
|
langroid/cachedb/base.py,sha256=ztVjB1DtN6pLCujCWnR6xruHxwVj3XkYniRTYAKKqk0,1354
|
@@ -137,8 +137,8 @@ langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3Hmh
|
|
137
137
|
langroid/vector_store/momento.py,sha256=qR-zBF1RKVHQZPZQYW_7g-XpTwr46p8HJuYPCkfJbM4,10534
|
138
138
|
langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
|
139
139
|
langroid/vector_store/qdrantdb.py,sha256=v88lqFkepADvlN6lByUj9I4NEKa9X9lWH16uTPPbYrE,17457
|
140
|
-
pyproject.toml,sha256=
|
141
|
-
langroid-0.19.
|
142
|
-
langroid-0.19.
|
143
|
-
langroid-0.19.
|
144
|
-
langroid-0.19.
|
140
|
+
pyproject.toml,sha256=cs7STWXoyn2Mat0iWQcywwjrxRYO7Y4nw5gc8udj9vo,7251
|
141
|
+
langroid-0.19.1.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
142
|
+
langroid-0.19.1.dist-info/METADATA,sha256=9tkOu9XsqdS4RAc9-aySyDaarwDt5ybBrehttG9vqys,56513
|
143
|
+
langroid-0.19.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
144
|
+
langroid-0.19.1.dist-info/RECORD,,
|
pyproject.toml
CHANGED
File without changes
|
File without changes
|