Skip to content

Commit c171cd5

Browse files
authored
Merge branch 'master' into array_data_type
2 parents 6ec9b86 + f679ed7 commit c171cd5

File tree

1,227 files changed

+72508
-31761
lines changed

Some content is hidden

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

1,227 files changed

+72508
-31761
lines changed

.devcontainer/docker-compose.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ services:
55
dockerfile: libs/langchain/dev.Dockerfile
66
context: ..
77
volumes:
8-
# Update this to wherever you want VS Code to mount the folder of your project
8+
# Update this to wherever you want VS Code to mount the folder of your project
99
- ..:/workspaces/langchain:cached
1010
networks:
11-
- langchain-network
11+
- langchain-network
1212
# environment:
1313
# MONGO_ROOT_USERNAME: root
1414
# MONGO_ROOT_PASSWORD: example123
@@ -28,5 +28,3 @@ services:
2828
networks:
2929
langchain-network:
3030
driver: bridge
31-
32-

.github/scripts/check_diff.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import glob
22
import json
33
import os
4-
import re
54
import sys
65
import tomllib
76
from collections import defaultdict
@@ -86,6 +85,11 @@ def add_dependents(dirs_to_eval: Set[str], dependents: dict) -> List[str]:
8685

8786

8887
def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
88+
if dir_ == "libs/core":
89+
return [
90+
{"working-directory": dir_, "python-version": f"3.{v}"}
91+
for v in range(8, 13)
92+
]
8993
min_python = "3.8"
9094
max_python = "3.12"
9195

@@ -95,6 +99,15 @@ def _get_configs_for_single_dir(job: str, dir_: str) -> List[Dict[str, str]]:
9599
# declare deps in funny way
96100
max_python = "3.11"
97101

102+
if dir_ in ["libs/community", "libs/langchain"] and job == "extended-tests":
103+
# community extended test resolution in 3.12 is slow
104+
# even in uv
105+
max_python = "3.11"
106+
107+
if dir_ == "libs/community" and job == "compile-integration-tests":
108+
# community integration deps are slow in 3.12
109+
max_python = "3.11"
110+
98111
return [
99112
{"working-directory": dir_, "python-version": min_python},
100113
{"working-directory": dir_, "python-version": max_python},
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import sys
2+
import tomllib
3+
4+
if __name__ == "__main__":
5+
# Get the TOML file path from the command line argument
6+
toml_file = sys.argv[1]
7+
8+
# read toml file
9+
with open(toml_file, "rb") as file:
10+
toml_data = tomllib.load(file)
11+
12+
# see if we're releasing an rc
13+
version = toml_data["tool"]["poetry"]["version"]
14+
releasing_rc = "rc" in version
15+
16+
# if not, iterate through dependencies and make sure none allow prereleases
17+
if not releasing_rc:
18+
dependencies = toml_data["tool"]["poetry"]["dependencies"]
19+
for lib in dependencies:
20+
dep_version = dependencies[lib]
21+
dep_version_string = (
22+
dep_version["version"] if isinstance(dep_version, dict) else dep_version
23+
)
24+
25+
if "rc" in dep_version_string:
26+
raise ValueError(
27+
f"Dependency {lib} has a prerelease version. Please remove this."
28+
)
29+
30+
if isinstance(dep_version, dict) and dep_version.get(
31+
"allow-prereleases", False
32+
):
33+
raise ValueError(
34+
f"Dependency {lib} has allow-prereleases set to true. Please remove this."
35+
)

.github/scripts/get_min_versions.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import sys
22

3-
import tomllib
3+
if sys.version_info >= (3, 11):
4+
import tomllib
5+
else:
6+
# for python 3.10 and below, which doesnt have stdlib tomllib
7+
import tomli as tomllib
8+
49
from packaging.version import parse as parse_version
510
import re
611

@@ -12,6 +17,8 @@
1217
"SQLAlchemy",
1318
]
1419

20+
SKIP_IF_PULL_REQUEST = ["langchain-core"]
21+
1522

1623
def get_min_version(version: str) -> str:
1724
# base regex for x.x.x with cases for rc/post/etc
@@ -38,7 +45,7 @@ def get_min_version(version: str) -> str:
3845
raise ValueError(f"Unrecognized version format: {version}")
3946

4047

41-
def get_min_version_from_toml(toml_path: str):
48+
def get_min_version_from_toml(toml_path: str, versions_for: str):
4249
# Parse the TOML file
4350
with open(toml_path, "rb") as file:
4451
toml_data = tomllib.load(file)
@@ -51,6 +58,10 @@ def get_min_version_from_toml(toml_path: str):
5158

5259
# Iterate over the libs in MIN_VERSION_LIBS
5360
for lib in MIN_VERSION_LIBS:
61+
if versions_for == "pull_request" and lib in SKIP_IF_PULL_REQUEST:
62+
# some libs only get checked on release because of simultaneous
63+
# changes
64+
continue
5465
# Check if the lib is present in the dependencies
5566
if lib in dependencies:
5667
# Get the version string
@@ -71,8 +82,10 @@ def get_min_version_from_toml(toml_path: str):
7182
if __name__ == "__main__":
7283
# Get the TOML file path from the command line argument
7384
toml_file = sys.argv[1]
85+
versions_for = sys.argv[2]
86+
assert versions_for in ["release", "pull_request"]
7487

7588
# Call the function to get the minimum versions
76-
min_versions = get_min_version_from_toml(toml_file)
89+
min_versions = get_min_version_from_toml(toml_file, versions_for)
7790

7891
print(" ".join([f"{lib}=={version}" for lib, version in min_versions.items()]))

