Commit Graph

672 Commits

Author SHA1 Message Date
Nuno Campos
d2a69a7b6b core: Cache serialized manifest for llms, chat models and prompts (#26404) 2024-09-12 14:57:06 -07:00
Bagatur
41a632a2ae core[patch]: cherry-pick 212c688 (#26402)
Co-authored-by: Nuno Campos <nuno@langchain.dev>
2024-09-12 20:43:35 +00:00
Eugene Yurtsev
e19b6ad266 core[patch]: Lift restrictions on input variables due to pydantic (#26394)
This PR lifts the restrictions by pydantic by remapping the fields.

We could do a bit more work if we wanted to better catch issues if any
users are intentionally trying to create field collisions
2024-09-12 13:23:42 -04:00
Eugene Yurtsev
8defdb10d8 core[major]: Remove "Schema" suffix from tool name (#26389)
Remove the automatically appended "Schema" suffix to tool names.
2024-09-12 15:56:56 +00:00
Eugene Yurtsev
bde3dbaed2 core[major]: Add restrictions on create_model field names to match pydantic constraints (#26345)
Pydantic 2 is stricter in terms of which field names are allowed in
pydantic models.

This PR results in the following breaking changes:

These will raise ValueErrors: 

```python
ChatPromptTemplate([("system", "{_private}")]).get_input_schema()
ChatPromptTemplate([("system","{model_json_schema}")]).get_input_schema()
```

This PR should properly suppress warnings for the following cases:

```python
ChatPromptTemplate([("system", "{schema}")]).get_input_schema()
ChatPromptTemplate([("system","{model_id}")]).get_input_schema()
```
2024-09-12 11:34:16 -04:00
ccurme
284e1a7e9e core[patch]: support pydantic v1 annotations in tool arguments (#26336)
If all pydantic annotations in function signature are V1, use V1
`validate_arguments`.
2024-09-11 16:31:40 -04:00
Bagatur
d67e1dfe32 docs: fix merge messages how-to (#26351) 2024-09-11 13:29:35 -07:00
ccurme
c074922876 core[patch]: fix regression in convert_to_openai_tool with instances of Tool (v0.3rc) (#26349)
Cherry-pick https://github.com/langchain-ai/langchain/pull/26327 from
master.
2024-09-11 16:00:16 -04:00
Eugene Yurtsev
8b7f5e1ec0 core[patch]: Remove non relevant todos (#26332)
Clean up TODO(0.3)
2024-09-11 13:38:39 -04:00
Eugene Yurtsev
da48c98eaf core[patch]: Add type literal to LLMResult (#26282)
Needed for LangServe serialization/deserializastion of callback events.
2024-09-11 11:46:13 -04:00
Eugene Yurtsev
c417bbc313 core[patch]: Add default None to StructuredTool func (#26324)
This PR was autogenerated using gritql, tests written manually

```shell

grit apply 'class_definition(name=$C, $body, superclasses=$S) where {    
    $C <: ! "Config", // Does not work in this scope, but works after class_definition
    $body <: block($statements),
    $statements <: some bubble assignment(left=$x, right=$y, type=$t) as $A where {
        or {
            $y <: `Field($z)`,
            $x <: "model_config"
        }
    },
    // And has either Any or Optional fields without a default
    $statements <: some bubble assignment(left=$x, right=$y, type=$t) as $A where {
        $t <: or {
            r"Optional.*",
            r"Any",
            r"Union[None, .*]",
            r"Union[.*, None, .*]",
            r"Union[.*, None]",
        },
        $y <: ., // Match empty node        
        $t => `$t = None`,
    },    
}
' --language python .

```
2024-09-11 11:12:52 -04:00
Bagatur
aa9f247803 core[patch]: manually coerce ToolMessage args (#26283) 2024-09-10 15:57:57 -07:00
Bagatur
fce9322d2e core[patch]: use pydantic.v1 in old tracer code (#26290)
Thank you for contributing to LangChain!

- [ ] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
  - Example: "community: add foobar LLM"


- [ ] **PR message**: ***Delete this entire checklist*** and replace
with
    - **Description:** a description of the change
    - **Issue:** the issue # it fixes, if applicable
    - **Dependencies:** any dependencies required for this change
- **Twitter handle:** if your PR gets announced, and you'd like a
mention, we'll gladly shout you out!


- [ ] **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.


- [ ] **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/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
2024-09-10 15:48:02 -07:00
Eugene Yurtsev
bee8994b7e langchain,core: Deprecate pydantic.v1 shims (#26280)
Deprecate shim namespace
2024-09-10 16:19:20 -04:00
Bagatur
c43c62b6c9 merge msater (#26275) 2024-09-10 12:57:18 -07:00
Eugene Yurtsev
ed412d89b4 core[patch]: Do not hard coded name for RunnableBranch (#26276)
This is no longer necessary
2024-09-10 15:49:51 -04:00
Bagatur
13ba15b2cc Merge branch 'v0.3rc' into bagatur/09-10/v0.3_merge_master 2024-09-10 12:44:49 -07:00
Bagatur
cecdc119bf merge 2024-09-10 12:32:47 -07:00
Eugene Yurtsev
7975c1f0ca core[patch]: Propagate module name to create model (#26267)
* This allows pydantic to correctly resolve annotations necessary for
building pydantic models dynamically.
* Makes a small fix for RunnableWithMessageHistory which was fetching
the OutputType from the RunnableLambda that was yielding another
RunnableLambda. This doesn't propagate the output of the RunnableAssign
fully (i.e., with concrete type information etc.)

Resolves issue: https://github.com/langchain-ai/langchain/issues/26250
2024-09-10 15:22:56 -04:00
Bagatur
162d3ff54b docs: fix language_models docstring (#26268) 2024-09-10 10:41:28 -07:00
Bagatur
301be2d40a core[patch]: de-beta astream_events (#26248) 2024-09-10 10:09:29 -07:00
Bagatur
9132516c84 core[patch]: add back ChatModel.callback_manager deprecation (#26244) 2024-09-09 17:46:48 -07:00
Vadym Barda
bab9de581c core[patch]: wrap mermaid node names w/ markdown in <p> tag (#26235)
This fixes the issue where `__start__` and `__end__` node labels are
being interpreted as markdown, as of the most recent Mermaid update
2024-09-09 20:11:00 -04:00
Bagatur
baad44965e core[patch]: update docstrings (#26241) 2024-09-09 17:04:57 -07:00
Eugene Yurtsev
b8fc82b84b core[patch]: Fix _get_type in AnyMessage (#26223)
Fix _get_type to work on deserialization path as well and add a unit test.
2024-09-09 10:33:18 -04:00
Vadym Barda
1b3bd52e0e core[patch]: fix edge labels for mermaid graphs (#26201) 2024-09-08 14:35:25 +00:00
Bagatur
d9ba65ca26 core[patch]: pydantic 2.7-compatible AnyMessage (#26177) 2024-09-06 18:44:06 -04:00
Eugene Yurtsev
6e2a72c218 core[patch]: Add missing cache for create_model (#26173)
It makes a big difference for performance.
2024-09-06 17:59:18 -04:00
Bagatur
b2ba4f4072 core[patch]: fix deprecated pydantic code (#26161) 2024-09-06 17:14:17 -04:00
Bagatur
b2c8f2de4c core[patch]: fix ChatPromptValueConcrete typing (#26106)
Thank you for contributing to LangChain!

- [ ] **PR title**: "package: description"
- Where "package" is whichever of langchain, community, core,
experimental, etc. is being modified. Use "docs: ..." for purely docs
changes, "templates: ..." for template changes, "infra: ..." for CI
changes.
  - Example: "community: add foobar LLM"


- [ ] **PR message**: ***Delete this entire checklist*** and replace
with
    - **Description:** a description of the change
    - **Issue:** the issue # it fixes, if applicable
    - **Dependencies:** any dependencies required for this change
- **Twitter handle:** if your PR gets announced, and you'd like a
mention, we'll gladly shout you out!


- [ ] **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.


- [ ] **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/

Additional guidelines:
- Make sure optional dependencies are imported within a function.
- Please do not add dependencies to pyproject.toml files (even optional
ones) unless they are required for unit tests.
- Most PRs should not touch more than one package.
- Changes should be backwards compatible.
- If you are adding something to community, do not re-import it in
langchain.

If no one reviews your PR within a few days, please @-mention one of
baskaryan, efriis, eyurtsev, ccurme, vbarda, hwchase17.
2024-09-06 17:13:57 -04:00
Bagatur
6df9360e32 core[patch]: remove v1_repr (#26165)
Co-authored-by: Erick Friis <erick@langchain.dev>
2024-09-06 17:00:52 -04:00
ccurme
c27703a10f core[patch]: resolve warnings (#26157)
Resolve a batch of warnings
2024-09-06 15:00:53 -04:00
ccurme
b74546a458 core[patch]: add google genai to serialization (#26154) 2024-09-06 12:54:16 -04:00
Eugene Yurtsev
6fd4ac4283 core[patch]: Replace @validator with @model_validator in length based example selector (#26124)
Resolves another warning from usage of deprecated functionality in
pydantic 2
2024-09-05 18:26:43 -04:00
Eugene Yurtsev
f4e7cb394f core[patch]: Ignore pydantic deprecation warnings in validate_arguments (#26122)
For now, we'll use the deprecation functionality which is present until
pydantic 3.
2024-09-05 18:23:48 -04:00
ccurme
5bbd5364f1 core[patch]: call RunnableConfigurableFields.model_rebuild() (#26118)
To fix a test in `langchain`
2024-09-05 16:59:52 -04:00
ccurme
9e7222618b core: reduce warnings (#26108) 2024-09-05 15:04:41 -04:00
Harrison Chase
8516a03a02 langchain-community[major]: Upgrade community to pydantic 2 (#26011)
This PR upgrades langchain-community to pydantic 2.


* Most of this PR was auto-generated using code mods with gritql
(https://github.com/eyurtsev/migrate-pydantic/tree/main)
* Subsequently, some code was fixed manually due to accommodate
differences between pydantic 1 and 2

Breaking Changes:

- Use TEXTEMBED_API_KEY and TEXTEMBEB_API_URL for env variables for text
embed integrations:
cbea780492

Other changes:

- Added pydantic_settings as a required dependency for community. This
may be removed if we have enough time to convert the dependency into an
optional one.

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2024-09-05 14:07:10 -04:00
Eugene Yurtsev
1c51e1693d core[patch]: Fix issue with adapter utility for pydantic repr (#26099)
This repr will be deleted prior to release -- it's temporarily here to
make it easy to separate code changes in langchain vs. code changes
stemming from breaking changes in pydantic
2024-09-05 12:27:01 -04:00
Eugene Yurtsev
a267da6a3a core[minor]: Add type overload for secret_from_env factory (#26091)
Add type overload
2024-09-05 11:52:19 -04:00
ccurme
e358846b39 core[patch]: add bedrock to load.mapping (#26094) 2024-09-05 10:56:46 -04:00
Eugene Yurtsev
3c598d25a6 core[minor]: Add get_input_jsonschema, get_output_jsonschema, get_config_jsonschema (#26034)
This PR adds methods to directly get the json schema for inputs,
outputs, and config.
Currently, it's delegating to the underlying pydantic implementation,
but this may be changed in the future to be independent of pydantic.
2024-09-05 10:36:42 -04:00
Bagatur
caf4ae3a45 fmt 2024-09-04 13:31:28 -07:00
Bagatur
e409a85a28 fmt 2024-09-04 13:29:24 -07:00
Eugene Yurtsev
efa10c8ef8 core[minor]: Add message chunks to AnyMessage (#26057)
Adds the chunk variant of each Message to AnyMessage.

Required for this PR:
https://github.com/langchain-ai/langchain/pull/26050/files
2024-09-04 15:36:22 -04:00
Bagatur
dba308447d fmt 2024-09-04 11:28:04 -07:00
Bagatur
576574c82c fmt 2024-09-04 11:05:36 -07:00
ccurme
4799ad95d0 core[patch]: remove warnings from protected namespaces on RunnableSerializable (#26040) 2024-09-04 13:10:08 -04:00
Eugene Yurtsev
5f98975be0 core[patch]: Fix injected args in tool signature (#25991)
- Fix injected args in tool signature
- Fix another unit test that was using the wrong namespace import in
pydantic
2024-09-03 21:53:50 -04:00
Erick Friis
0da201c1d5 core: fix lint 0.3rc (#25993) 2024-09-03 17:13:52 -04:00