langroid 0.33.10__py3-none-any.whl → 0.33.11__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 +5 -0
- langroid/agent/chat_agent.py +12 -8
- langroid/agent/task.py +9 -2
- {langroid-0.33.10.dist-info → langroid-0.33.11.dist-info}/METADATA +1 -1
- {langroid-0.33.10.dist-info → langroid-0.33.11.dist-info}/RECORD +7 -7
- {langroid-0.33.10.dist-info → langroid-0.33.11.dist-info}/WHEEL +0 -0
- {langroid-0.33.10.dist-info → langroid-0.33.11.dist-info}/licenses/LICENSE +0 -0
langroid/agent/base.py
CHANGED
@@ -1039,6 +1039,11 @@ class Agent(ABC):
|
|
1039
1039
|
"""
|
1040
1040
|
if msg is None:
|
1041
1041
|
return False
|
1042
|
+
if isinstance(msg, ChatDocument):
|
1043
|
+
if len(msg.tool_messages) > 0:
|
1044
|
+
return True
|
1045
|
+
if msg.metadata.sender != Entity.LLM:
|
1046
|
+
return False
|
1042
1047
|
try:
|
1043
1048
|
tools = self.get_tool_messages(msg)
|
1044
1049
|
return len(tools) > 0
|
langroid/agent/chat_agent.py
CHANGED
@@ -1063,18 +1063,20 @@ class ChatAgent(Agent):
|
|
1063
1063
|
|
1064
1064
|
return tools
|
1065
1065
|
|
1066
|
-
def _get_any_tool_message(self, optional: bool = True) -> type[ToolMessage]:
|
1066
|
+
def _get_any_tool_message(self, optional: bool = True) -> type[ToolMessage] | None:
|
1067
1067
|
"""
|
1068
1068
|
Returns a `ToolMessage` which wraps all enabled tools, excluding those
|
1069
1069
|
where strict recovery is disabled. Used in strict recovery.
|
1070
1070
|
"""
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1071
|
+
possible_tools = tuple(
|
1072
|
+
self.llm_tools_map[t]
|
1073
|
+
for t in self.llm_tools_usable
|
1074
|
+
if t not in self.disable_strict_tools_set
|
1075
|
+
)
|
1076
|
+
if len(possible_tools) == 0:
|
1077
|
+
return None
|
1078
|
+
any_tool_type = Union.__getitem__(possible_tools) # type ignore
|
1079
|
+
|
1078
1080
|
maybe_optional_type = Optional[any_tool_type] if optional else any_tool_type
|
1079
1081
|
|
1080
1082
|
class AnyTool(ToolMessage):
|
@@ -1225,6 +1227,8 @@ class ChatAgent(Agent):
|
|
1225
1227
|
and self.config.strict_recovery
|
1226
1228
|
):
|
1227
1229
|
AnyTool = self._get_any_tool_message()
|
1230
|
+
if AnyTool is None:
|
1231
|
+
return None
|
1228
1232
|
self.set_output_format(
|
1229
1233
|
AnyTool,
|
1230
1234
|
force_tools=True,
|
langroid/agent/task.py
CHANGED
@@ -1429,8 +1429,15 @@ class Task:
|
|
1429
1429
|
else:
|
1430
1430
|
response_fn = self._entity_responder_map[cast(Entity, e)]
|
1431
1431
|
result = response_fn(self.pending_message)
|
1432
|
-
# update result.tool_messages if any
|
1433
|
-
if
|
1432
|
+
# update result.tool_messages if any.
|
1433
|
+
# Do this only if sender is LLM, since this could be
|
1434
|
+
# a tool-call result from the Agent responder, which may
|
1435
|
+
# contain strings that look like tools, and we don't want to
|
1436
|
+
# trigger strict tool recovery due to that.
|
1437
|
+
if (
|
1438
|
+
isinstance(result, ChatDocument)
|
1439
|
+
and result.metadata.sender == Entity.LLM
|
1440
|
+
):
|
1434
1441
|
self.agent.try_get_tool_messages(result)
|
1435
1442
|
|
1436
1443
|
result_chat_doc = self.agent.to_ChatDocument(
|
@@ -3,12 +3,12 @@ langroid/exceptions.py,sha256=gp6ku4ZLdXXCUQIwUNVFojJNGTzGnkevi2PLvG7HOhc,2555
|
|
3
3
|
langroid/mytypes.py,sha256=ptAFxEAtiwmIfUnGisNotTe8wT9LKBf22lOfPgZoQIY,2368
|
4
4
|
langroid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
|
6
|
-
langroid/agent/base.py,sha256
|
6
|
+
langroid/agent/base.py,sha256=oThlrYygKDu1-bKjAfygldJ511gMKT8Z0qCrD52DdDM,77834
|
7
7
|
langroid/agent/batch.py,sha256=qK3ph6VNj_1sOhfXCZY4r6gh035DglDKU751p8BU0tY,14665
|
8
|
-
langroid/agent/chat_agent.py,sha256=
|
8
|
+
langroid/agent/chat_agent.py,sha256=cxamUgqQkr6_W3mqCPz3L7rJnXIkD4hemR7X7uhlBvI,82095
|
9
9
|
langroid/agent/chat_document.py,sha256=xPUMGzR83rn4iAEXIw2jy5LQ6YJ6Y0TiZ78XRQeDnJQ,17778
|
10
10
|
langroid/agent/openai_assistant.py,sha256=JkAcs02bIrgPNVvUWVR06VCthc5-ulla2QMBzux_q6o,34340
|
11
|
-
langroid/agent/task.py,sha256=
|
11
|
+
langroid/agent/task.py,sha256=XrXUbSoiFasvpIsZPn_cBpdWaTCKljJPRimtLMrSZrs,90347
|
12
12
|
langroid/agent/tool_message.py,sha256=BhjP-_TfQ2tgxuY4Yo_JHLOwwt0mJ4BwjPnREvEY4vk,14744
|
13
13
|
langroid/agent/xml_tool_message.py,sha256=6SshYZJKIfi4mkE-gIoSwjkEYekQ8GwcSiCv7a5uO9E,15054
|
14
14
|
langroid/agent/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -121,7 +121,7 @@ langroid/vector_store/lancedb.py,sha256=b3_vWkTjG8mweZ7ZNlUD-NjmQP_rLBZfyKWcxt2v
|
|
121
121
|
langroid/vector_store/meilisearch.py,sha256=6frB7GFWeWmeKzRfLZIvzRjllniZ1cYj3HmhHQICXLs,11663
|
122
122
|
langroid/vector_store/momento.py,sha256=UNHGT6jXuQtqY9f6MdqGU14bVnS0zHgIJUa30ULpUJo,10474
|
123
123
|
langroid/vector_store/qdrantdb.py,sha256=HRLCt-FG8y4718omwpFaQZnWeYxPj0XCwS4tjokI1sU,18116
|
124
|
-
langroid-0.33.
|
125
|
-
langroid-0.33.
|
126
|
-
langroid-0.33.
|
127
|
-
langroid-0.33.
|
124
|
+
langroid-0.33.11.dist-info/METADATA,sha256=A-tOfJCvDuYvM96q3zqx6NnATzEflj7mdfoEX64XV4A,59016
|
125
|
+
langroid-0.33.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
126
|
+
langroid-0.33.11.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
127
|
+
langroid-0.33.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|