Merge branch 'master' into fix/azureml-serverless-api-http400-bug

This commit is contained in:
KoKo Mexcelsa 2024-09-20 07:38:10 +08:00 committed by GitHub
commit a7ce3f293c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 73 additions and 51 deletions

View File

@ -96,22 +96,27 @@ body:
- type: textarea - type: textarea
id: system-info id: system-info
attributes: attributes:
label: System Info
description: | description: |
Please share your system info with us. Do NOT skip this step and please don't trim Please share your system info with us.
the output. Most users don't include enough information here and it makes it harder
for us to help you.
Run the following command in your terminal and paste the output here: "pip freeze | grep langchain"
platform (windows / linux / mac)
python version
OR if you're on a recent version of langchain-core you can paste the output of:
python -m langchain_core.sys_info python -m langchain_core.sys_info
or if you have an existing python interpreter running:
from langchain_core import sys_info
sys_info.print_sys_info()
alternatively, put the entire output of `pip freeze` here.
placeholder: | placeholder: |
"pip freeze | grep langchain"
platform
python version
Alternatively, if you're on a recent version of langchain-core you can paste the output of:
python -m langchain_core.sys_info python -m langchain_core.sys_info
These will only surface LangChain packages, don't forget to include any other relevant
packages you're using (if you're not sure what's relevant, you can paste the entire output of `pip freeze`).
validations: validations:
required: true required: true

View File

@ -19,6 +19,17 @@ DEFAULT_NAMESPACES = [
"langchain_anthropic", "langchain_anthropic",
"langchain_groq", "langchain_groq",
"langchain_google_genai", "langchain_google_genai",
"langchain_aws",
"langchain_openai",
"langchain_google_vertexai",
"langchain_mistralai",
"langchain_fireworks",
]
# Namespaces for which only deserializing via the SERIALIZABLE_MAPPING is allowed.
# Load by path is not allowed.
DISALLOW_LOAD_FROM_PATH = [
"langchain_community",
"langchain",
] ]
ALL_SERIALIZABLE_MAPPINGS = { ALL_SERIALIZABLE_MAPPINGS = {
@ -103,40 +114,31 @@ class Reviver:
and value.get("id", None) is not None and value.get("id", None) is not None
): ):
[*namespace, name] = value["id"] [*namespace, name] = value["id"]
mapping_key = tuple(value["id"])
if namespace[0] not in self.valid_namespaces: if namespace[0] not in self.valid_namespaces:
raise ValueError(f"Invalid namespace: {value}") raise ValueError(f"Invalid namespace: {value}")
# The root namespace ["langchain"] is not a valid identifier.
# The root namespace "langchain" is not a valid identifier. elif namespace == ["langchain"]:
if len(namespace) == 1 and namespace[0] == "langchain":
raise ValueError(f"Invalid namespace: {value}") raise ValueError(f"Invalid namespace: {value}")
# Has explicit import path.
# If namespace is in known namespaces, try to use mapping elif mapping_key in self.import_mappings:
key = tuple(namespace + [name]) import_path = self.import_mappings[mapping_key]
if namespace[0] in DEFAULT_NAMESPACES:
# Get the importable path
if key not in self.import_mappings:
raise ValueError(
"Trying to deserialize something that cannot "
"be deserialized in current version of langchain-core: "
f"{key}"
)
import_path = self.import_mappings[key]
# Split into module and name # Split into module and name
import_dir, import_obj = import_path[:-1], import_path[-1] import_dir, name = import_path[:-1], import_path[-1]
# Import module # Import module
mod = importlib.import_module(".".join(import_dir)) mod = importlib.import_module(".".join(import_dir))
# Import class elif namespace[0] in DISALLOW_LOAD_FROM_PATH:
cls = getattr(mod, import_obj) raise ValueError(
# Otherwise, load by path "Trying to deserialize something that cannot "
"be deserialized in current version of langchain-core: "
f"{mapping_key}."
)
# Otherwise, treat namespace as path.
else: else:
if key in self.additional_import_mappings: mod = importlib.import_module(".".join(namespace))
import_path = self.import_mappings[key]
mod = importlib.import_module(".".join(import_path[:-1])) cls = getattr(mod, name)
name = import_path[-1]
else:
mod = importlib.import_module(".".join(namespace))
cls = getattr(mod, name)
# The class must be a subclass of Serializable. # The class must be a subclass of Serializable.
if not issubclass(cls, Serializable): if not issubclass(cls, Serializable):

View File

@ -1026,4 +1026,24 @@ _JS_SERIALIZABLE_MAPPING: dict[tuple[str, ...], tuple[str, ...]] = {
"image", "image",
"ImagePromptTemplate", "ImagePromptTemplate",
), ),
("langchain", "chat_models", "bedrock", "ChatBedrock"): (
"langchain_aws",
"chat_models",
"ChatBedrock",
),
("langchain", "chat_models", "google_genai", "ChatGoogleGenerativeAI"): (
"langchain_google_genai",
"chat_models",
"ChatGoogleGenerativeAI",
),
("langchain", "chat_models", "groq", "ChatGroq"): (
"langchain_groq",
"chat_models",
"ChatGroq",
),
("langchain", "chat_models", "bedrock", "BedrockChat"): (
"langchain_aws",
"chat_models",
"ChatBedrock",
),
} }

View File

@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "langchain-core" name = "langchain-core"
version = "0.3.1" version = "0.3.2"
description = "Building applications with LLMs through composability" description = "Building applications with LLMs through composability"
authors = [] authors = []
license = "MIT" license = "MIT"
@ -18,6 +18,9 @@ disallow_untyped_defs = "True"
module = [ "numpy", "pytest",] module = [ "numpy", "pytest",]
ignore_missing_imports = true ignore_missing_imports = true
[tool.ruff]
target-version = "py39"
[tool.poetry.urls] [tool.poetry.urls]
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/core" "Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/core"
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-core%3D%3D0%22&expanded=true" "Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-core%3D%3D0%22&expanded=true"
@ -40,20 +43,9 @@ python = ">=3.12.4"
[tool.poetry.extras] [tool.poetry.extras]
[tool.ruff]
target-version = "py39"
[tool.ruff.lint] [tool.ruff.lint]
select = ["B", "E", "F", "I", "N", "T201", "UP"] select = [ "B", "E", "F", "I", "N", "T201", "UP",]
ignore = ["UP007"] ignore = [ "UP007",]
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"classmethod",
"langchain_core.utils.pydantic.pre_init",
"pydantic.field_validator",
"pydantic.v1.root_validator",
]
[tool.coverage.run] [tool.coverage.run]
omit = [ "tests/*",] omit = [ "tests/*",]
@ -79,6 +71,9 @@ optional = true
[tool.poetry.group.test_integration] [tool.poetry.group.test_integration]
optional = true optional = true
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",]
[tool.ruff.lint.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"tests/unit_tests/prompts/test_chat.py" = [ "E501",] "tests/unit_tests/prompts/test_chat.py" = [ "E501",]
"tests/unit_tests/runnables/test_runnable.py" = [ "E501",] "tests/unit_tests/runnables/test_runnable.py" = [ "E501",]