langroid 0.58.1__tar.gz → 0.58.3__tar.gz

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.
Files changed (146) hide show
  1. {langroid-0.58.1 → langroid-0.58.3}/PKG-INFO +3 -3
  2. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/client_cache.py +64 -0
  3. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/openai_gpt.py +66 -2
  4. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/url_loader.py +1 -1
  5. {langroid-0.58.1 → langroid-0.58.3}/pyproject.toml +2 -2
  6. {langroid-0.58.1 → langroid-0.58.3}/.gitignore +0 -0
  7. {langroid-0.58.1 → langroid-0.58.3}/LICENSE +0 -0
  8. {langroid-0.58.1 → langroid-0.58.3}/README.md +0 -0
  9. {langroid-0.58.1 → langroid-0.58.3}/langroid/__init__.py +0 -0
  10. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/__init__.py +0 -0
  11. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/base.py +0 -0
  12. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/batch.py +0 -0
  13. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/callbacks/__init__.py +0 -0
  14. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/callbacks/chainlit.py +0 -0
  15. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/chat_agent.py +0 -0
  16. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/chat_document.py +0 -0
  17. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/done_sequence_parser.py +0 -0
  18. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/openai_assistant.py +0 -0
  19. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/__init__.py +0 -0
  20. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/arangodb/__init__.py +0 -0
  21. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
  22. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/arangodb/system_messages.py +0 -0
  23. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/arangodb/tools.py +0 -0
  24. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/arangodb/utils.py +0 -0
  25. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/doc_chat_agent.py +0 -0
  26. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/doc_chat_task.py +0 -0
  27. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  28. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_rag/__init__.py +0 -0
  29. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
  30. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  31. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
  32. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/lance_tools.py +0 -0
  33. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/neo4j/__init__.py +0 -0
  34. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  35. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  36. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/neo4j/system_messages.py +0 -0
  37. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/neo4j/tools.py +0 -0
  38. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  39. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/retriever_agent.py +0 -0
  40. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/__init__.py +0 -0
  41. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  42. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/utils/__init__.py +0 -0
  43. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  44. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  45. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/utils/system_message.py +0 -0
  46. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/sql/utils/tools.py +0 -0
  47. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/special/table_chat_agent.py +0 -0
  48. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/task.py +0 -0
  49. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tool_message.py +0 -0
  50. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/__init__.py +0 -0
  51. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  52. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/exa_search_tool.py +0 -0
  53. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/file_tools.py +0 -0
  54. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/google_search_tool.py +0 -0
  55. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/mcp/__init__.py +0 -0
  56. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/mcp/decorators.py +0 -0
  57. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/mcp/fastmcp_client.py +0 -0
  58. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  59. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/orchestration.py +0 -0
  60. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/recipient_tool.py +0 -0
  61. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/retrieval_tool.py +0 -0
  62. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/rewind_tool.py +0 -0
  63. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/segment_extract_tool.py +0 -0
  64. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/task_tool.py +0 -0
  65. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/tools/tavily_search_tool.py +0 -0
  66. {langroid-0.58.1 → langroid-0.58.3}/langroid/agent/xml_tool_message.py +0 -0
  67. {langroid-0.58.1 → langroid-0.58.3}/langroid/cachedb/__init__.py +0 -0
  68. {langroid-0.58.1 → langroid-0.58.3}/langroid/cachedb/base.py +0 -0
  69. {langroid-0.58.1 → langroid-0.58.3}/langroid/cachedb/redis_cachedb.py +0 -0
  70. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/__init__.py +0 -0
  71. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/base.py +0 -0
  72. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/models.py +0 -0
  73. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/protoc/__init__.py +0 -0
  74. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  75. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  76. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  77. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  78. {langroid-0.58.1 → langroid-0.58.3}/langroid/embedding_models/remote_embeds.py +0 -0
  79. {langroid-0.58.1 → langroid-0.58.3}/langroid/exceptions.py +0 -0
  80. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/__init__.py +0 -0
  81. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/azure_openai.py +0 -0
  82. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/base.py +0 -0
  83. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/config.py +0 -0
  84. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/mock_lm.py +0 -0
  85. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/model_info.py +0 -0
  86. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  87. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/prompt_formatter/base.py +0 -0
  88. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  89. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  90. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/provider_params.py +0 -0
  91. {langroid-0.58.1 → langroid-0.58.3}/langroid/language_models/utils.py +0 -0
  92. {langroid-0.58.1 → langroid-0.58.3}/langroid/mcp/__init__.py +0 -0
  93. {langroid-0.58.1 → langroid-0.58.3}/langroid/mcp/server/__init__.py +0 -0
  94. {langroid-0.58.1 → langroid-0.58.3}/langroid/mytypes.py +0 -0
  95. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/__init__.py +0 -0
  96. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/agent_chats.py +0 -0
  97. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/code_parser.py +0 -0
  98. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/document_parser.py +0 -0
  99. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/file_attachment.py +0 -0
  100. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/md_parser.py +0 -0
  101. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/para_sentence_split.py +0 -0
  102. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/parse_json.py +0 -0
  103. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/parser.py +0 -0
  104. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/pdf_utils.py +0 -0
  105. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/repo_loader.py +0 -0
  106. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/routing.py +0 -0
  107. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/search.py +0 -0
  108. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/spider.py +0 -0
  109. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/table_loader.py +0 -0
  110. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/urls.py +0 -0
  111. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/utils.py +0 -0
  112. {langroid-0.58.1 → langroid-0.58.3}/langroid/parsing/web_search.py +0 -0
  113. {langroid-0.58.1 → langroid-0.58.3}/langroid/prompts/__init__.py +0 -0
  114. {langroid-0.58.1 → langroid-0.58.3}/langroid/prompts/dialog.py +0 -0
  115. {langroid-0.58.1 → langroid-0.58.3}/langroid/prompts/prompts_config.py +0 -0
  116. {langroid-0.58.1 → langroid-0.58.3}/langroid/prompts/templates.py +0 -0
  117. {langroid-0.58.1 → langroid-0.58.3}/langroid/py.typed +0 -0
  118. {langroid-0.58.1 → langroid-0.58.3}/langroid/pydantic_v1/__init__.py +0 -0
  119. {langroid-0.58.1 → langroid-0.58.3}/langroid/pydantic_v1/main.py +0 -0
  120. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/__init__.py +0 -0
  121. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/algorithms/__init__.py +0 -0
  122. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/algorithms/graph.py +0 -0
  123. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/configuration.py +0 -0
  124. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/constants.py +0 -0
  125. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/git_utils.py +0 -0
  126. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/globals.py +0 -0
  127. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/html_logger.py +0 -0
  128. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/logging.py +0 -0
  129. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/object_registry.py +0 -0
  130. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/output/__init__.py +0 -0
  131. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/output/citations.py +0 -0
  132. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/output/printing.py +0 -0
  133. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/output/status.py +0 -0
  134. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/pandas_utils.py +0 -0
  135. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/pydantic_utils.py +0 -0
  136. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/system.py +0 -0
  137. {langroid-0.58.1 → langroid-0.58.3}/langroid/utils/types.py +0 -0
  138. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/__init__.py +0 -0
  139. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/base.py +0 -0
  140. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/chromadb.py +0 -0
  141. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/lancedb.py +0 -0
  142. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/meilisearch.py +0 -0
  143. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/pineconedb.py +0 -0
  144. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/postgres.py +0 -0
  145. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/qdrantdb.py +0 -0
  146. {langroid-0.58.1 → langroid-0.58.3}/langroid/vector_store/weaviatedb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.58.1
