Skip to content

Commit 5855208

Browse files
authored
Merge branch 'master' into feat/trim_messages-support-approx-alias
2 parents d7b4e02 + 50012d9 commit 5855208

File tree

122 files changed

+2923
-1393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+2923
-1393
lines changed

β€Ž.github/actions/people/action.ymlβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Adapted from https://github.com/tiangolo/fastapi/blob/master/.github/actions/people/action.yml
2+
# TODO: fix this, migrate to new docs repo?
3+
24
name: "Generate LangChain People"
35
description: "Generate the data for the LangChain People page"
46
author: "Jacob Lee <[email protected]>"

β€Ž.github/actions/uv_setup/action.ymlβ€Ž

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Helper to set up Python and uv with caching
2+
13
name: uv-install
24
description: Set up Python and uv with caching
35

@@ -8,15 +10,15 @@ inputs:
810
enable-cache:
911
description: Enable caching for uv dependencies
1012
required: false
11-
default: 'true'
13+
default: "true"
1214
cache-suffix:
1315
description: Custom cache key suffix for cache invalidation
1416
required: false
15-
default: ''
17+
default: ""
1618
working-directory:
1719
description: Working directory for cache glob scoping
1820
required: false
19-
default: '**'
21+
default: "**"
2022

2123
env:
2224
UV_VERSION: "0.5.25"

β€Ž.github/labeler.ymlβ€Ž renamed to β€Ž.github/pr-file-labeler.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GitHub PR Labeler Configuration for LangChain
1+
# Label PRs (config)
22
# Automatically applies labels based on changed files and branch patterns
33

44
# Core packages

β€Ž.github/pr-title-labeler.ymlβ€Ž

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1-
# PR Title Labeler Configuration
1+
# PR title labeler config
2+
#
23
# Labels PRs based on conventional commit patterns in titles
4+
#
35
# Format: type(scope): description or type!: description (breaking)
46

57
add-missing-labels: true
8+
clear-prexisting: false
69
include-commits: false
710
include-title: true
811
label-for-breaking-changes: breaking
912

1013
label-mapping:
11-
# Features and enhancements
1214
feature: ["feat"]
13-
14-
# Bug fixes
1515
fix: ["fix"]
16-
17-
# Documentation
1816
documentation: ["docs"]
19-
20-
# Infrastructure and tooling
21-
infra: ["chore", "ci", "build", "infra"]
22-
23-
# Integration partners - detected by scope
24-
integration: ["anthropic", "chroma", "deepseek", "exa", "fireworks", "groq", "huggingface", "mistralai", "nomic", "ollama", "openai", "perplexity", "prompty", "qdrant", "xai"]
25-
26-
# Releases
17+
linting: ["style"]
18+
refactor: ["refactor"]
19+
performance: ["perf"]
20+
infra: ["build", "ci", "chore"]
21+
integration:
22+
[
23+
"anthropic",
24+
"chroma",
25+
"deepseek",
26+
"exa",
27+
"fireworks",
28+
"groq",
29+
"huggingface",
30+
"mistralai",
31+
"nomic",
32+
"ollama",
33+
"openai",
34+
"perplexity",
35+
"prompty",
36+
"qdrant",
37+
"xai",
38+
]
39+
revert: ["revert"]
2740
release: ["release"]

β€Ž.github/scripts/check_diff.pyβ€Ž

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
"""Analyze git diffs to determine which directories need to be tested.
2+
3+
Intelligently determines which LangChain packages and directories need to be tested,
4+
linted, or built based on the changes. Handles dependency relationships between
5+
packages, maps file changes to appropriate CI job configurations, and outputs JSON
6+
configurations for GitHub Actions.
7+
8+
- Maps changed files to affected package directories (libs/core, libs/partners/*, etc.)
9+
- Builds dependency graph to include dependent packages when core components change
10+
- Generates test matrix configurations with appropriate Python versions
11+
- Handles special cases for Pydantic version testing and performance benchmarks
12+
13+
Used as part of the check_diffs workflow.
14+
"""
15+
116
import glob
217
import json
318
import os
@@ -17,7 +32,7 @@
1732
"libs/langchain_v1",
1833
]
1934

20-
# when set to True, we are ignoring core dependents
35+
# When set to True, we are ignoring core dependents
2136
# in order to be able to get CI to pass for each individual
2237
# package that depends on core
2338
# e.g. if you touch core, we don't then add textsplitters/etc to CI
@@ -49,9 +64,9 @@ def all_package_dirs() -> Set[str]:
4964

5065

