langchain 0.3.18rc2__py3-none-any.whl → 0.3.19__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.
@@ -50,9 +50,10 @@ class JSONAgentOutputParser(AgentOutputParser):
50
50
  if response["action"] == "Final Answer":
51
51
  return AgentFinish({"output": response["action_input"]}, text)
52
52
  else:
53
- return AgentAction(
54
- response["action"], response.get("action_input", {}), text
55
- )
53
+ action_input = response.get("action_input", {})
54
+ if action_input is None:
55
+ action_input = {}
56
+ return AgentAction(response["action"], action_input, text)
56
57
  except Exception as e:
57
58
  raise OutputParserException(f"Could not parse LLM output: {text}") from e
58
59
 
@@ -98,9 +98,12 @@ def init_chat_model(
98
98
  installed.
99
99
 
100
100
  Args:
101
- model: The name of the model, e.g. "gpt-4o", "claude-3-opus-20240229".
102
- model_provider: The model provider. Supported model_provider values and the
103
- corresponding integration package are:
101
+ model: The name of the model, e.g. "o3-mini", "claude-3-5-sonnet-latest". You can
102
+ also specify model and model provider in a single argument using
103
+ '{model_provider}:{model}' format, e.g. "openai:o1".
104
+ model_provider: The model provider if not specified as part of model arg (see
105
+ above). Supported model_provider values and the corresponding integration
106
+ package are:
104
107
 
105
108
  - 'openai' -> langchain-openai
106
109
  - 'anthropic' -> langchain-anthropic
@@ -117,6 +120,10 @@ def init_chat_model(
117
120
  - 'groq' -> langchain-groq
118
121
  - 'ollama' -> langchain-ollama
119
122
  - 'google_anthropic_vertex' -> langchain-google-vertexai
123
+ - 'deepseek' -> langchain-deepseek
124
+ - 'ibm' -> langchain-ibm
125
+ - 'nvidia' -> langchain-nvidia-ai-endpoints
126
+ - 'xai' -> langchain-xai
120
127
 
121
128
  Will attempt to infer model_provider from model if not specified. The
122
129
  following providers will be inferred based on these model prefixes:
@@ -128,6 +135,8 @@ def init_chat_model(
128
135
  - 'command...' -> 'cohere'
129
136
  - 'accounts/fireworks...' -> 'fireworks'
130
137
  - 'mistral...' -> 'mistralai'
138
+ - 'deepseek...' -> 'deepseek'
139
+ - 'grok...' -> 'xai'
131
140
  configurable_fields: Which model parameters are
132
141
  configurable:
133
142
 
@@ -179,13 +188,13 @@ def init_chat_model(
179
188
  # pip install langchain langchain-openai langchain-anthropic langchain-google-vertexai
180
189
  from langchain.chat_models import init_chat_model
181
190
 
182
- gpt_4o = init_chat_model("gpt-4o", model_provider="openai", temperature=0)
183
- claude_opus = init_chat_model("claude-3-opus-20240229", model_provider="anthropic", temperature=0)
184
- gemini_15 = init_chat_model("gemini-1.5-pro", model_provider="google_vertexai", temperature=0)
191
+ o3_mini = init_chat_model("openai:o3-mini", temperature=0)
192
+ claude_sonnet = init_chat_model("anthropic:claude-3-5-sonnet-latest", temperature=0)
193
+ gemini_2_flash = init_chat_model("google_vertexai:gemini-2.0-flash", temperature=0)
185
194
 
186
- gpt_4o.invoke("what's your name")
187
- claude_opus.invoke("what's your name")
188
- gemini_15.invoke("what's your name")
195
+ o3_mini.invoke("what's your name")
196
+ claude_sonnet.invoke("what's your name")
197
+ gemini_2_flash.invoke("what's your name")
189
198
 
190
199
 
191
200
  .. dropdown:: Partially configurable model with no default
@@ -206,7 +215,7 @@ def init_chat_model(
206
215
 
207
216
  configurable_model.invoke(
208
217
  "what's your name",
209
- config={"configurable": {"model": "claude-3-5-sonnet-20240620"}}
218
+ config={"configurable": {"model": "claude-3-5-sonnet-latest"}}
210
219
  )
211
220
  # claude-3.5 sonnet response
212
221
 
@@ -218,8 +227,7 @@ def init_chat_model(
218
227
  from langchain.chat_models import init_chat_model
219
228
 
220
229
  configurable_model_with_default = init_chat_model(
221
- "gpt-4o",
222
- model_provider="openai",
230
+ "openai:gpt-4o",
223
231
  configurable_fields="any", # this allows us to configure other params like temperature, max_tokens, etc at runtime.
224
232
  config_prefix="foo",
225
233
  temperature=0
@@ -232,8 +240,7 @@ def init_chat_model(
232
240
  "what's your name",
233
241
  config={
234
242
  "configurable": {
235
- "foo_model": "claude-3-5-sonnet-20240620",
236
- "foo_model_provider": "anthropic",
243
+ "foo_model": "anthropic:claude-3-5-sonnet-20240620",
237
244
  "foo_temperature": 0.6
238
245
  }
239
246
  }
@@ -287,18 +294,22 @@ def init_chat_model(
287
294
 
288
295
  .. versionchanged:: 0.2.12
289
296
 
290
- Support for ChatOllama via langchain-ollama package added
297
+ Support for Ollama via langchain-ollama package added
291
298
  (langchain_ollama.ChatOllama). Previously,
292
299
  the now-deprecated langchain-community version of Ollama was imported
293
300
  (langchain_community.chat_models.ChatOllama).
294
301
 
295
- Support for langchain_aws.ChatBedrockConverse added
302
+ Support for AWS Bedrock models via the Converse API added
296
303
  (model_provider="bedrock_converse").
297
304
 
298
305
  .. versionchanged:: 0.3.5
299
306
 
300
307
  Out of beta.
301
308
 
309
+ .. versionchanged:: 0.3.19
310
+
311
+ Support for Deepseek, IBM, Nvidia, and xAI models added.
312
+
302
313
  """ # noqa: E501
303
314
  if not model and not configurable_fields:
304
315
  configurable_fields = ("model", "model_provider")
@@ -421,6 +432,21 @@ def _init_chat_model_helper(
421
432
  from langchain_deepseek import ChatDeepSeek
422
433
 
423
434
  return ChatDeepSeek(model=model, **kwargs)
435
+ elif model_provider == "nvidia":
436
+ _check_pkg("langchain_nvidia_ai_endpoints")
437
+ from langchain_nvidia_ai_endpoints import ChatNVIDIA
438
+
439
+ return ChatNVIDIA(model=model, **kwargs)
440
+ elif model_provider == "ibm":
441
+ _check_pkg("langchain_ibm")
442
+ from langchain_ibm import ChatWatsonx
443
+
444
+ return ChatWatsonx(model_id=model, **kwargs)
445
+ elif model_provider == "xai":
446
+ _check_pkg("langchain_xai")
447
+ from langchain_xai import ChatXAI
448
+
449
+ return ChatXAI(model=model, **kwargs)
424
450
  else:
425
451
  supported = ", ".join(_SUPPORTED_PROVIDERS)
426
452
  raise ValueError(
@@ -446,11 +472,13 @@ _SUPPORTED_PROVIDERS = {
446
472
  "bedrock_converse",
447
473
  "google_anthropic_vertex",
448
474
  "deepseek",
475
+ "ibm",
476
+ "xai",
449
477
  }
450
478
 
451
479
 
452
480
  def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
453
- if any(model_name.startswith(pre) for pre in ("gpt-3", "gpt-4", "o1")):
481
+ if any(model_name.startswith(pre) for pre in ("gpt-3", "gpt-4", "o1", "o3")):
454
482
  return "openai"
455
483
  elif model_name.startswith("claude"):
456
484
  return "anthropic"
@@ -464,6 +492,10 @@ def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
464
492
  return "bedrock"
465
493
  elif model_name.startswith("mistral"):
466
494
  return "mistralai"
495
+ elif model_name.startswith("deepseek"):
496
+ return "deepseek"
497
+ elif model_name.startswith("grok"):
498
+ return "xai"
467
499
  else:
468
500
  return None
469
501
 
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langchain
3
- Version: 0.3.18rc2
3
+ Version: 0.3.19
4
4
  Summary: Building applications with LLMs through composability
5
5
  License: MIT
6
6
  Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/langchain
7
7
  Project-URL: Release Notes, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain%3D%3D0%22&expanded=true
8
8
  Project-URL: repository, https://github.com/langchain-ai/langchain
9
9
  Requires-Python: <4.0,>=3.9
10
- Requires-Dist: langchain-core<1.0.0,>=0.3.34rc2
11
- Requires-Dist: langchain-text-splitters<1.0.0,>=0.3.6rc2
10
+ Requires-Dist: langchain-core<1.0.0,>=0.3.35
11
+ Requires-Dist: langchain-text-splitters<1.0.0,>=0.3.6
12
12
  Requires-Dist: langsmith<0.4,>=0.1.17
13
13
  Requires-Dist: pydantic<3.0.0,>=2.7.4
14
14
  Requires-Dist: SQLAlchemy<3,>=1.4
@@ -22,9 +22,9 @@ Requires-Dist: async-timeout<5.0.0,>=4.0.0; python_version < "3.11"
22
22
  Provides-Extra: community
23
23
  Requires-Dist: langchain-community; extra == "community"
24
24
  Provides-Extra: anthropic
25
- Requires-Dist: langchain-anthropic>=0.3.7rc1; extra == "anthropic"
25
+ Requires-Dist: langchain-anthropic; extra == "anthropic"
26
26
  Provides-Extra: openai
27
- Requires-Dist: langchain-openai>=0.3.4rc1; extra == "openai"
27
+ Requires-Dist: langchain-openai; extra == "openai"
28
28
  Provides-Extra: cohere
29
29
  Requires-Dist: langchain-cohere; extra == "cohere"
30
30
  Provides-Extra: google-vertexai
@@ -47,6 +47,8 @@ Provides-Extra: aws
47
47
  Requires-Dist: langchain-aws; extra == "aws"
48
48
  Provides-Extra: deepseek
49
49
  Requires-Dist: langchain-deepseek; extra == "deepseek"
50
+ Provides-Extra: xai
51
+ Requires-Dist: langchain-xai; extra == "xai"
50
52
  Description-Content-Type: text/markdown
51
53
 
52
54
  # 🦜️🔗 LangChain
@@ -1,7 +1,7 @@
1
- langchain-0.3.18rc2.dist-info/METADATA,sha256=VuY663cPMaKm29Kx9iPZmRuZ9_TGR03jwV19ivv2TF8,7839
2
- langchain-0.3.18rc2.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- langchain-0.3.18rc2.dist-info/entry_points.txt,sha256=hLMwTN6pPNCY0cYtYmCYgY-piFzDb17o6ZrDC6IpdQU,75
4
- langchain-0.3.18rc2.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
1
+ langchain-0.3.19.dist-info/METADATA,sha256=S-FF3oq7oPneNryroGuJczaeyecMeokCY5IhNPTKwms,7875
2
+ langchain-0.3.19.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ langchain-0.3.19.dist-info/entry_points.txt,sha256=hLMwTN6pPNCY0cYtYmCYgY-piFzDb17o6ZrDC6IpdQU,75
4
+ langchain-0.3.19.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
5
5
  langchain/__init__.py,sha256=4cqV-N_QJnfjk52DqtR2e72vsmJC1R6PkflvRdLjZQI,13709
6
6
  langchain/_api/__init__.py,sha256=0FuHuMNUBMrst1Y1nm5yZzQr2xbLmb7rxMsimqKBXhs,733
7
7
  langchain/_api/deprecation.py,sha256=K9VCkmMs_ebfd_wCJppKq4Ahw-mlXkukbsQ69iQVxT0,1246
@@ -124,7 +124,7 @@ langchain/agents/openai_functions_multi_agent/base.py,sha256=dRVNujpitWkqgjleJaT
124
124
  langchain/agents/openai_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
125
  langchain/agents/openai_tools/base.py,sha256=8a5x0l2FFEv9juNTCRDpzgsLNg4W3sUzD4kT10JySNg,3596
126
126
  langchain/agents/output_parsers/__init__.py,sha256=Zzsf8moY-juhKCrnBDUhwgKQtW12cNBkua5faqbAlQA,1374
127
- langchain/agents/output_parsers/json.py,sha256=sW9e8fG4VlPnMn53dWIwSgnyRBUYs4ULFymrhW92sWQ,1846
127
+ langchain/agents/output_parsers/json.py,sha256=Q4G8FtZ2GG3JZ_ZCvntIVLL26LgW_O8jDlWnZK-k1gU,1931
128
128
  langchain/agents/output_parsers/openai_functions.py,sha256=MjNEFVCxYgS6Efr3HX4rR1zoks2vJxoV8FCUa240jPQ,3467
129
129
  langchain/agents/output_parsers/openai_tools.py,sha256=A_GpcYqy3xnkKrlBtrmHIUWwwLMyaKwWc8R-gEvRV3s,2317
130
130
  langchain/agents/output_parsers/react_json_single_input.py,sha256=SUkOGmdGGzxB4e1CNJD1eo4dJneiMYsgfGVHpxZ5bfI,2473
@@ -364,7 +364,7 @@ langchain/chat_models/azure_openai.py,sha256=aRNol2PNC49PmvdZnwjhQeMFRDOOelPNAXz
364
364
  langchain/chat_models/azureml_endpoint.py,sha256=6mxXm8UFXataLp0NYRGA88V3DpiNKPo095u_JGj7XGE,863
365
365
  langchain/chat_models/baichuan.py,sha256=3-GveFoF5ZNyLdRNK6V4i3EDDjdseOTFWbCMhDbtO9w,643
366
366
  langchain/chat_models/baidu_qianfan_endpoint.py,sha256=CZrX2SMpbE9H7wBXNC6rGvw-YqQl9zjuJrClYQxEzuI,715
367
- langchain/chat_models/base.py,sha256=ZpW2fAC0KigZMmEzxWQ_EREB4jTqXioE4unjDYlj2kw,33324
367
+ langchain/chat_models/base.py,sha256=--ERckyG_jME7_OKslfMvV_t58df8ce4iu4xtPWPUz4,34561
368
368
  langchain/chat_models/bedrock.py,sha256=HRV3T_0mEnZ8LvJJqAA_UVpt-_03G715oIgomRJw55M,757
369
369
  langchain/chat_models/cohere.py,sha256=EYOECHX-nKRhZVfCfmFGZ2lr51PzaB5OvOEqmBCu1fI,633
370
370
  langchain/chat_models/databricks.py,sha256=5_QkC5lG4OldaHC2FS0XylirJouyZx1YT95SKwc12M0,653
@@ -1339,4 +1339,4 @@ langchain/vectorstores/xata.py,sha256=HW_Oi5Hz8rH2JaUhRNWQ-3hLYmNzD8eAz6K5YqPArm
1339
1339
  langchain/vectorstores/yellowbrick.py,sha256=-lnjGcRE8Q1nEPOTdbKYTw5noS2cy2ce1ePOU804-_o,624
1340
1340
  langchain/vectorstores/zep.py,sha256=RJ2auxoA6uHHLEZknw3_jeFmYJYVt-PWKMBcNMGV6TM,798
1341
1341
  langchain/vectorstores/zilliz.py,sha256=XhPPIUfKPFJw0_svCoBgCnNkkBLoRVVcyuMfOnE5IxU,609
1342
- langchain-0.3.18rc2.dist-info/RECORD,,
1342
+ langchain-0.3.19.dist-info/RECORD,,