.github/workflows/_release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189
--extra-index-url https://test.pypi.org/simple/ \
190190
"$PKG_NAME==$VERSION" || \
191191
( \
192-
sleep 5 && \
192+
sleep 15 && \
193193
poetry run pip install \
194194
--extra-index-url https://test.pypi.org/simple/ \
195195
"$PKG_NAME==$VERSION" \
@@ -221,12 +221,17 @@ jobs:
221221
run: make tests
222222
working-directory: ${{ inputs.working-directory }}
223223

224+
- name: Check for prerelease versions
225+
working-directory: ${{ inputs.working-directory }}
226+
run: |
227+
poetry run python $GITHUB_WORKSPACE/.github/scripts/check_prerelease_dependencies.py pyproject.toml
228+
224229
- name: Get minimum versions
225230
working-directory: ${{ inputs.working-directory }}
226231
id: min-version
227232
run: |
228233
poetry run pip install packaging
229-
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml)"
234+
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml release)"
230235
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
231236
echo "min-versions=$min_versions"
232237
@@ -285,6 +290,7 @@ jobs:
285290
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
286291
UPSTAGE_API_KEY: ${{ secrets.UPSTAGE_API_KEY }}
287292
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
293+
UNSTRUCTURED_API_KEY: ${{ secrets.UNSTRUCTURED_API_KEY }}
288294
run: make integration_tests
289295
working-directory: ${{ inputs.working-directory }}
290296

.github/workflows/_test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,22 @@ jobs:
6565
# grep will exit non-zero if the target message isn't found,
6666
# and `set -e` above will cause the step to fail.
6767
echo "$STATUS" | grep 'nothing to commit, working tree clean'
68+
69+
- name: Get minimum versions
70+
working-directory: ${{ inputs.working-directory }}
71+
id: min-version
72+
run: |
73+
poetry run pip install packaging tomli
74+
min_versions="$(poetry run python $GITHUB_WORKSPACE/.github/scripts/get_min_versions.py pyproject.toml pull_request)"
75+
echo "min-versions=$min_versions" >> "$GITHUB_OUTPUT"
76+
echo "min-versions=$min_versions"
77+
78+
# Temporarily disabled until we can get the minimum versions working
79+
# - name: Run unit tests with minimum dependency versions
80+
# if: ${{ steps.min-version.outputs.min-versions != '' }}
81+
# env:
82+
# MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
83+
# run: |
84+
# poetry run pip install --force-reinstall $MIN_VERSIONS --editable .
85+
# make tests
86+
# working-directory: ${{ inputs.working-directory }}

MIGRATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Now:
5252

5353
`from langchain_experimental.sql import SQLDatabaseChain`
5454

55-
Alternatively, if you are just interested in using the query generation part of the SQL chain, you can check out [`create_sql_query_chain`](https://github.com/langchain-ai/langchain/blob/master/docs/extras/use_cases/tabular/sql_query.ipynb)
55+
Alternatively, if you are just interested in using the query generation part of the SQL chain, you can check out this [`SQL question-answering tutorial`](https://python.langchain.com/v0.2/docs/tutorials/sql_qa/#convert-question-to-sql-query)
5656

5757
`from langchain.chains import create_sql_query_chain`
5858

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
[![PyPI - License](https://img.shields.io/pypi/l/langchain-core?style=flat-square)](https://opensource.org/licenses/MIT)
88
[![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain-core?style=flat-square)](https://pypistats.org/packages/langchain-core)
99
[![GitHub star chart](https://img.shields.io/github/stars/langchain-ai/langchain?style=flat-square)](https://star-history.com/#langchain-ai/langchain)
10-
[![Dependency Status](https://img.shields.io/librariesio/github/langchain-ai/langchain?style=flat-square)](https://libraries.io/github/langchain-ai/langchain)
1110
[![Open Issues](https://img.shields.io/github/issues-raw/langchain-ai/langchain?style=flat-square)](https://github.com/langchain-ai/langchain/issues)
1211
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode&style=flat-square)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/langchain-ai/langchain)
1312
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/langchain-ai/langchain)

cookbook/Multi_modal_RAG.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"metadata": {},
6565
"outputs": [],
6666
"source": [
67-
"! pip install -U langchain openai chromadb langchain-experimental # (newest versions required for multi-modal)"
67+
"! pip install -U langchain openai langchain-chroma langchain-experimental # (newest versions required for multi-modal)"
6868
]
6969
},
7070
{
@@ -355,7 +355,7 @@
355355
"\n",
356356
"from langchain.retrievers.multi_vector import MultiVectorRetriever\n",
357357
"from langchain.storage import InMemoryStore\n",
358-
"from langchain_community.vectorstores import Chroma\n",
358+
"from langchain_chroma import Chroma\n",
359359
"from langchain_core.documents import Document\n",
360360
"from langchain_openai import OpenAIEmbeddings\n",
361361
"\n",

cookbook/Multi_modal_RAG_google.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
40-
"%pip install -U --quiet langchain langchain_community openai chromadb langchain-experimental\n",
40+
"%pip install -U --quiet langchain langchain-chroma langchain-community openai langchain-experimental\n",
4141
"%pip install --quiet \"unstructured[all-docs]\" pypdf pillow pydantic lxml pillow matplotlib chromadb tiktoken"
4242
]
4343
},
@@ -344,8 +344,8 @@
344344
"\n",
345345
"from langchain.retrievers.multi_vector import MultiVectorRetriever\n",
346346
"from langchain.storage import InMemoryStore\n",
347+
"from langchain_chroma import Chroma\n",
347348
"from langchain_community.embeddings import VertexAIEmbeddings\n",
348-
"from langchain_community.vectorstores import Chroma\n",
349349
"from langchain_core.documents import Document\n",
350350
"\n",
351351
"\n",

0 commit comments

Comments
 (0)