3
+ Version: 0.58.3
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -94,8 +94,8 @@ Requires-Dist: chainlit<3.0.0,>=2.0.1; extra == 'chainlit'
94
94
  Requires-Dist: python-socketio<6.0.0,>=5.11.0; extra == 'chainlit'
95
95
  Provides-Extra: chromadb
96
96
  Requires-Dist: chromadb<=0.4.23,>=0.4.21; extra == 'chromadb'
97
- Provides-Extra: crawl-4-ai
98
- Requires-Dist: crawl4ai>=0.6.3; extra == 'crawl-4-ai'
97
+ Provides-Extra: crawl4ai
98
+ Requires-Dist: crawl4ai>=0.6.3; extra == 'crawl4ai'
99
99
  Provides-Extra: db
100
100
  Requires-Dist: psycopg2-binary>=2.9.10; extra == 'db'
101
101
  Requires-Dist: psycopg2<3.0.0,>=2.9.7; extra == 'db'
@@ -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
@@ -287,6 +287,9 @@ class OpenAIGPTConfig(LLMConfig):
287
287
  langdb_params: LangDBParams = LangDBParams()
288
288
  portkey_params: PortkeyParams = PortkeyParams()
289
289
  headers: Dict[str, str] = {}
290
+ http_client_factory: Optional[Callable[[], Any]] = None # Factory for httpx.Client
291
+ http_verify_ssl: bool = True # Simple flag for SSL verification
292
+ http_client_config: Optional[Dict[str, Any]] = None # Config dict for httpx.Client
290
293
 
291
294
  def __init__(self, **kwargs) -> None: # type: ignore
292
295
  local_model = "api_base" in kwargs and kwargs["api_base"] is not None
@@ -631,6 +634,32 @@ class OpenAIGPT(LanguageModel):
631
634
  # Add Portkey-specific headers
632
635
  self.config.headers.update(self.config.portkey_params.get_headers())
633
636
 
