Mason Daugherty
123e29dc26
style: more refs fixes ( #33730 )
2025-10-29 16:34:46 -04:00
Mason Daugherty
1d2273597a
docs: more fixes for refs ( #33554 )
2025-10-16 22:54:16 -04:00
Mason Daugherty
15db024811
chore: more sweeping ( #33533 )
...
more fixes for refs
2025-10-16 15:44:56 -04:00
ccurme
c1b816cb7e
fix(fireworks): parse standard blocks in input ( #33426 )
2025-10-10 16:18:37 -04:00
Mason Daugherty
291a9fcea1
style: llm -> model ( #33423 )
2025-10-10 13:19:13 -04:00
Mason Daugherty
6fc21afbc9
style: .. code-block:: admonition translations ( #33400 )
...
biiiiiiiiiiiiiiiigggggggg pass
2025-10-09 16:52:58 -04:00
Mason Daugherty
d8a680ee57
style: address Sphinx double-backtick snippet syntax ( #33389 )
2025-10-09 13:35:51 -04:00
Mason Daugherty
3576e690fa
chore: update Sphinx links to markdown ( #33386 )
2025-10-09 11:54:14 -04:00
Mason Daugherty
b6132fc23e
style: remove more Optional syntax ( #33371 )
2025-10-08 23:28:43 -04:00
Mason Daugherty
31eeb50ce0
chore: drop UP045 ( #33362 )
...
Python 3.9 EOL
2025-10-08 21:17:53 -04:00
Mason Daugherty
d13823043d
style: monorepo pass for refs ( #33359 )
...
* Delete some double backticks previously used by Sphinx (not done
everywhere yet)
* Fix some code blocks / dropdowns
Ignoring CLI CI for now
2025-10-08 18:41:39 -04:00
Mason Daugherty
e85b03d5e4
release(fireworks): 1.0.0a1 ( #33230 )
2025-10-02 19:03:54 -04:00
Mason Daugherty
ae5b105d11
docs: v1 docs updates ( #33173 )
...
Co-authored-by: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com >
Co-authored-by: Caspar Broekhuizen <caspar@langchain.dev >
Co-authored-by: ccurme <chester.curme@gmail.com >
Co-authored-by: Christophe Bornet <cbornet@hotmail.com >
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com >
Co-authored-by: Sadra Barikbin <sadraqazvin1@yahoo.com >
Co-authored-by: Vadym Barda <vadim.barda@gmail.com >
2025-10-02 18:46:26 -04:00
Mason Daugherty
eaa6dcce9e
release: v1.0.0 ( #32567 )
...
Co-authored-by: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com >
Co-authored-by: Caspar Broekhuizen <caspar@langchain.dev >
Co-authored-by: ccurme <chester.curme@gmail.com >
Co-authored-by: Christophe Bornet <cbornet@hotmail.com >
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com >
Co-authored-by: Sadra Barikbin <sadraqazvin1@yahoo.com >
Co-authored-by: Vadym Barda <vadim.barda@gmail.com >
2025-10-02 10:49:42 -04:00
Mason Daugherty
b92b394804
style: repo linting pass ( #33089 )
...
enable docstring-code-format
2025-09-24 15:25:55 -04:00
Matthew Lapointe
b1f08467cd
feat(core): allow overriding ls_model_name from kwargs ( #32541 )
2025-09-11 16:18:06 -04:00
Mason Daugherty
96cbd90cba
fix: formatting issues in docstrings ( #32265 )
...
Ensures proper reStructuredText formatting by adding the required blank
line before closing docstring quotes, which resolves the "Block quote
ends without a blank line; unexpected unindent" warning.
2025-07-27 23:37:47 -04:00
niceg
0d6f915442
fix: LLM mimicking Unicode responses due to forced Unicode conversion of non-ASCII characters. ( #32222 )
...
fix: Fix LLM mimicking Unicode responses due to forced Unicode
conversion of non-ASCII characters.
- **Description:** This PR fixes an issue where the LLM would mimic
Unicode responses due to forced Unicode conversion of non-ASCII
characters in tool calls. The fix involves disabling the `ensure_ascii`
flag in `json.dumps()` when converting tool calls to OpenAI format.
- **Issue:** Fixes ↓↓↓
input:
```json
{'role': 'assistant', 'tool_calls': [{'type': 'function', 'id': 'call_nv9trcehdpihr21zj9po19vq', 'function': {'name': 'create_customer', 'arguments': '{"customer_name": "你好啊集团"}'}}]}
```
output:
```json
{'role': 'assistant', 'tool_calls': [{'type': 'function', 'id': 'call_nv9trcehdpihr21zj9po19vq', 'function': {'name': 'create_customer', 'arguments': '{"customer_name": "\\u4f60\\u597d\\u554a\\u96c6\\u56e2"}'}}]}
```
then:
llm will mimic outputting unicode. Unicode's vast number of symbols can
lengthen LLM responses, leading to slower performance.
<img width="686" height="277" alt="image"
src="https://github.com/user-attachments/assets/28f3b007-3964-4455-bee2-68f86ac1906d "
/>
---------
Co-authored-by: Mason Daugherty <github@mdrxy.com >
Co-authored-by: Mason Daugherty <mason@langchain.dev >
2025-07-24 17:01:31 -04:00
Mason Daugherty
d53ebf367e
fix(docs): capitalization, codeblock formatting, and hyperlinks, note blocks ( #32235 )
...
widespread cleanup attempt
2025-07-24 16:55:04 -04:00
Mason Daugherty
4d9eefecab
fix: bump lockfiles ( #31923 )
...
* bump lockfiles after upgrading ruff
* resolve resulting linting fixes
2025-07-08 13:27:55 -04:00
Mason Daugherty
06ab2972e3
fireworks[patch]: ruff fixes and rules ( #31903 )
...
* bump ruff deps
* add more thorough ruff rules
* fix said rules
2025-07-08 02:14:59 +00:00
Mason Daugherty
479b6fd7c5
langchain-fireworks[patch]: Add ruff bandit rules to linter ( #31796 )
...
- Add ruff bandit rules
- Address a s113 error
2025-07-01 11:07:26 -04:00
ccurme
eedda164c6
fireworks[minor]: remove default model and temperature ( #30965 )
...
`mixtral-8x-7b-instruct` was recently retired from Fireworks Serverless.
Here we remove the default model altogether, so that the model must be
explicitly specified on init:
```python
ChatFireworks(model="accounts/fireworks/models/llama-v3p1-70b-instruct") # for example
```
We also set a null default for `temperature`, which previously defaulted
to 0.0. This parameter will no longer be included in request payloads
unless it is explicitly provided.
2025-04-22 15:58:58 -04:00
Sydney Runkle
8c6734325b
partners[lint]: run pyupgrade to get code in line with 3.9 standards ( #30781 )
...
Using `pyupgrade` to get all `partners` code up to 3.9 standards
(mostly, fixing old `typing` imports).
2025-04-11 07:18:44 -04:00
ccurme
22d1a7d7b6
standard-tests[patch]: require model_name in response_metadata if returns_usage_metadata ( #30497 )
...
We are implementing a token-counting callback handler in
`langchain-core` that is intended to work with all chat models
supporting usage metadata. The callback will aggregate usage metadata by
model. This requires responses to include the model name in its
metadata.
To support this, if a model `returns_usage_metadata`, we check that it
includes a string model name in its `response_metadata` in the
`"model_name"` key.
More context: https://github.com/langchain-ai/langchain/pull/30487
2025-03-26 12:20:53 -04:00
ccurme
b86cd8270c
multiple: support strict and method in with_structured_output ( #30385 )
2025-03-20 13:17:07 -04:00
ccurme
806211475a
core[patch]: update structured output tracing ( #30123 )
...
- Trace JSON schema in `options`
- Rename to `ls_structured_output_format`
2025-03-07 13:05:25 -05:00
Erick Friis
8f95da4eb1
multiple: structured output tracing standard metadata ( #29421 )
...
Co-authored-by: Chester Curme <chester.curme@gmail.com >
2025-01-29 14:00:26 -08:00
Erick Friis
187131c55c
Revert "integrations[patch]: remove non-required chat param defaults" ( #29048 )
...
Reverts langchain-ai/langchain#26730
discuss best way to release default changes (esp openai temperature)
2025-01-06 14:45:34 -08:00
Bagatur
3d7ae8b5d2
integrations[patch]: remove non-required chat param defaults ( #26730 )
...
anthropic:
- max_retries
openai:
- n
- temperature
- max_retries
fireworks
- temperature
groq
- n
- max_retries
- temperature
mistral
- max_retries
- timeout
- max_concurrent_requests
- temperature
- top_p
- safe_mode
---------
Co-authored-by: Erick Friis <erick@langchain.dev >
2025-01-06 22:26:22 +00:00
Erick Friis
907f36a6e9
fireworks: fix lint ( #28821 )
2024-12-19 15:36:36 +00:00
Erick Friis
d1108607f4
multiple: push deprecation removals to 1.0 ( #28236 )
2024-11-20 19:56:29 -08:00
Bagatur
4935a14314
core,integrations[minor]: Dont error on fields in model_kwargs ( #27110 )
...
Given the current erroring behavior, every time we've moved a kwarg from
model_kwargs and made it its own field that was a breaking change.
Updating this behavior to support the old instantiations /
serializations.
Assuming build_extra_kwargs was not something that itself is being used
externally and needs to be kept backwards compatible
2024-10-04 11:30:27 -07:00
Bagatur
0078493a80
fireworks[patch]: allow tool_choice with multiple tools ( #26999 )
...
https://docs.fireworks.ai/api-reference/post-chatcompletions
2024-09-30 11:28:43 -07:00
Bagatur
e1d113ea84
core,openai,grow,fw[patch]: deprecate bind_functions, update chat mod… ( #26584 )
...
…el api ref
2024-09-17 11:32:39 -07:00
Erick Friis
c2a3021bb0
multiple: pydantic 2 compatibility, v0.3 ( #26443 )
...
Signed-off-by: ChengZi <chen.zhang@zilliz.com >
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com >
Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com >
Co-authored-by: Dan O'Donovan <dan.odonovan@gmail.com >
Co-authored-by: Tom Daniel Grande <tomdgrande@gmail.com >
Co-authored-by: Grande <Tom.Daniel.Grande@statsbygg.no >
Co-authored-by: Bagatur <baskaryan@gmail.com >
Co-authored-by: ccurme <chester.curme@gmail.com >
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com >
Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com >
Co-authored-by: ZhangShenao <15201440436@163.com >
Co-authored-by: Friso H. Kingma <fhkingma@gmail.com >
Co-authored-by: ChengZi <chen.zhang@zilliz.com >
Co-authored-by: Nuno Campos <nuno@langchain.dev >
Co-authored-by: Morgante Pell <morgantep@google.com >
2024-09-13 14:38:45 -07:00
Eugene Yurtsev
eb3870e9d8
fireworks[patch]: Upgrade @root_validators to be pydantic 2 compliant ( #25443 )
...
Update @root_validators to be pydantic 2 compliant
2024-08-15 16:56:48 +00:00
Eugene Yurtsev
5f5e8c9a60
huggingface[patch], pinecone[patch], fireworks[patch], mistralai[patch], voyageai[patch], togetherai[path]: convert Pydantic extras to literals ( #25384 )
...
Backwards compatible change that converts pydantic extras to literals
which is consistent with pydantic 2 usage.
- fireworks
- voyage ai
- mistralai
- mistral ai
- together ai
- huggigng face
- pinecone
2024-08-14 09:55:30 -04:00
Eugene Yurtsev
1c9917dfa2
fireworks[patch]: Fix doc-string for API Referenmce ( #25304 )
2024-08-12 17:16:13 +00:00
Eugene Yurtsev
53ee5770d3
fireworks: Add APIReference for the FireworksEmbeddings model ( #25292 )
...
Add API Reference documentation for the FireworksEmbedding model.
Issue: https://github.com/langchain-ai/langchain/issues/24856
2024-08-12 13:13:43 -04:00
Bagatur
8461934c2b
core[patch], integrations[patch]: convert TypedDict to tool schema support ( #24641 )
...
supports following UX
```python
class SubTool(TypedDict):
"""Subtool docstring"""
args: Annotated[Dict[str, Any], {}, "this does bar"]
class Tool(TypedDict):
"""Docstring
Args:
arg1: foo
"""
arg1: str
arg2: Union[int, str]
arg3: Optional[List[SubTool]]
arg4: Annotated[Literal["bar", "baz"], ..., "this does foo"]
arg5: Annotated[Optional[float], None]
```
- can parse google style docstring
- can use Annotated to specify default value (second arg)
- can use Annotated to specify arg description (third arg)
- can have nested complex types
2024-07-31 18:27:24 +00:00
Chuck Wooters
56c2a7f6d4
partners: add missing key name to Field() for ChatFireworks model ( #24721 )
...
**Description:**
In the `ChatFireworks` class definition, the Field() call for the "stop"
("stop_sequences") parameter is missing the "default" keyword.
**Issue:**
Type checker reports "stop_sequences" as a missing arg (not recognizing
the default value is None)
**Dependencies:**
None
**Twitter handle:**
None
2024-07-28 18:40:21 +00:00
Bagatur
236e957abb
core,groq,openai,mistralai,robocorp,fireworks,anthropic[patch]: Update BaseModel subclass and instance checks to handle both v1 and proper namespaces ( #24417 )
...
After this PR chat models will correctly handle pydantic 2 with
bind_tools and with_structured_output.
```python
import pydantic
print(pydantic.__version__)
```
2.8.2
```python
from langchain_openai import ChatOpenAI
from pydantic import BaseModel, Field
class Add(BaseModel):
x: int
y: int
model = ChatOpenAI().bind_tools([Add])
print(model.invoke('2 + 5').tool_calls)
model = ChatOpenAI().with_structured_output(Add)
print(type(model.invoke('2 + 5')))
```
```
[{'name': 'Add', 'args': {'x': 2, 'y': 5}, 'id': 'call_PNUFa4pdfNOYXxIMHc6ps2Do', 'type': 'tool_call'}]
<class '__main__.Add'>
```
```python
from langchain_openai import ChatOpenAI
from pydantic.v1 import BaseModel, Field
class Add(BaseModel):
x: int
y: int
model = ChatOpenAI().bind_tools([Add])
print(model.invoke('2 + 5').tool_calls)
model = ChatOpenAI().with_structured_output(Add)
print(type(model.invoke('2 + 5')))
```
```python
[{'name': 'Add', 'args': {'x': 2, 'y': 5}, 'id': 'call_hhiHYP441cp14TtrHKx3Upg0', 'type': 'tool_call'}]
<class '__main__.Add'>
```
Addresses issues: https://github.com/langchain-ai/langchain/issues/22782
---------
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com >
2024-07-22 20:07:39 +00:00
Bagatur
5fd1e67808
core[minor], integrations...[patch]: Support ToolCall as Tool input and ToolMessage as Tool output ( #24038 )
...
Changes:
- ToolCall, InvalidToolCall and ToolCallChunk can all accept a "type"
parameter now
- LLM integration packages add "type" to all the above
- Tool supports ToolCall inputs that have "type" specified
- Tool outputs ToolMessage when a ToolCall is passed as input
- Tools can separately specify ToolMessage.content and
ToolMessage.raw_output
- Tools emit events for validation errors (using on_tool_error and
on_tool_end)
Example:
```python
@tool("structured_api", response_format="content_and_raw_output")
def _mock_structured_tool_with_raw_output(
arg1: int, arg2: bool, arg3: Optional[dict] = None
) -> Tuple[str, dict]:
"""A Structured Tool"""
return f"{arg1} {arg2}", {"arg1": arg1, "arg2": arg2, "arg3": arg3}
def test_tool_call_input_tool_message_with_raw_output() -> None:
tool_call: Dict = {
"name": "structured_api",
"args": {"arg1": 1, "arg2": True, "arg3": {"img": "base64string..."}},
"id": "123",
"type": "tool_call",
}
expected = ToolMessage("1 True", raw_output=tool_call["args"], tool_call_id="123")
tool = _mock_structured_tool_with_raw_output
actual = tool.invoke(tool_call)
assert actual == expected
tool_call.pop("type")
with pytest.raises(ValidationError):
tool.invoke(tool_call)
actual_content = tool.invoke(tool_call["args"])
assert actual_content == expected.content
```
---------
Co-authored-by: Erick Friis <erick@langchain.dev >
2024-07-11 14:54:02 -07:00
Bagatur
a0c2281540
infra: update mypy 1.10, ruff 0.5 ( #23721 )
...
```python
"""python scripts/update_mypy_ruff.py"""
import glob
import tomllib
from pathlib import Path
import toml
import subprocess
import re
ROOT_DIR = Path(__file__).parents[1]
def main():
for path in glob.glob(str(ROOT_DIR / "libs/**/pyproject.toml"), recursive=True):
print(path)
with open(path, "rb") as f:
pyproject = tomllib.load(f)
try:
pyproject["tool"]["poetry"]["group"]["typing"]["dependencies"]["mypy"] = (
"^1.10"
)
pyproject["tool"]["poetry"]["group"]["lint"]["dependencies"]["ruff"] = (
"^0.5"
)
except KeyError:
continue
with open(path, "w") as f:
toml.dump(pyproject, f)
cwd = "/".join(path.split("/")[:-1])
completed = subprocess.run(
"poetry lock --no-update; poetry install --with typing; poetry run mypy . --no-color",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
logs = completed.stdout.split("\n")
to_ignore = {}
for l in logs:
if re.match("^(.*)\:(\d+)\: error:.*\[(.*)\]", l):
path, line_no, error_type = re.match(
"^(.*)\:(\d+)\: error:.*\[(.*)\]", l
).groups()
if (path, line_no) in to_ignore:
to_ignore[(path, line_no)].append(error_type)
else:
to_ignore[(path, line_no)] = [error_type]
print(len(to_ignore))
for (error_path, line_no), error_types in to_ignore.items():
all_errors = ", ".join(error_types)
full_path = f"{cwd}/{error_path}"
try:
with open(full_path, "r") as f:
file_lines = f.readlines()
except FileNotFoundError:
continue
file_lines[int(line_no) - 1] = (
file_lines[int(line_no) - 1][:-1] + f" # type: ignore[{all_errors}]\n"
)
with open(full_path, "w") as f:
f.write("".join(file_lines))
subprocess.run(
"poetry run ruff format .; poetry run ruff --select I --fix .",
cwd=cwd,
shell=True,
capture_output=True,
text=True,
)
if __name__ == "__main__":
main()
```
2024-07-03 10:33:27 -07:00
ccurme
54e730f6e4
fireworks[patch]: read from tool calls attribute ( #23820 )
2024-07-03 11:11:17 -04:00
Bagatur
fc8fd49328
openai, anthropic, ...: with_structured_output to pass in explicit tool choice ( #23645 )
...
...community, mistralai, groq, fireworks
part of #23644
2024-06-28 16:39:53 -07:00
Julian Weng
6a1a0d977a
partners[minor]: Fix value error message for with_structured_output ( #22877 )
...
Currently, calling `with_structured_output()` with an invalid method
argument raises `Unrecognized method argument. Expected one of
'function_calling' or 'json_format'`, but the JSON mode option [is now
referred
to](https://python.langchain.com/v0.2/docs/how_to/structured_output/#the-with_structured_output-method )
by `'json_mode'`. This fixes that.
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com >
2024-06-20 15:03:21 +00:00
shaunakgodbole
7193634ae6
fireworks[patch]: fix api_key alias in Fireworks LLM ( #23118 )
...
Thank you for contributing to LangChain!
**Description**
The current code snippet for `Fireworks` had incorrect parameters. This
PR fixes those parameters.
---------
Co-authored-by: Chester Curme <chester.curme@gmail.com >
Co-authored-by: Bagatur <baskaryan@gmail.com >
2024-06-19 21:14:42 +00:00
Bagatur
d96f67b06f
standard-tests[patch]: Update chat model standard tests ( #22378 )
...
- Refactor standard test classes to make them easier to configure
- Update openai to support stop_sequences init param
- Update groq to support stop_sequences init param
- Update fireworks to support max_retries init param
- Update ChatModel.bind_tools to type tool_choice
- Update groq to handle tool_choice="any". **this may be controversial**
---------
Co-authored-by: Chester Curme <chester.curme@gmail.com >
2024-06-17 13:37:41 -07:00