mirror of
https://github.com/hwchase17/langchain
synced 2024-11-16 06:13:16 +00:00
core[patch]: support old core namespaces (#16155)
This commit is contained in:
parent
fb940d11df
commit
5c73fd5bba
@ -6,7 +6,7 @@ from typing import Any, Dict, List, Optional
|
||||
from langchain_core._api import beta
|
||||
from langchain_core.load.mapping import (
|
||||
_OG_SERIALIZABLE_MAPPING,
|
||||
OLD_PROMPT_TEMPLATE_FORMATS,
|
||||
OLD_CORE_NAMESPACES_MAPPING,
|
||||
SERIALIZABLE_MAPPING,
|
||||
)
|
||||
from langchain_core.load.serializable import Serializable
|
||||
@ -15,7 +15,7 @@ DEFAULT_NAMESPACES = ["langchain", "langchain_core", "langchain_community"]
|
||||
|
||||
ALL_SERIALIZABLE_MAPPINGS = {
|
||||
**SERIALIZABLE_MAPPING,
|
||||
**OLD_PROMPT_TEMPLATE_FORMATS,
|
||||
**OLD_CORE_NAMESPACES_MAPPING,
|
||||
**_OG_SERIALIZABLE_MAPPING,
|
||||
}
|
||||
|
||||
|
@ -513,102 +513,239 @@ _OG_SERIALIZABLE_MAPPING: Dict[Tuple[str, ...], Tuple[str, ...]] = {
|
||||
}
|
||||
|
||||
# Needed for backwards compatibility for a few versions where we serialized
|
||||
# with langchain_core
|
||||
OLD_PROMPT_TEMPLATE_FORMATS: Dict[Tuple[str, ...], Tuple[str, ...]] = {
|
||||
(
|
||||
# with langchain_core paths.
|
||||
OLD_CORE_NAMESPACES_MAPPING: Dict[Tuple[str, ...], Tuple[str, ...]] = {
|
||||
("langchain_core", "messages", "ai", "AIMessage"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"messages",
|
||||
"ai",
|
||||
"AIMessage",
|
||||
),
|
||||
("langchain_core", "messages", "ai", "AIMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"ai",
|
||||
"AIMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "base", "BaseMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"base",
|
||||
"BasePromptTemplate",
|
||||
): (
|
||||
"BaseMessage",
|
||||
),
|
||||
("langchain_core", "messages", "base", "BaseMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"base",
|
||||
"BaseMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "chat", "ChatMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"chat",
|
||||
"ChatMessage",
|
||||
),
|
||||
("langchain_core", "messages", "function", "FunctionMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"function",
|
||||
"FunctionMessage",
|
||||
),
|
||||
("langchain_core", "messages", "human", "HumanMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"human",
|
||||
"HumanMessage",
|
||||
),
|
||||
("langchain_core", "messages", "system", "SystemMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"system",
|
||||
"SystemMessage",
|
||||
),
|
||||
("langchain_core", "messages", "tool", "ToolMessage"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"tool",
|
||||
"ToolMessage",
|
||||
),
|
||||
("langchain_core", "agents", "AgentAction"): (
|
||||
"langchain_core",
|
||||
"agents",
|
||||
"AgentAction",
|
||||
),
|
||||
("langchain_core", "agents", "AgentFinish"): (
|
||||
"langchain_core",
|
||||
"agents",
|
||||
"AgentFinish",
|
||||
),
|
||||
("langchain_core", "prompts", "base", "BasePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"base",
|
||||
"BasePromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"prompt",
|
||||
"PromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "prompt", "PromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"prompt",
|
||||
"PromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"MessagesPlaceholder",
|
||||
): (
|
||||
("langchain_core", "prompts", "chat", "MessagesPlaceholder"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"MessagesPlaceholder",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"ChatPromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "chat", "ChatPromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"ChatPromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"HumanMessagePromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "chat", "HumanMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"HumanMessagePromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"SystemMessagePromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "chat", "SystemMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"SystemMessagePromptTemplate",
|
||||
),
|
||||
(
|
||||
("langchain_core", "agents", "AgentActionMessageLog"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseMessagePromptTemplate",
|
||||
): (
|
||||
"agents",
|
||||
"AgentActionMessageLog",
|
||||
),
|
||||
("langchain_core", "prompts", "chat", "BaseMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseMessagePromptTemplate",
|
||||
),
|
||||
(
|
||||
("langchain_core", "outputs", "chat_generation", "ChatGeneration"): (
|
||||
"langchain_core",
|
||||
"outputs",
|
||||
"chat_generation",
|
||||
"ChatGeneration",
|
||||
),
|
||||
("langchain_core", "outputs", "generation", "Generation"): (
|
||||
"langchain_core",
|
||||
"outputs",
|
||||
"generation",
|
||||
"Generation",
|
||||
),
|
||||
("langchain_core", "documents", "base", "Document"): (
|
||||
"langchain_core",
|
||||
"documents",
|
||||
"base",
|
||||
"Document",
|
||||
),
|
||||
("langchain_core", "prompts", "chat", "AIMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseChatPromptTemplate",
|
||||
): (
|
||||
"AIMessagePromptTemplate",
|
||||
),
|
||||
("langchain_core", "runnables", "configurable", "DynamicRunnable"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"configurable",
|
||||
"DynamicRunnable",
|
||||
),
|
||||
("langchain_core", "prompt_values", "PromptValue"): (
|
||||
"langchain_core",
|
||||
"prompt_values",
|
||||
"PromptValue",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableBinding"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableBinding",
|
||||
),
|
||||
("langchain_core", "runnables", "branch", "RunnableBranch"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"branch",
|
||||
"RunnableBranch",
|
||||
),
|
||||
("langchain_core", "runnables", "fallbacks", "RunnableWithFallbacks"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"fallbacks",
|
||||
"RunnableWithFallbacks",
|
||||
),
|
||||
("langchain_core", "output_parsers", "string", "StrOutputParser"): (
|
||||
"langchain_core",
|
||||
"output_parsers",
|
||||
"string",
|
||||
"StrOutputParser",
|
||||
),
|
||||
("langchain_core", "output_parsers", "list", "CommaSeparatedListOutputParser"): (
|
||||
"langchain_core",
|
||||
"output_parsers",
|
||||
"list",
|
||||
"CommaSeparatedListOutputParser",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableParallel"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableParallel",
|
||||
),
|
||||
("langchain_core", "outputs", "chat_generation", "ChatGenerationChunk"): (
|
||||
"langchain_core",
|
||||
"outputs",
|
||||
"chat_generation",
|
||||
"ChatGenerationChunk",
|
||||
),
|
||||
("langchain_core", "messages", "chat", "ChatMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"chat",
|
||||
"ChatMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "human", "HumanMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"human",
|
||||
"HumanMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "function", "FunctionMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"function",
|
||||
"FunctionMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "system", "SystemMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"system",
|
||||
"SystemMessageChunk",
|
||||
),
|
||||
("langchain_core", "messages", "tool", "ToolMessageChunk"): (
|
||||
"langchain_core",
|
||||
"messages",
|
||||
"tool",
|
||||
"ToolMessageChunk",
|
||||
),
|
||||
("langchain_core", "outputs", "generation", "GenerationChunk"): (
|
||||
"langchain_core",
|
||||
"outputs",
|
||||
"generation",
|
||||
"GenerationChunk",
|
||||
),
|
||||
("langchain_core", "prompts", "chat", "BaseChatPromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseChatPromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"ChatMessagePromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "chat", "ChatMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
@ -625,48 +762,108 @@ OLD_PROMPT_TEMPLATE_FORMATS: Dict[Tuple[str, ...], Tuple[str, ...]] = {
|
||||
"few_shot_with_templates",
|
||||
"FewShotPromptWithTemplates",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"pipeline",
|
||||
"PipelinePromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "pipeline", "PipelinePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"pipeline",
|
||||
"PipelinePromptTemplate",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"string",
|
||||
"StringPromptTemplate",
|
||||
): (
|
||||
("langchain_core", "prompts", "string", "StringPromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"string",
|
||||
"StringPromptTemplate",
|
||||
),
|
||||
(
|
||||
("langchain_core", "prompt_values", "StringPromptValue"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseStringMessagePromptTemplate",
|
||||
): (
|
||||
"prompt_values",
|
||||
"StringPromptValue",
|
||||
),
|
||||
("langchain_core", "prompts", "chat", "BaseStringMessagePromptTemplate"): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"BaseStringMessagePromptTemplate",
|
||||
),
|
||||
("langchain_core", "prompt_values", "ChatPromptValue"): (
|
||||
"langchain_core",
|
||||
"prompt_values",
|
||||
"ChatPromptValue",
|
||||
),
|
||||
("langchain_core", "prompt_values", "ChatPromptValueConcrete"): (
|
||||
"langchain_core",
|
||||
"prompt_values",
|
||||
"ChatPromptValueConcrete",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableBindingBase"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableBindingBase",
|
||||
),
|
||||
("langchain_core", "runnables", "router", "RouterRunnable"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"router",
|
||||
"RouterRunnable",
|
||||
),
|
||||
("langchain_core", "runnables", "passthrough", "RunnablePassthrough"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"passthrough",
|
||||
"RunnablePassthrough",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableSequence"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableSequence",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableEach"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableEach",
|
||||
),
|
||||
("langchain_core", "runnables", "base", "RunnableEachBase"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"base",
|
||||
"RunnableEachBase",
|
||||
),
|
||||
(
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"AIMessagePromptTemplate",
|
||||
"runnables",
|
||||
"configurable",
|
||||
"RunnableConfigurableAlternatives",
|
||||
): (
|
||||
"langchain_core",
|
||||
"prompts",
|
||||
"chat",
|
||||
"AIMessagePromptTemplate",
|
||||
"runnables",
|
||||
"configurable",
|
||||
"RunnableConfigurableAlternatives",
|
||||
),
|
||||
("langchain_core", "runnables", "configurable", "RunnableConfigurableFields"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"configurable",
|
||||
"RunnableConfigurableFields",
|
||||
),
|
||||
("langchain_core", "runnables", "history", "RunnableWithMessageHistory"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"history",
|
||||
"RunnableWithMessageHistory",
|
||||
),
|
||||
("langchain_core", "runnables", "passthrough", "RunnableAssign"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"passthrough",
|
||||
"RunnableAssign",
|
||||
),
|
||||
("langchain_core", "runnables", "retry", "RunnableRetry"): (
|
||||
"langchain_core",
|
||||
"runnables",
|
||||
"retry",
|
||||
"RunnableRetry",
|
||||
),
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "langchain-core"
|
||||
version = "0.1.11"
|
||||
version = "0.1.12-rc.1"
|
||||
description = "Building applications with LLMs through composability"
|
||||
authors = []
|
||||
license = "MIT"
|
||||
|
Loading…
Reference in New Issue
Block a user