5166
def dependents_graph() -> dict:
52-
"""
53-
Construct a mapping of package -> dependents, such that we can
54-
run tests on all dependents of a package when a change is made.
67+
"""Construct a mapping of package -> dependents
68+
69+
Done such that we can run tests on all dependents of a package when a change is made.
5570
"""
5671
dependents = defaultdict(set)
5772

@@ -123,9 +138,6 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
123138
elif dir_ == "libs/core":
124139
py_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]
125140
# custom logic for specific directories
126-
elif dir_ == "libs/partners/milvus":
127-
# milvus doesn't allow 3.12 because they declare deps in funny way
128-
py_versions = ["3.9", "3.11"]
129141

130142
elif dir_ in PY_312_MAX_PACKAGES:
131143
py_versions = ["3.9", "3.12"]

β€Ž.github/scripts/check_prerelease_dependencies.pyβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Check that no dependencies allow prereleases unless we're releasing a prerelease."""
2+
13
import sys
24

35
import tomllib
@@ -6,15 +8,14 @@
68
# Get the TOML file path from the command line argument
79
toml_file = sys.argv[1]
810

9-
# read toml file
1011
with open(toml_file, "rb") as file:
1112
toml_data = tomllib.load(file)
1213

13-
# see if we're releasing an rc
14+
# See if we're releasing an rc or dev version
1415
version = toml_data["project"]["version"]
1516
releasing_rc = "rc" in version or "dev" in version
1617

17-
# if not, iterate through dependencies and make sure none allow prereleases
18+
# If not, iterate through dependencies and make sure none allow prereleases
1819
if not releasing_rc:
1920
dependencies = toml_data["project"]["dependencies"]
2021
for dep_version in dependencies:

β€Ž.github/scripts/get_min_versions.pyβ€Ž

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
"""Get minimum versions of dependencies from a pyproject.toml file."""
2+
13
import sys
24
from collections import defaultdict
35
from typing import Optional
46

57
if sys.version_info >= (3, 11):
68
import tomllib
79
else:
8-
# for python 3.10 and below, which doesnt have stdlib tomllib
10+
# For Python 3.10 and below, which doesnt have stdlib tomllib
911
import tomli as tomllib
1012

1113
import re
@@ -34,14 +36,13 @@
3436

3537

3638
def get_pypi_versions(package_name: str) -> List[str]:
37-
"""
38-
Fetch all available versions for a package from PyPI.
39+
"""Fetch all available versions for a package from PyPI.
3940
4041
Args:
41-
package_name (str): Name of the package
42+
package_name: Name of the package
4243
4344
Returns:
44-
List[str]: List of all available versions
45+
List of all available versions
4546
4647
Raises:
4748
requests.exceptions.RequestException: If PyPI API request fails
@@ -54,24 +55,23 @@ def get_pypi_versions(package_name: str) -> List[str]:
5455

5556

5657
def get_minimum_version(package_name: str, spec_string: str) -> Optional[str]:
57-
"""
58-
Find the minimum published version that satisfies the given constraints.
58+
"""Find the minimum published version that satisfies the given constraints.
5959
6060
Args:
61-
package_name (str): Name of the package
62-
spec_string (str): Version specification string (e.g., ">=0.2.43,<0.4.0,!=0.3.0")
61+
package_name: Name of the package
62+
spec_string: Version specification string (e.g., ">=0.2.43,<0.4.0,!=0.3.0")
6363
6464
Returns:
65-
Optional[str]: Minimum compatible version or None if no compatible version found
65+
Minimum compatible version or None if no compatible version found
6666
"""
67-
# rewrite occurrences of ^0.0.z to 0.0.z (can be anywhere in constraint string)
67+
# Rewrite occurrences of ^0.0.z to 0.0.z (can be anywhere in constraint string)
6868
spec_string = re.sub(r"\^0\.0\.(\d+)", r"0.0.\1", spec_string)
69-
# rewrite occurrences of ^0.y.z to >=0.y.z,<0.y+1 (can be anywhere in constraint string)
69+
# Rewrite occurrences of ^0.y.z to >=0.y.z,<0.y+1 (can be anywhere in constraint string)
7070
for y in range(1, 10):
7171
spec_string = re.sub(
7272
rf"\^0\.{y}\.(\d+)", rf">=0.{y}.\1,<0.{y + 1}", spec_string
7373
)
74-
# rewrite occurrences of ^x.y.z to >=x.y.z,<x+1.0.0 (can be anywhere in constraint string)
74+
# Rewrite occurrences of ^x.y.z to >=x.y.z,<x+1.0.0 (can be anywhere in constraint string)
7575
for x in range(1, 10):
7676
spec_string = re.sub(
7777
rf"\^{x}\.(\d+)\.(\d+)", rf">={x}.\1.\2,<{x + 1}", spec_string
@@ -154,22 +154,25 @@ def get_min_version_from_toml(
154154

155155

156156
def check_python_version(version_string, constraint_string):
157-
"""
158-
Check if the given Python version matches the given constraints.
157+
"""Check if the given Python version matches the given constraints.
159158
160-
:param version_string: A string representing the Python version (e.g. "3.8.5").
161-
:param constraint_string: A string representing the package's Python version constraints (e.g. ">=3.6, <4.0").
162-
:return: True if the version matches the constraints, False otherwise.
159+
Args:
160+
version_string: A string representing the Python version (e.g. "3.8.5").
161+
constraint_string: A string representing the package's Python version
162+
constraints (e.g. ">=3.6, <4.0").
163+
164+
Returns:
165+
True if the version matches the constraints
163166
"""
164167

