langroid 0.58.2__py3-none-any.whl → 0.59.0b1__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 +39 -17
- langroid/agent/base.py-e +2216 -0
- langroid/agent/callbacks/chainlit.py +2 -1
- langroid/agent/chat_agent.py +73 -55
- langroid/agent/chat_agent.py-e +2086 -0
- langroid/agent/chat_document.py +7 -7
- langroid/agent/chat_document.py-e +513 -0
- langroid/agent/openai_assistant.py +9 -9
- langroid/agent/openai_assistant.py-e +882 -0
- langroid/agent/special/arangodb/arangodb_agent.py +10 -18
- langroid/agent/special/arangodb/arangodb_agent.py-e +648 -0
- langroid/agent/special/arangodb/tools.py +3 -3
- langroid/agent/special/doc_chat_agent.py +16 -14
- langroid/agent/special/lance_rag/critic_agent.py +2 -2
- langroid/agent/special/lance_rag/query_planner_agent.py +4 -4
- langroid/agent/special/lance_tools.py +6 -5
- langroid/agent/special/lance_tools.py-e +61 -0
- langroid/agent/special/neo4j/neo4j_chat_agent.py +3 -7
- langroid/agent/special/neo4j/neo4j_chat_agent.py-e +430 -0
- langroid/agent/special/relevance_extractor_agent.py +1 -1
- langroid/agent/special/sql/sql_chat_agent.py +11 -3
- langroid/agent/task.py +9 -87
- langroid/agent/task.py-e +2418 -0
- langroid/agent/tool_message.py +33 -17
- langroid/agent/tool_message.py-e +400 -0
- langroid/agent/tools/file_tools.py +4 -2
- langroid/agent/tools/file_tools.py-e +234 -0
- langroid/agent/tools/mcp/fastmcp_client.py +19 -6
- langroid/agent/tools/mcp/fastmcp_client.py-e +584 -0
- langroid/agent/tools/orchestration.py +22 -17
- langroid/agent/tools/orchestration.py-e +301 -0
- langroid/agent/tools/recipient_tool.py +3 -3
- langroid/agent/tools/task_tool.py +22 -16
- langroid/agent/tools/task_tool.py-e +249 -0
- langroid/agent/xml_tool_message.py +90 -35
- langroid/agent/xml_tool_message.py-e +392 -0
- langroid/cachedb/base.py +1 -1
- langroid/embedding_models/base.py +2 -2
- langroid/embedding_models/models.py +3 -7
- langroid/embedding_models/models.py-e +563 -0
- langroid/exceptions.py +4 -1
- langroid/language_models/azure_openai.py +2 -2
- langroid/language_models/azure_openai.py-e +134 -0
- langroid/language_models/base.py +6 -4
- langroid/language_models/base.py-e +812 -0
- langroid/language_models/client_cache.py +64 -0
- langroid/language_models/config.py +2 -4
- langroid/language_models/config.py-e +18 -0
- langroid/language_models/model_info.py +9 -1
- langroid/language_models/model_info.py-e +483 -0
- langroid/language_models/openai_gpt.py +119 -20
- langroid/language_models/openai_gpt.py-e +2280 -0
- langroid/language_models/provider_params.py +3 -22
- langroid/language_models/provider_params.py-e +153 -0
- langroid/mytypes.py +11 -4
- langroid/mytypes.py-e +132 -0
- langroid/parsing/code_parser.py +1 -1
- langroid/parsing/file_attachment.py +1 -1
- langroid/parsing/file_attachment.py-e +246 -0
- langroid/parsing/md_parser.py +14 -4
- langroid/parsing/md_parser.py-e +574 -0
- langroid/parsing/parser.py +22 -7
- langroid/parsing/parser.py-e +410 -0
- langroid/parsing/repo_loader.py +3 -1
- langroid/parsing/repo_loader.py-e +812 -0
- langroid/parsing/search.py +1 -1
- langroid/parsing/url_loader.py +17 -51
- langroid/parsing/url_loader.py-e +683 -0
- langroid/parsing/urls.py +5 -4
- langroid/parsing/urls.py-e +279 -0
- langroid/prompts/prompts_config.py +1 -1
- langroid/pydantic_v1/__init__.py +45 -6
- langroid/pydantic_v1/__init__.py-e +36 -0
- langroid/pydantic_v1/main.py +11 -4
- langroid/pydantic_v1/main.py-e +11 -0
- langroid/utils/configuration.py +13 -11
- langroid/utils/configuration.py-e +141 -0
- langroid/utils/constants.py +1 -1
- langroid/utils/constants.py-e +32 -0
- langroid/utils/globals.py +21 -5
- langroid/utils/globals.py-e +49 -0
- langroid/utils/html_logger.py +2 -1
- langroid/utils/html_logger.py-e +825 -0
- langroid/utils/object_registry.py +1 -1
- langroid/utils/object_registry.py-e +66 -0
- langroid/utils/pydantic_utils.py +55 -28
- langroid/utils/pydantic_utils.py-e +602 -0
- langroid/utils/types.py +2 -2
- langroid/utils/types.py-e +113 -0
- langroid/vector_store/base.py +3 -3
- langroid/vector_store/lancedb.py +5 -5
- langroid/vector_store/lancedb.py-e +404 -0
- langroid/vector_store/meilisearch.py +2 -2
- langroid/vector_store/pineconedb.py +4 -4
- langroid/vector_store/pineconedb.py-e +427 -0
- langroid/vector_store/postgres.py +1 -1
- langroid/vector_store/qdrantdb.py +3 -3
- langroid/vector_store/weaviatedb.py +1 -1
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/METADATA +3 -2
- langroid-0.59.0b1.dist-info/RECORD +181 -0
- langroid/agent/special/doc_chat_task.py +0 -0
- langroid/mcp/__init__.py +0 -1
- langroid/mcp/server/__init__.py +0 -1
- langroid-0.58.2.dist-info/RECORD +0 -145
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/WHEEL +0 -0
- {langroid-0.58.2.dist-info → langroid-0.59.0b1.dist-info}/licenses/LICENSE +0 -0
@@ -49,6 +49,8 @@ def get_openai_client(
|
|
49
49
|
organization: Optional[str] = None,
|
50
50
|
timeout: Union[float, Timeout] = 120.0,
|
51
51
|
default_headers: Optional[Dict[str, str]] = None,
|
52
|
+
http_client: Optional[Any] = None,
|
53
|
+
http_client_config: Optional[Dict[str, Any]] = None,
|
52
54
|
) -> OpenAI:
|
53
55
|
"""
|
54
56
|
Get or create a singleton OpenAI client with the given configuration.
|
@@ -59,6 +61,8 @@ def get_openai_client(
|
|
59
61
|
organization: Optional organization ID
|
60
62
|
timeout: Request timeout
|
61
63
|
default_headers: Optional default headers
|
64
|
+
http_client: Optional httpx.Client instance
|
65
|
+
http_client_config: Optional config dict for creating httpx.Client
|
62
66
|
|
63
67
|
Returns:
|
64
68
|
OpenAI client instance
|
@@ -66,6 +70,32 @@ def get_openai_client(
|
|
66
70
|
if isinstance(timeout, (int, float)):
|
67
71
|
timeout = Timeout(timeout)
|
68
72
|
|
73
|
+
# If http_client is provided directly, don't cache (complex object)
|
74
|
+
if http_client is not None:
|
75
|
+
client = OpenAI(
|
76
|
+
api_key=api_key,
|
77
|
+
base_url=base_url,
|
78
|
+
organization=organization,
|
79
|
+
timeout=timeout,
|
80
|
+
default_headers=default_headers,
|
81
|
+
http_client=http_client,
|
82
|
+
)
|
83
|
+
_all_clients.add(client)
|
84
|
+
return client
|
85
|
+
|
86
|
+
# If http_client_config is provided, create client from config and cache
|
87
|
+
created_http_client = None
|
88
|
+
if http_client_config is not None:
|
89
|
+
try:
|
90
|
+
from httpx import Client
|
91
|
+
|
92
|
+
created_http_client = Client(**http_client_config)
|
93
|
+
except ImportError:
|
94
|
+
raise ValueError(
|
95
|
+
"httpx is required to use http_client_config. "
|
96
|
+
"Install it with: pip install httpx"
|
97
|
+
)
|
98
|
+
|
69
99
|
cache_key = _get_cache_key(
|
70
100
|
"openai",
|
71
101
|
api_key=api_key,
|
@@ -73,6 +103,7 @@ def get_openai_client(
|
|
73
103
|
organization=organization,
|
74
104
|
timeout=timeout,
|
75
105
|
default_headers=default_headers,
|
106
|
+
http_client_config=http_client_config, # Include config in cache key
|
76
107
|
)
|
77
108
|
|
78
109
|
if cache_key in _client_cache:
|
@@ -84,6 +115,7 @@ def get_openai_client(
|
|
84
115
|
organization=organization,
|
85
116
|
timeout=timeout,
|
86
117
|
default_headers=default_headers,
|
118
|
+
http_client=created_http_client, # Use the client created from config
|
87
119
|
)
|
88
120
|
|
89
121
|
_client_cache[cache_key] = client
|
@@ -97,6 +129,8 @@ def get_async_openai_client(
|
|
97
129
|
organization: Optional[str] = None,
|
98
130
|
timeout: Union[float, Timeout] = 120.0,
|
99
131
|
default_headers: Optional[Dict[str, str]] = None,
|
132
|
+
http_client: Optional[Any] = None,
|
133
|
+
http_client_config: Optional[Dict[str, Any]] = None,
|
100
134
|
) -> AsyncOpenAI:
|
101
135
|
"""
|
102
136
|
Get or create a singleton AsyncOpenAI client with the given configuration.
|
@@ -107,6 +141,8 @@ def get_async_openai_client(
|
|
107
141
|
organization: Optional organization ID
|
108
142
|
timeout: Request timeout
|
109
143
|
default_headers: Optional default headers
|
144
|
+
http_client: Optional httpx.AsyncClient instance
|
145
|
+
http_client_config: Optional config dict for creating httpx.AsyncClient
|
110
146
|
|
111
147
|
Returns:
|
112
148
|
AsyncOpenAI client instance
|
@@ -114,6 +150,32 @@ def get_async_openai_client(
|
|
114
150
|
if isinstance(timeout, (int, float)):
|
115
151
|
timeout = Timeout(timeout)
|
116
152
|
|
153
|
+
# If http_client is provided directly, don't cache (complex object)
|
154
|
+
if http_client is not None:
|
155
|
+
client = AsyncOpenAI(
|
156
|
+
api_key=api_key,
|
157
|
+
base_url=base_url,
|
158
|
+
organization=organization,
|
159
|
+
timeout=timeout,
|
160
|
+
default_headers=default_headers,
|
161
|
+
http_client=http_client,
|
162
|
+
)
|
163
|
+
_all_clients.add(client)
|
164
|
+
return client
|
165
|
+
|
166
|
+
# If http_client_config is provided, create async client from config and cache
|
167
|
+
created_http_client = None
|
168
|
+
if http_client_config is not None:
|
169
|
+
try:
|
170
|
+
from httpx import AsyncClient
|
171
|
+
|
172
|
+
created_http_client = AsyncClient(**http_client_config)
|
173
|
+
except ImportError:
|
174
|
+
raise ValueError(
|
175
|
+
"httpx is required to use http_client_config. "
|
176
|
+
"Install it with: pip install httpx"
|
177
|
+
)
|
178
|
+
|
117
179
|
cache_key = _get_cache_key(
|
118
180
|
"async_openai",
|
119
181
|
api_key=api_key,
|
@@ -121,6 +183,7 @@ def get_async_openai_client(
|
|
121
183
|
organization=organization,
|
122
184
|
timeout=timeout,
|
123
185
|
default_headers=default_headers,
|
186
|
+
http_client_config=http_client_config, # Include config in cache key
|
124
187
|
)
|
125
188
|
|
126
189
|
if cache_key in _client_cache:
|
@@ -132,6 +195,7 @@ def get_async_openai_client(
|
|
132
195
|
organization=organization,
|
133
196
|
timeout=timeout,
|
134
197
|
default_headers=default_headers,
|
198
|
+
http_client=created_http_client, # Use the client created from config
|
135
199
|
)
|
136
200
|
|
137
201
|
_client_cache[cache_key] = client
|
@@ -1,12 +1,10 @@
|
|
1
|
-
from
|
1
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
2
2
|
|
3
3
|
|
4
4
|
class PromptFormatterConfig(BaseSettings):
|
5
5
|
type: str = "llama2"
|
6
6
|
|
7
|
-
|
8
|
-
env_prefix = "FORMAT_"
|
9
|
-
case_sensitive = False
|
7
|
+
model_config = SettingsConfigDict(env_prefix="FORMAT_", case_sensitive=False)
|
10
8
|
|
11
9
|
|
12
10
|
class Llama2FormatterConfig(PromptFormatterConfig):
|
@@ -0,0 +1,18 @@
|
|
1
|
+
from pydantic_settings import BaseSettings
|
2
|
+
|
3
|
+
from pydantic import ConfigDict
|
4
|
+
|
5
|
+
|
6
|
+
class PromptFormatterConfig(BaseSettings):
|
7
|
+
type: str = "llama2"
|
8
|
+
|
9
|
+
model_config = ConfigDict(env_prefix="FORMAT_", case_sensitive=False)
|
10
|
+
|
11
|
+
|
12
|
+
class Llama2FormatterConfig(PromptFormatterConfig):
|
13
|
+
use_bos_eos: bool = False
|
14
|
+
|
15
|
+
|
16
|
+
class HFPromptFormatterConfig(PromptFormatterConfig):
|
17
|
+
type: str = "hf"
|
18
|
+
model_name: str
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from enum import Enum
|
2
2
|
from typing import Dict, List, Optional
|
3
3
|
|
4
|
-
from
|
4
|
+
from pydantic import BaseModel
|
5
5
|
|
6
6
|
|
7
7
|
class ModelProvider(str, Enum):
|
@@ -173,6 +173,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
173
173
|
OpenAIChatModel.GPT4_1_NANO.value: ModelInfo(
|
174
174
|
name=OpenAIChatModel.GPT4_1_NANO.value,
|
175
175
|
provider=ModelProvider.OPENAI,
|
176
|
+
has_structured_output=True,
|
176
177
|
context_length=1_047_576,
|
177
178
|
max_output_tokens=32_768,
|
178
179
|
input_cost_per_million=0.10,
|
@@ -183,6 +184,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
183
184
|
OpenAIChatModel.GPT4_1_MINI.value: ModelInfo(
|
184
185
|
name=OpenAIChatModel.GPT4_1_MINI.value,
|
185
186
|
provider=ModelProvider.OPENAI,
|
187
|
+
has_structured_output=True,
|
186
188
|
context_length=1_047_576,
|
187
189
|
max_output_tokens=32_768,
|
188
190
|
input_cost_per_million=0.40,
|
@@ -193,6 +195,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
193
195
|
OpenAIChatModel.GPT4_1.value: ModelInfo(
|
194
196
|
name=OpenAIChatModel.GPT4_1.value,
|
195
197
|
provider=ModelProvider.OPENAI,
|
198
|
+
has_structured_output=True,
|
196
199
|
context_length=1_047_576,
|
197
200
|
max_output_tokens=32_768,
|
198
201
|
input_cost_per_million=2.00,
|
@@ -232,6 +235,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
232
235
|
output_cost_per_million=60.0,
|
233
236
|
allows_streaming=True,
|
234
237
|
allows_system_message=False,
|
238
|
+
has_structured_output=True,
|
235
239
|
unsupported_params=["temperature"],
|
236
240
|
rename_params={"max_tokens": "max_completion_tokens"},
|
237
241
|
has_tools=False,
|
@@ -247,6 +251,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
247
251
|
output_cost_per_million=8.0,
|
248
252
|
allows_streaming=True,
|
249
253
|
allows_system_message=False,
|
254
|
+
has_structured_output=True,
|
250
255
|
unsupported_params=["temperature"],
|
251
256
|
rename_params={"max_tokens": "max_completion_tokens"},
|
252
257
|
has_tools=False,
|
@@ -262,6 +267,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
262
267
|
output_cost_per_million=4.4,
|
263
268
|
allows_streaming=False,
|
264
269
|
allows_system_message=False,
|
270
|
+
has_structured_output=True,
|
265
271
|
unsupported_params=["temperature", "stream"],
|
266
272
|
rename_params={"max_tokens": "max_completion_tokens"},
|
267
273
|
has_tools=False,
|
@@ -277,6 +283,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
277
283
|
output_cost_per_million=4.4,
|
278
284
|
allows_streaming=False,
|
279
285
|
allows_system_message=False,
|
286
|
+
has_structured_output=True,
|
280
287
|
unsupported_params=["temperature", "stream"],
|
281
288
|
rename_params={"max_tokens": "max_completion_tokens"},
|
282
289
|
has_tools=False,
|
@@ -292,6 +299,7 @@ MODEL_INFO: Dict[str, ModelInfo] = {
|
|
292
299
|
output_cost_per_million=4.40,
|
293
300
|
allows_streaming=False,
|
294
301
|
allows_system_message=False,
|
302
|
+
has_structured_output=True,
|
295
303
|
unsupported_params=["temperature", "stream"],
|
296
304
|
rename_params={"max_tokens": "max_completion_tokens"},
|
297
305
|
has_tools=False,
|