637
+ # Create http_client if needed - Priority order:
638
+ # 1. http_client_factory (most flexibility, not cacheable)
639
+ # 2. http_client_config (cacheable, moderate flexibility)
640
+ # 3. http_verify_ssl=False (cacheable, simple SSL bypass)
641
+ http_client = None
642
+ async_http_client = None
643
+ http_client_config_used = None
644
+
645
+ if self.config.http_client_factory is not None:
646
+ # Use the factory to create http_client (not cacheable)
647
+ http_client = self.config.http_client_factory()
648
+ # Don't set async_http_client from sync client - create separately
649
+ # This avoids type mismatch issues
650
+ async_http_client = None
651
+ elif self.config.http_client_config is not None:
652
+ # Use config dict (cacheable)
653
+ http_client_config_used = self.config.http_client_config
654
+ elif not self.config.http_verify_ssl:
655
+ # Simple SSL bypass (cacheable)
656
+ http_client_config_used = {"verify": False}
657
+ logging.warning(
658
+ "SSL verification has been disabled. This is insecure and "
659
+ "should only be used in trusted environments (e.g., "
660
+ "corporate networks with self-signed certificates)."
661
+ )
662
+
634
663
  if self.config.use_cached_client:
635
664
  self.client = get_openai_client(
636
665
  api_key=self.api_key,
@@ -638,6 +667,8 @@ class OpenAIGPT(LanguageModel):
638
667
  organization=self.config.organization,
639
668
  timeout=Timeout(self.config.timeout),
640
669
  default_headers=self.config.headers,
670
+ http_client=http_client,
671
+ http_client_config=http_client_config_used,
641
672
  )
642
673
  self.async_client = get_async_openai_client(
643
674
  api_key=self.api_key,
@@ -645,23 +676,56 @@ class OpenAIGPT(LanguageModel):
645
676
  organization=self.config.organization,
646
677
  timeout=Timeout(self.config.timeout),
647
678
  default_headers=self.config.headers,
679
+ http_client=async_http_client,
680
+ http_client_config=http_client_config_used,
648
681
  )
649
682
  else:
650
683
  # Create new clients without caching
651
- self.client = OpenAI(
684
+ client_kwargs: Dict[str, Any] = dict(
652
685
  api_key=self.api_key,
653
686
  base_url=self.api_base,
654
687
  organization=self.config.organization,
655
688
  timeout=Timeout(self.config.timeout),
656
689
  default_headers=self.config.headers,
657
690
  )
658
- self.async_client = AsyncOpenAI(
691
+ if http_client is not None:
692
+ client_kwargs["http_client"] = http_client
693
+ elif http_client_config_used is not None:
694
+ # Create http_client from config for non-cached scenario
695
+ try:
696
+ from httpx import Client
697
+
698
+ client_kwargs["http_client"] = Client(**http_client_config_used)
699
+ except ImportError:
700
+ raise ValueError(
701
+ "httpx is required to use http_client_config. "
702
+ "Install it with: pip install httpx"
703
+ )
704
+ self.client = OpenAI(**client_kwargs)
705
+
706
+ async_client_kwargs: Dict[str, Any] = dict(
659
707
  api_key=self.api_key,
660
708
  base_url=self.api_base,
661
709
  organization=self.config.organization,
662
710
  timeout=Timeout(self.config.timeout),
663
711
  default_headers=self.config.headers,
664
712
  )
713
+ if async_http_client is not None:
714
+ async_client_kwargs["http_client"] = async_http_client
715
+ elif http_client_config_used is not None:
716
+ # Create async http_client from config for non-cached scenario
717
+ try:
718
+ from httpx import AsyncClient
719
+
720
+ async_client_kwargs["http_client"] = AsyncClient(
721
+ **http_client_config_used
722
+ )
723
+ except ImportError:
724
+ raise ValueError(
725
+ "httpx is required to use http_client_config. "
726
+ "Install it with: pip install httpx"
727
+ )
728
+ self.async_client = AsyncOpenAI(**async_client_kwargs)
665
729
 
666
730
  self.cache: CacheDB | None = None
667
731
  use_cache = self.config.cache_config is not None
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
25
25
  from crawl4ai.extraction_strategy import ExtractionStrategy
26
26
  from crawl4ai.markdown_generation_strategy import MarkdownGenerationStrategy
27
27
  except ImportError:
28
- raise LangroidImportError("crawl4ai", "crawl-4-ai")
28
+ raise LangroidImportError("crawl4ai", "crawl4ai")
29
29
 
30
30
  load_dotenv()
31
31
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "langroid"
3
- version = "0.58.1"
3
+ version = "0.58.3"
4
4
  authors = [
5
5
  {name = "Prasad Chalasani", email = "pchalasani@gmail.com"},
6
6
  ]
@@ -270,7 +270,7 @@ asyncio = [
270
270
  firecrawl = [
271
271
  "firecrawl-py>=1.13.5",
272
272
  ]
273
- crawl-4-ai = [
273
+ crawl4ai = [
274
274
  "crawl4ai>=0.6.3",
275
275
  ]
276
276
 
File without changes
File without changes
File without changes
File without changes
File without changes