Eugene Yurtsev
c90c479119
Merge branch 'master' into wfh/rm_context_api
2025-03-31 10:47:38 -04:00
Christophe Bornet
8395abbb42
core: Fix test_stream_error_callback ( #30228 )
...
Fixes #29436
---------
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2025-03-31 10:37:22 -04:00
Christophe Bornet
026de908eb
core: Add ruff rules G, FA, INP, AIR and ISC ( #29334 )
...
Fixes mostly for rules G. See
https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
2025-03-31 10:05:23 -04:00
William FH
b075eab3e0
Include delayed inputs in langchain tracer ( #30546 )
2025-03-28 16:07:22 -07:00
Thommy257
372dc7f991
core[patch]: fix loss of partially initialized variables during prompt composition ( #30096 )
...
**Description:**
This PR addresses the loss of partially initialised variables when
composing different prompts. I.e. it allows the following snippet to
run:
```python
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_messages([('system', 'Prompt {x} {y}')]).partial(x='1')
appendix = ChatPromptTemplate.from_messages([('system', 'Appendix {z}')])
(prompt + appendix).invoke({'y': '2', 'z': '3'})
```
Previously, this would have raised a `KeyError`, stating that variable
`x` remains undefined.
**Issue**
References issue #30049
**Todo**
- [x] **Add tests and docs**: If you're adding a new integration, please
include
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in
`docs/docs/integrations` directory.
- [x] **Lint and test**: Run `make format`, `make lint` and `make test`
from the root of the package(s) you've modified. See contribution
guidelines for more: https://python.langchain.com/docs/contributing/
---------
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2025-03-28 20:41:57 +00:00
Eugene Yurtsev
d075ad21a0
core[patch]: specify default event loop scope in pyproject.toml ( #30543 )
...
Specify default event loop scope
2025-03-28 19:51:19 +00:00
Eugene Yurtsev
dd0faab07e
fix types
2025-03-28 14:23:50 -04:00
Eugene Yurtsev
21ab1dc675
Merge branch 'master' of github.com:xzq-xu/langchain into xzq-xu/master
2025-03-28 13:56:49 -04:00
Eugene Yurtsev
22cee5d983
x
2025-03-28 13:56:10 -04:00
Eugene Yurtsev
a14d8b103b
Merge branch 'master' into master
2025-03-28 13:53:58 -04:00
Eugene Yurtsev
6d22f40a0b
x
2025-03-28 13:51:06 -04:00
Christophe Bornet
e181d43214
core: Bump ruff version to 0.11 ( #30519 )
...
Changes are from the new TC006 rule:
https://docs.astral.sh/ruff/rules/runtime-cast-value/
TC006 is auto-fixed.
2025-03-27 13:01:49 -04:00
Keiichi Hirobe
956b09f468
core[patch]: stop deleting records with "scoped_full" when doc is empty ( #30520 )
...
Fix a bug that causes `scoped_full` in index to delete records when there are no input docs.
2025-03-27 11:04:34 -04:00
Christophe Bornet
b28a474e79
core[patch]: Add ruff rules for PLW (Pylint Warnings) ( #29288 )
...
See https://docs.astral.sh/ruff/rules/#warning-w_1
---------
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2025-03-27 10:26:12 +00:00
xzq.xu
92dc3f7341
format test lint passed
2025-03-27 13:44:59 +08:00
xzq.xu
d0a9808148
modify test name
2025-03-27 13:34:51 +08:00
xzq.xu
ed2428f902
add a unit test
2025-03-27 12:43:16 +08:00
ccurme
9a80be7bb7
core[patch]: release 0.3.49 ( #30500 )
2025-03-26 13:26:32 -04:00
xzq.xu
913c8b71d9
format import
2025-03-26 23:34:38 +08:00
xzq.xu
7e3dea5db8
add a new-line
2025-03-26 23:32:07 +08:00
xzq.xu
d602141ab1
remove unused e
2025-03-26 23:10:41 +08:00
xzq.xu
dd9031fc82
_prep_run_args,tool_input copy, Exception
2025-03-26 23:06:43 +08:00
xzq.xu
3382b0d8ea
_prep_run_args,tool_input copy
2025-03-26 22:56:32 +08:00
xzq.xu
65ecc22606
# Fix: Prevent run_manager from being added to state object
2025-03-26 22:36:31 +08:00
ccurme
7e62e3a137
core[patch]: store model names on usage callback handler ( #30487 )
...
So we avoid mingling tokens from different models.
2025-03-25 21:26:09 -04:00
ccurme
32827765bf
core[patch]: mark usage callback handler as beta ( #30486 )
2025-03-25 23:25:57 +00:00
Eugene Yurtsev
9f345d64fd
core[patch]: Remove old accidental commit ( #30483 )
...
Remove commented out file that was accidentally added
Co-authored-by: ccurme <chester.curme@gmail.com>
2025-03-25 15:37:20 -07:00
ccurme
4b9e2e51f3
core[patch]: add token counting callback handler ( #30481 )
...
Stripped-down version of
[OpenAICallbackHandler](https://github.com/langchain-ai/langchain/blob/master/libs/community/langchain_community/callbacks/openai_info.py )
that just tracks `AIMessage.usage_metadata`.
```python
from langchain_core.callbacks import get_usage_metadata_callback
from langgraph.prebuilt import create_react_agent
def get_weather(location: str) -> str:
"""Get the weather at a location."""
return "It's sunny."
tools = [get_weather]
agent = create_react_agent("openai:gpt-4o-mini", tools)
with get_usage_metadata_callback() as cb:
result = await agent.ainvoke({"messages": "What's the weather in Boston?"})
print(cb.usage_metadata)
```
2025-03-25 18:16:39 -04:00
Eugene Yurtsev
0acca6b9c8
core[patch]: Fix handling of title
when tool schema is specified manually via JSONSchema ( #30479 )
...
Fix issue: https://github.com/langchain-ai/langchain/issues/30456
2025-03-25 15:15:24 -04:00
Vadym Barda
97dec30eea
docs[patch]: update trim_messages doc ( #30462 )
2025-03-24 18:50:48 +00:00
Vadym Barda
7bc50730aa
core[patch]: release 0.3.48 ( #30458 )
2025-03-24 09:48:03 -04:00
Adrián Panella
b75573e858
core: add tool_call exclusion in filter_message ( #30289 )
...
Extend functionallity to allow to filter pairs of tool calls (ai +
tool).
---------
Co-authored-by: vbarda <vadym@langchain.dev>
2025-03-21 23:05:29 +00:00
Vadym Barda
673ec00030
docs[patch]: add warning to token counter docstring ( #30426 )
2025-03-21 18:59:40 -04:00
Adrián Panella
3933a4abc3
core(mermaid): allow greater customization ( #29939 )
...
Adds greater style customization by allowing a custom frontmatter
config. This allows to set a `theme` and `look` or to adjust theme by
setting `themeVariables`
Example:
```python
node_colors = NodeStyles(
default="fill:#e2e2e2,line-height:1.2,stroke:#616161",
first="fill:#cfeab8,fill-opacity:0",
last="fill:#eac3b8",
)
frontmatter_config = {
"config": {
"theme": "neutral",
"look": "handDrawn"
}
}
graph.get_graph().draw_mermaid_png(node_colors=node_colors, frontmatter_config=frontmatter_config)
```

---------
Co-authored-by: vbarda <vadym@langchain.dev>
2025-03-21 18:25:26 -04:00
Vadym Barda
07823cd41c
core[patch]: optimize trim_messages ( #30327 )
...
Refactored w/ Claude
Up to 20x speedup! (with theoretical max improvement of `O(n / log n)`)
2025-03-21 17:08:26 -04:00
Vadym Barda
4852ab8d0a
core[patch]: more tests for trim_messages ( #30421 )
2025-03-21 16:19:52 +00:00
ccurme
5588ca4cfb
core: release 0.3.47 ( #30396 )
2025-03-20 18:52:53 +00:00
ccurme
de3960d285
multiple: enforce standards on tool_choice ( #30372 )
...
- Test if models support forcing tool calls via `tool_choice`. If they
do, they should support
- `"any"` to specify any tool
- the tool name as a string to force calling a particular tool
- Add `tool_choice` to signature of `BaseChatModel.bind_tools` in core
- Deprecate `tool_choice_value` in standard tests in favor of a boolean
`has_tool_choice`
Will follow up with PRs in external repos (tested in AWS and Google
already).
2025-03-20 17:48:59 +00:00
Vadym Barda
73c04f4707
core[patch]: release 0.3.46 ( #30383 )
2025-03-19 15:09:08 -04:00
William Fu-Hinthorn
a3e8a7fd17
Remove unused Context API
2025-03-19 12:07:20 -07:00
William FH
ce84f8ba7e
Dereference run tree ( #30377 )
2025-03-19 19:05:06 +00:00
William FH
8265be4d3e
Unset context to None in var ( #30380 )
2025-03-19 18:53:17 +00:00
William FH
4130e6476b
Unset context after step ( #30378 )
...
While we are already careful to copy before setting the config, if other
objects hold a reference to the config or context, it wouldn't be
cleared.
2025-03-19 11:46:23 -07:00
Vadym Barda
37190881d3
core[patch]: add util for approximate token counting ( #30373 )
2025-03-19 17:48:38 +00:00
William FH
f5a0092551
Rm test for parent_run presence ( #30356 )
2025-03-18 19:44:19 -07:00
ccurme
315bb17ef5
core: release 0.3.45 ( #30277 )
2025-03-13 22:44:23 +00:00
Jacob Lee
e9c1765967
fix(core): Ignore missing secrets on deserialization ( #30252 )
2025-03-13 12:27:03 -07:00
ccurme
cd1ea8e94d
openai[patch]: support Responses API ( #30231 )
...
Co-authored-by: Bagatur <baskaryan@gmail.com>
2025-03-12 12:25:46 -04:00
Vadym Barda
23fa70f328
core[patch]: release 0.3.44 ( #30236 )
2025-03-11 18:59:02 -04:00
Vadym Barda
c7842730ef
core[patch]: support single-node subgraphs and put subgraph nodes under the respective subgraphs ( #30234 )
2025-03-11 18:55:45 -04:00