165-
# rewrite occurrences of ^0.0.z to 0.0.z (can be anywhere in constraint string)
168+
# Rewrite occurrences of ^0.0.z to 0.0.z (can be anywhere in constraint string)
166169
constraint_string = re.sub(r"\^0\.0\.(\d+)", r"0.0.\1", constraint_string)
167-
# rewrite occurrences of ^0.y.z to >=0.y.z,<0.y+1.0 (can be anywhere in constraint string)
170+
# Rewrite occurrences of ^0.y.z to >=0.y.z,<0.y+1.0 (can be anywhere in constraint string)
168171
for y in range(1, 10):
169172
constraint_string = re.sub(
170173
rf"\^0\.{y}\.(\d+)", rf">=0.{y}.\1,<0.{y + 1}.0", constraint_string
171174
)
172-
# rewrite occurrences of ^x.y.z to >=x.y.z,<x+1.0.0 (can be anywhere in constraint string)
175+
# Rewrite occurrences of ^x.y.z to >=x.y.z,<x+1.0.0 (can be anywhere in constraint string)
173176
for x in range(1, 10):
174177
constraint_string = re.sub(
175178
rf"\^{x}\.0\.(\d+)", rf">={x}.0.\1,<{x + 1}.0.0", constraint_string

β€Ž.github/scripts/prep_api_docs_build.pyβ€Ž

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env python
2-
"""Script to sync libraries from various repositories into the main langchain repository."""
2+
"""Sync libraries from various repositories into this monorepo.
3+
4+
Moves cloned partner packages into libs/partners structure.
5+
"""
36

47
import os
58
import shutil
@@ -10,7 +13,7 @@
1013

1114

1215
def load_packages_yaml() -> Dict[str, Any]:
13-
"""Load and parse the packages.yml file."""
16+
"""Load and parse packages.yml."""
1417
with open("langchain/libs/packages.yml", "r") as f:
1518
return yaml.safe_load(f)
1619

@@ -61,12 +64,15 @@ def move_libraries(packages: list) -> None:
6164

6265

6366
def main():
64-
"""Main function to orchestrate the library sync process."""
67+
"""Orchestrate the library sync process."""
6568
try:
6669
# Load packages configuration
6770
package_yaml = load_packages_yaml()
6871

69-
# Clean target directories
72+
# Clean/empty target directories in preparation for moving new ones
73+
#
74+
# Only for packages in the langchain-ai org or explicitly included via
75+
# include_in_api_ref, excluding 'langchain' itself and 'langchain-ai21'
7076
clean_target_directories(
7177
[
7278
p
@@ -80,7 +86,9 @@ def main():
8086
]
8187
)
8288

83-
# Move libraries to their new locations
89+
# Move cloned libraries to their new locations, only for packages in the
90+
# langchain-ai org or explicitly included via include_in_api_ref,
91+
# excluding 'langchain' itself and 'langchain-ai21'
8492
move_libraries(
8593
[
8694
p
@@ -95,7 +103,7 @@ def main():
95103
]
96104
)
97105

98-
# Delete ones without a pyproject.toml
106+
# Delete partner packages without a pyproject.toml
99107
for partner in Path("langchain/libs/partners").iterdir():
100108
if partner.is_dir() and not (partner / "pyproject.toml").exists():
101109
print(f"Removing {partner} as it does not have a pyproject.toml")

β€Ž.github/workflows/_compile_integration_test.ymlβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Validates that a package's integration tests compile without syntax or import errors.
2+
#
3+
# (If an integration test fails to compile, it won't run.)
4+
#
5+
# Called as part of check_diffs.yml workflow
6+
#
7+
# Runs pytest with compile marker to check syntax/imports.
8+
19
name: 'πŸ”— Compile Integration Tests'
210

311
on:

β€Ž.github/workflows/_integration_test.ymlβ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
# Runs `make integration_tests` on the specified package.
3+
#
4+
# Manually triggered via workflow_dispatch for testing with real APIs.
5+
#
6+
# Installs integration test dependencies and executes full test suite.
7+
18
name: 'πŸš€ Integration Tests'
29
run-name: 'Test ${{ inputs.working-directory }} on Python ${{ inputs.python-version }}'
310

@@ -83,7 +90,7 @@ jobs:
8390
run: |
8491
make integration_tests
8592
86-
- name: Ensure the tests did not create any additional files
93+
- name: 'Ensure testing did not create/modify files'
8794
shell: bash
8895
run: |
8996
set -eu

0 commit comments

Comments
Β (0)