langroid 0.59.5__py3-none-any.whl → 0.59.7__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/chat_agent.py +34 -30
- langroid/language_models/model_info.py +5 -0
- {langroid-0.59.5.dist-info → langroid-0.59.7.dist-info}/METADATA +2 -2
- {langroid-0.59.5.dist-info → langroid-0.59.7.dist-info}/RECORD +6 -6
- {langroid-0.59.5.dist-info → langroid-0.59.7.dist-info}/WHEEL +0 -0
- {langroid-0.59.5.dist-info → langroid-0.59.7.dist-info}/licenses/LICENSE +0 -0
langroid/agent/chat_agent.py
CHANGED
@@ -363,26 +363,30 @@ class ChatAgent(Agent):
|
|
363
363
|
if tool_call.id in self.oai_tool_id2call:
|
364
364
|
del self.oai_tool_id2call[tool_call.id]
|
365
365
|
|
366
|
-
def clear_history(self, start: int = -2) -> None:
|
366
|
+
def clear_history(self, start: int = -2, end: int = -1) -> None:
|
367
367
|
"""
|
368
|
-
Clear the message history,
|
368
|
+
Clear the message history, deleting messages from index `start`,
|
369
|
+
up to index `end`.
|
369
370
|
|
370
371
|
Args:
|
371
372
|
start (int): index of first message to delete; default = -2
|
372
373
|
(i.e. delete last 2 messages, typically these
|
373
374
|
are the last user and assistant messages)
|
375
|
+
end (int): index of last message to delete; Default = -1
|
376
|
+
(i.e. delete all messages up to the last one)
|
374
377
|
"""
|
378
|
+
n = len(self.message_history)
|
375
379
|
if start < 0:
|
376
|
-
n = len(self.message_history)
|
377
380
|
start = max(0, n + start)
|
378
|
-
|
381
|
+
end_ = n if end == -1 else end + 1
|
382
|
+
dropped = self.message_history[start:end_]
|
379
383
|
# consider the dropped msgs in REVERSE order, so we are
|
380
384
|
# carefully updating self.oai_tool_calls
|
381
385
|
for msg in reversed(dropped):
|
382
386
|
self._drop_msg_update_tool_calls(msg)
|
383
387
|
# clear out the chat document from the ObjectRegistry
|
384
388
|
ChatDocument.delete_id(msg.chat_document_id)
|
385
|
-
|
389
|
+
del self.message_history[start:end_]
|
386
390
|
|
387
391
|
def update_history(self, message: str, response: str) -> None:
|
388
392
|
"""
|
@@ -704,7 +708,7 @@ class ChatAgent(Agent):
|
|
704
708
|
if request == "":
|
705
709
|
raise ValueError(
|
706
710
|
f"""
|
707
|
-
ToolMessage class {message_class} must have a non-empty
|
711
|
+
ToolMessage class {message_class} must have a non-empty
|
708
712
|
'request' field if it is to be enabled as a tool.
|
709
713
|
"""
|
710
714
|
)
|
@@ -746,10 +750,10 @@ class ChatAgent(Agent):
|
|
746
750
|
logger.warning(
|
747
751
|
f"""
|
748
752
|
ToolMessage class {tool_class} does not allow LLM use,
|
749
|
-
because `_allow_llm_use=False` either in the Tool or a
|
753
|
+
because `_allow_llm_use=False` either in the Tool or a
|
750
754
|
parent class of this tool;
|
751
755
|
so not enabling LLM use for this tool!
|
752
|
-
If you intended an LLM to use this tool,
|
756
|
+
If you intended an LLM to use this tool,
|
753
757
|
set `_allow_llm_use=True` when you define the tool.
|
754
758
|
"""
|
755
759
|
)
|
@@ -1298,7 +1302,7 @@ class ChatAgent(Agent):
|
|
1298
1302
|
tool_name = limiting_tool.default_value("request")
|
1299
1303
|
max_tokens: int = max_retained_tokens
|
1300
1304
|
truncation_warning = f"""
|
1301
|
-
The result of the {tool_name} tool were too large,
|
1305
|
+
The result of the {tool_name} tool were too large,
|
1302
1306
|
and has been truncated to {max_tokens} tokens.
|
1303
1307
|
To obtain the full result, the tool needs to be re-used.
|
1304
1308
|
"""
|
@@ -1591,9 +1595,9 @@ class ChatAgent(Agent):
|
|
1591
1595
|
logger.debug(
|
1592
1596
|
f"""
|
1593
1597
|
Chat Model context length is {self.llm.chat_context_length()},
|
1594
|
-
but the current message history is {self.chat_num_tokens(hist)}
|
1595
|
-
tokens long, which does not allow
|
1596
|
-
{self.config.llm.model_max_output_tokens} output tokens.
|
1598
|
+
but the current message history is {self.chat_num_tokens(hist)}
|
1599
|
+
tokens long, which does not allow
|
1600
|
+
{self.config.llm.model_max_output_tokens} output tokens.
|
1597
1601
|
Therefore we reduced `max_output_tokens` to {output_len} tokens,
|
1598
1602
|
so they can fit within the model's context length
|
1599
1603
|
"""
|
@@ -1625,16 +1629,16 @@ class ChatAgent(Agent):
|
|
1625
1629
|
# and last message (user msg).
|
1626
1630
|
raise ValueError(
|
1627
1631
|
"""
|
1628
|
-
The (message history + max_output_tokens) is longer than the
|
1629
|
-
max chat context length of this model, and we have tried
|
1632
|
+
The (message history + max_output_tokens) is longer than the
|
1633
|
+
max chat context length of this model, and we have tried
|
1630
1634
|
reducing the requested max output tokens, as well as truncating
|
1631
|
-
early parts of the message history, to accommodate the model
|
1635
|
+
early parts of the message history, to accommodate the model
|
1632
1636
|
context length, but we have run out of msgs to drop.
|
1633
|
-
|
1634
|
-
HINT: In the `llm` field of your `ChatAgentConfig` object,
|
1635
|
-
which is of type `LLMConfig/OpenAIGPTConfig`, try
|
1636
|
-
- increasing `chat_context_length`
|
1637
|
-
(if accurate for the model), or
|
1637
|
+
|
1638
|
+
HINT: In the `llm` field of your `ChatAgentConfig` object,
|
1639
|
+
which is of type `LLMConfig/OpenAIGPTConfig`, try
|
1640
|
+
- increasing `chat_context_length`
|
1641
|
+
(if accurate for the model), or
|
1638
1642
|
- decreasing `max_output_tokens`
|
1639
1643
|
"""
|
1640
1644
|
)
|
@@ -1657,15 +1661,15 @@ class ChatAgent(Agent):
|
|
1657
1661
|
if output_len < self.config.llm.min_output_tokens:
|
1658
1662
|
raise ValueError(
|
1659
1663
|
f"""
|
1660
|
-
Tried to shorten prompt history for chat mode
|
1661
|
-
but even after truncating all messages except system msg and
|
1662
|
-
last (user) msg,
|
1664
|
+
Tried to shorten prompt history for chat mode
|
1665
|
+
but even after truncating all messages except system msg and
|
1666
|
+
last (user) msg,
|
1663
1667
|
the history token len {self.chat_num_tokens(hist)} is
|
1664
1668
|
too long to accommodate the desired minimum output tokens
|
1665
|
-
{self.config.llm.min_output_tokens} within the
|
1669
|
+
{self.config.llm.min_output_tokens} within the
|
1666
1670
|
model's context length {self.llm.chat_context_length()}.
|
1667
1671
|
Please try shortening the system msg or user prompts,
|
1668
|
-
or adjust `config.llm.min_output_tokens` to be smaller.
|
1672
|
+
or adjust `config.llm.min_output_tokens` to be smaller.
|
1669
1673
|
"""
|
1670
1674
|
)
|
1671
1675
|
else:
|
@@ -1673,13 +1677,13 @@ class ChatAgent(Agent):
|
|
1673
1677
|
msg_tokens = self.chat_num_tokens()
|
1674
1678
|
logger.warning(
|
1675
1679
|
f"""
|
1676
|
-
Chat Model context length is {self.llm.chat_context_length()}
|
1680
|
+
Chat Model context length is {self.llm.chat_context_length()}
|
1677
1681
|
tokens, but the current message history is {msg_tokens} tokens long,
|
1678
|
-
which does not allow {self.config.llm.model_max_output_tokens}
|
1679
|
-
output tokens.
|
1682
|
+
which does not allow {self.config.llm.model_max_output_tokens}
|
1683
|
+
output tokens.
|
1680
1684
|
Therefore we truncated the first {n_truncated} messages
|
1681
|
-
in the conversation history so that history token
|
1682
|
-
length is reduced to {self.chat_num_tokens(hist)}, and
|
1685
|
+
in the conversation history so that history token
|
1686
|
+
length is reduced to {self.chat_num_tokens(hist)}, and
|
1683
1687
|
we use `max_output_tokens = {output_len}`,
|
1684
1688
|
so they can fit within the model's context length
|
1685
1689
|
of {self.llm.chat_context_length()} tokens.
|
@@ -90,6 +90,11 @@ class OpenAI_API_ParamInfo(BaseModel):
|
|
90
90
|
params: Dict[str, List[str]] = dict(
|
91
91
|
reasoning_effort=[
|
92
92
|
OpenAIChatModel.O3_MINI.value,
|
93
|
+
OpenAIChatModel.O3.value,
|
94
|
+
OpenAIChatModel.O4_MINI.value,
|
95
|
+
OpenAIChatModel.GPT5.value,
|
96
|
+
OpenAIChatModel.GPT5_MINI.value,
|
97
|
+
OpenAIChatModel.GPT5_NANO.value,
|
93
98
|
GeminiModel.GEMINI_2_5_PRO.value,
|
94
99
|
GeminiModel.GEMINI_2_5_FLASH.value,
|
95
100
|
GeminiModel.GEMINI_2_5_FLASH_LITE.value,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: langroid
|
3
|
-
Version: 0.59.
|
3
|
+
Version: 0.59.7
|
4
4
|
Summary: Harness LLMs with Multi-Agent Programming
|
5
5
|
Author-email: Prasad Chalasani <pchalasani@gmail.com>
|
6
6
|
License: MIT
|
@@ -53,7 +53,7 @@ Requires-Dist: requests<3.0.0,>=2.31.0
|
|
53
53
|
Requires-Dist: rich<14.0.0,>=13.3.4
|
54
54
|
Requires-Dist: thefuzz<1.0.0,>=0.20.0
|
55
55
|
Requires-Dist: tiktoken<1.0.0,>=0.7.0
|
56
|
-
Requires-Dist: trafilatura<
|
56
|
+
Requires-Dist: trafilatura<3.0.0,>=2.0.0
|
57
57
|
Requires-Dist: typer<1.0.0,>=0.9.0
|
58
58
|
Requires-Dist: wget<4.0,>=3.2
|
59
59
|
Provides-Extra: all
|
@@ -5,7 +5,7 @@ langroid/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
langroid/agent/__init__.py,sha256=ll0Cubd2DZ-fsCMl7e10hf9ZjFGKzphfBco396IKITY,786
|
6
6
|
langroid/agent/base.py,sha256=mP57z3QiOm8Y7tG_OHpyvcsWmoq-4WSrHxAiiwgtsX8,87307
|
7
7
|
langroid/agent/batch.py,sha256=wpE9RqCNDVDhAXkCB7wEqfCIEAi6qKcrhaZ-Zr9T4C0,21375
|
8
|
-
langroid/agent/chat_agent.py,sha256=
|
8
|
+
langroid/agent/chat_agent.py,sha256=OqP4N9jqeSJfCqTznE4zqtsVCyzUQlAhz_ToXYIYCSc,90436
|
9
9
|
langroid/agent/chat_document.py,sha256=bgNGfgyvTqPqUV8093IYRJ7jLNlOEctEvjnwdVUApaI,19748
|
10
10
|
langroid/agent/done_sequence_parser.py,sha256=99UZoLknQx0AZzX-hGp03MfUxHomrMTLcyekpC25JoU,5845
|
11
11
|
langroid/agent/openai_assistant.py,sha256=v__MWg0jhEOQVplKh1urU2Dq4VZonHV0G3CuGiHFw7o,34386
|
@@ -77,7 +77,7 @@ langroid/language_models/base.py,sha256=uRi-XtQhsEBN702_lGepxlNQ0e8gaPgaXjULYn2r
|
|
77
77
|
langroid/language_models/client_cache.py,sha256=c8tAUTKxbd-CVGRy9WPYhI1pLtarFWWwX6-qm4ZXaqk,9399
|
78
78
|
langroid/language_models/config.py,sha256=rhEZ9Wwq42q1uW_-oRFbilJhIw1vYlTvYqIk_7pHiSY,397
|
79
79
|
langroid/language_models/mock_lm.py,sha256=tA9JpURznsMZ59iRhFYMmaYQzAc0D0BT-PiJIV58sAk,4079
|
80
|
-
langroid/language_models/model_info.py,sha256=
|
80
|
+
langroid/language_models/model_info.py,sha256=qAx_BSU2Ix7gkCtFirRnKwrtMq20ORPv9fwmOOOsa9Q,19532
|
81
81
|
langroid/language_models/openai_gpt.py,sha256=qz-KN8phkVglZ6GeqXDwW60Dr1--ZhhKdTEaXwftRZA,93543
|
82
82
|
langroid/language_models/provider_params.py,sha256=upG4cBrX8fcvAo1g7fcsv-rBbsfypIqcDRRV9m1hohU,4846
|
83
83
|
langroid/language_models/utils.py,sha256=n55Oe2_V_4VNGhytvPWLYC-0tFS07RTjN83KWl-p_MI,6032
|
@@ -139,7 +139,7 @@ langroid/vector_store/pineconedb.py,sha256=7V0Bkt4ZrOR3V90tdXvdFmyNGuww7SFdyPq7-
|
|
139
139
|
langroid/vector_store/postgres.py,sha256=TY_VshimwFZglYgKYm7Qn1F-dCSL8GsXRTgmh7VTe9c,16110
|
140
140
|
langroid/vector_store/qdrantdb.py,sha256=mqxMOrcLAQpl0opuL8vXhdIt6ppv2zYyAvddHZoEW0Y,19184
|
141
141
|
langroid/vector_store/weaviatedb.py,sha256=BS95bxVKNYfQc9VPb85a1HlcgnXfAkgMzjydnjCgRHc,11853
|
142
|
-
langroid-0.59.
|
143
|
-
langroid-0.59.
|
144
|
-
langroid-0.59.
|
145
|
-
langroid-0.59.
|
142
|
+
langroid-0.59.7.dist-info/METADATA,sha256=PEdzKonu-UCwiNQjBg0I-BqZGbY0-KYCB7UDs4_xbPI,66517
|
143
|
+
langroid-0.59.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
144
|
+
langroid-0.59.7.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
145
|
+
langroid-0.59.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|