langroid 0.50.3__py3-none-any.whl → 0.50.4__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 +2 -7
- langroid/language_models/base.py +14 -0
- langroid/language_models/openai_gpt.py +0 -24
- {langroid-0.50.3.dist-info → langroid-0.50.4.dist-info}/METADATA +1 -1
- {langroid-0.50.3.dist-info → langroid-0.50.4.dist-info}/RECORD +7 -7
- {langroid-0.50.3.dist-info → langroid-0.50.4.dist-info}/WHEEL +0 -0
- {langroid-0.50.3.dist-info → langroid-0.50.4.dist-info}/licenses/LICENSE +0 -0
langroid/agent/chat_agent.py
CHANGED
@@ -94,7 +94,7 @@ class ChatAgentConfig(AgentConfig):
|
|
94
94
|
handle_llm_no_tool: Any = None
|
95
95
|
use_tools: bool = False
|
96
96
|
use_functions_api: bool = True
|
97
|
-
use_tools_api: bool =
|
97
|
+
use_tools_api: bool = True
|
98
98
|
strict_recovery: bool = True
|
99
99
|
enable_orchestration_tool_handling: bool = True
|
100
100
|
output_format: Optional[type] = None
|
@@ -308,12 +308,7 @@ class ChatAgent(Agent):
|
|
308
308
|
|
309
309
|
def _fn_call_available(self) -> bool:
|
310
310
|
"""Does this agent's LLM support function calling?"""
|
311
|
-
return (
|
312
|
-
self.llm is not None
|
313
|
-
and isinstance(self.llm, OpenAIGPT)
|
314
|
-
and self.llm.is_openai_chat_model()
|
315
|
-
and self.llm.supports_functions_or_tools()
|
316
|
-
)
|
311
|
+
return self.llm is not None and self.llm.supports_functions_or_tools()
|
317
312
|
|
318
313
|
def _strict_tools_available(self) -> bool:
|
319
314
|
"""Does this agent's LLM support strict tools?"""
|
langroid/language_models/base.py
CHANGED
@@ -626,6 +626,20 @@ class LanguageModel(ABC):
|
|
626
626
|
)
|
627
627
|
return get_model_info(orig_model, model)
|
628
628
|
|
629
|
+
def supports_functions_or_tools(self) -> bool:
|
630
|
+
"""
|
631
|
+
Does this Model's API support "native" tool-calling, i.e.
|
632
|
+
can we call the API with arguments that contain a list of available tools,
|
633
|
+
and their schemas?
|
634
|
+
Note that, given the plethora of LLM provider APIs this determination is
|
635
|
+
imperfect at best, and leans towards returning True.
|
636
|
+
When the API calls fails with an error indicating tools are not supported,
|
637
|
+
then users are encouraged to use the Langroid-based prompt-based
|
638
|
+
ToolMessage mechanism, which works with ANY LLM. To enable this,
|
639
|
+
in your ChatAgentConfig, set `use_functions_api=False`, and `use_tools=True`.
|
640
|
+
"""
|
641
|
+
return self.info().has_tools
|
642
|
+
|
629
643
|
def chat_context_length(self) -> int:
|
630
644
|
return self.config.chat_context_length or DEFAULT_CONTEXT_LENGTH
|
631
645
|
|
@@ -682,9 +682,6 @@ class OpenAIGPT(LanguageModel):
|
|
682
682
|
openai_chat_models = [e.value for e in OpenAIChatModel]
|
683
683
|
return self.config.chat_model in openai_chat_models
|
684
684
|
|
685
|
-
def supports_functions_or_tools(self) -> bool:
|
686
|
-
return self.is_openai_chat_model() and self.info().has_tools
|
687
|
-
|
688
685
|
def is_openai_completion_model(self) -> bool:
|
689
686
|
openai_completion_models = [e.value for e in OpenAICompletionModel]
|
690
687
|
return self.config.completion_model in openai_completion_models
|
@@ -1644,17 +1641,6 @@ class OpenAIGPT(LanguageModel):
|
|
1644
1641
|
) -> LLMResponse:
|
1645
1642
|
self.run_on_first_use()
|
1646
1643
|
|
1647
|
-
if [functions, tools] != [None, None] and not self.is_openai_chat_model():
|
1648
|
-
raise ValueError(
|
1649
|
-
f"""
|
1650
|
-
`functions` and `tools` can only be specified for OpenAI chat LLMs,
|
1651
|
-
or LLMs served via an OpenAI-compatible API.
|
1652
|
-
{self.config.chat_model} does not support function-calling or tools.
|
1653
|
-
Instead, please use Langroid's ToolMessages, which are equivalent.
|
1654
|
-
In the ChatAgentConfig, set `use_functions_api=False`
|
1655
|
-
and `use_tools=True`, this will enable ToolMessages.
|
1656
|
-
"""
|
1657
|
-
)
|
1658
1644
|
if self.config.use_completion_for_chat and not self.is_openai_chat_model():
|
1659
1645
|
# only makes sense for non-OpenAI models
|
1660
1646
|
if self.config.formatter is None or self.config.hf_formatter is None:
|
@@ -1699,16 +1685,6 @@ class OpenAIGPT(LanguageModel):
|
|
1699
1685
|
) -> LLMResponse:
|
1700
1686
|
self.run_on_first_use()
|
1701
1687
|
|
1702
|
-
if [functions, tools] != [None, None] and not self.is_openai_chat_model():
|
1703
|
-
raise ValueError(
|
1704
|
-
f"""
|
1705
|
-
`functions` and `tools` can only be specified for OpenAI chat models;
|
1706
|
-
{self.config.chat_model} does not support function-calling or tools.
|
1707
|
-
Instead, please use Langroid's ToolMessages, which are equivalent.
|
1708
|
-
In the ChatAgentConfig, set `use_functions_api=False`
|
1709
|
-
and `use_tools=True`, this will enable ToolMessages.
|
1710
|
-
"""
|
1711
|
-
)
|
1712
1688
|
# turn off streaming for async calls
|
1713
1689
|
if (
|
1714
1690
|
self.config.use_completion_for_chat
|
@@ -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=bs5OLCf534mhsdR7Rgf27GqVNuSV2bOVbD46Y86mGFA,79829
|
7
7
|
langroid/agent/batch.py,sha256=vi1r5i1-vN80WfqHDSwjEym_KfGsqPGUtwktmiK1nuk,20635
|
8
|
-
langroid/agent/chat_agent.py,sha256=
|
8
|
+
langroid/agent/chat_agent.py,sha256=m1alf-KNJSU6PeFF6ocwTHSG0cmTE-iy1o7UYAvRGQE,85081
|
9
9
|
langroid/agent/chat_document.py,sha256=xzMtrPbaW-Y-BnF7kuhr2dorsD-D5rMWzfOqJ8HAoo8,17885
|
10
10
|
langroid/agent/openai_assistant.py,sha256=JkAcs02bIrgPNVvUWVR06VCthc5-ulla2QMBzux_q6o,34340
|
11
11
|
langroid/agent/task.py,sha256=HB6N-Jn80HFqCf0ZYOC1v3Bn3oO7NLjShHQJJFwW0q4,90557
|
@@ -69,11 +69,11 @@ langroid/embedding_models/protoc/embeddings_pb2.pyi,sha256=UkNy7BrNsmQm0vLb3NtGX
|
|
69
69
|
langroid/embedding_models/protoc/embeddings_pb2_grpc.py,sha256=9dYQqkW3JPyBpSEjeGXTNpSqAkC-6FPtBHyteVob2Y8,2452
|
70
70
|
langroid/language_models/__init__.py,sha256=3aD2qC1lz8v12HX4B-dilv27gNxYdGdeu1QvDlkqqHs,1095
|
71
71
|
langroid/language_models/azure_openai.py,sha256=SW0Fp_y6HpERr9l6TtF6CYsKgKwjUf_hSL_2mhTV4wI,5034
|
72
|
-
langroid/language_models/base.py,sha256=
|
72
|
+
langroid/language_models/base.py,sha256=A9A83SJOGh_elRScKNIDAcVT4mw9vKCou7txsPMVSv4,27023
|
73
73
|
langroid/language_models/config.py,sha256=9Q8wk5a7RQr8LGMT_0WkpjY8S4ywK06SalVRjXlfCiI,378
|
74
74
|
langroid/language_models/mock_lm.py,sha256=5BgHKDVRWFbUwDT_PFgTZXz9-k8wJSA2e3PZmyDgQ1k,4022
|
75
75
|
langroid/language_models/model_info.py,sha256=tfBBxL0iUf2mVN6CjcvqflzFUVg2oZqOJZexZ8jHTYA,12216
|
76
|
-
langroid/language_models/openai_gpt.py,sha256=
|
76
|
+
langroid/language_models/openai_gpt.py,sha256=t5oFJFxfm0ZwbD5kS73TY8Hal6aCFUWX7O7dBZc-7fw,84480
|
77
77
|
langroid/language_models/utils.py,sha256=L4_CbihDMTGcsg0TOG1Yd5JFEto46--h7CX_14m89sQ,5016
|
78
78
|
langroid/language_models/prompt_formatter/__init__.py,sha256=2-5cdE24XoFDhifOLl8yiscohil1ogbP1ECkYdBlBsk,372
|
79
79
|
langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
|
@@ -129,7 +129,7 @@ langroid/vector_store/pineconedb.py,sha256=otxXZNaBKb9f_H75HTaU3lMHiaR2NUp5MqwLZ
|
|
129
129
|
langroid/vector_store/postgres.py,sha256=wHPtIi2qM4fhO4pMQr95pz1ZCe7dTb2hxl4VYspGZoA,16104
|
130
130
|
langroid/vector_store/qdrantdb.py,sha256=O6dSBoDZ0jzfeVBd7LLvsXu083xs2fxXtPa9gGX3JX4,18443
|
131
131
|
langroid/vector_store/weaviatedb.py,sha256=Yn8pg139gOy3zkaPfoTbMXEEBCiLiYa1MU5d_3UA1K4,11847
|
132
|
-
langroid-0.50.
|
133
|
-
langroid-0.50.
|
134
|
-
langroid-0.50.
|
135
|
-
langroid-0.50.
|
132
|
+
langroid-0.50.4.dist-info/METADATA,sha256=3HQH6x3pAFIDSUIt8TLI912CA-8EN_Jl_nKpQ09oli0,63641
|
133
|
+
langroid-0.50.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
134
|
+
langroid-0.50.4.dist-info/licenses/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
|
135
|
+
langroid-0.50.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|