initial commit

This commit is contained in:
2026-05-11 12:36:20 +05:30
commit 384cbe8019
15377 changed files with 2360544 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
"""**Schemas** are the LangChain Base Classes and Interfaces."""
from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.caches import BaseCache
from langchain_core.chat_history import BaseChatMessageHistory
from langchain_core.documents import BaseDocumentTransformer, Document
from langchain_core.exceptions import LangChainException, OutputParserException
from langchain_core.messages import (
AIMessage,
BaseMessage,
ChatMessage,
FunctionMessage,
HumanMessage,
SystemMessage,
_message_from_dict,
get_buffer_string,
messages_from_dict,
messages_to_dict,
)
from langchain_core.messages.base import message_to_dict
from langchain_core.output_parsers import (
BaseLLMOutputParser,
BaseOutputParser,
StrOutputParser,
)
from langchain_core.outputs import (
ChatGeneration,
ChatResult,
Generation,
LLMResult,
RunInfo,
)
from langchain_core.prompt_values import PromptValue
from langchain_core.prompts import BasePromptTemplate, format_document
from langchain_core.retrievers import BaseRetriever
from langchain_core.stores import BaseStore
from langchain_classic.base_memory import BaseMemory
RUN_KEY = "__run"
# Backwards compatibility.
Memory = BaseMemory
_message_to_dict = message_to_dict
__all__ = [
"RUN_KEY",
"AIMessage",
"AgentAction",
"AgentFinish",
"BaseCache",
"BaseChatMessageHistory",
"BaseDocumentTransformer",
"BaseLLMOutputParser",
"BaseMemory",
"BaseMessage",
"BaseOutputParser",
"BasePromptTemplate",
"BaseRetriever",
"BaseStore",
"ChatGeneration",
"ChatMessage",
"ChatResult",
"Document",
"FunctionMessage",
"Generation",
"HumanMessage",
"LLMResult",
"LangChainException",
"Memory",
"OutputParserException",
"PromptValue",
"RunInfo",
"StrOutputParser",
"SystemMessage",
"_message_from_dict",
"_message_to_dict",
"format_document",
"get_buffer_string",
"message_to_dict",
"messages_from_dict",
"messages_to_dict",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.agents import AgentAction, AgentActionMessageLog, AgentFinish
__all__ = ["AgentAction", "AgentActionMessageLog", "AgentFinish"]

View File

@@ -0,0 +1,3 @@
from langchain_core.caches import RETURN_VAL_TYPE, BaseCache
__all__ = ["RETURN_VAL_TYPE", "BaseCache"]

View File

@@ -0,0 +1,23 @@
from langchain_core.callbacks.base import (
AsyncCallbackHandler,
BaseCallbackHandler,
BaseCallbackManager,
CallbackManagerMixin,
ChainManagerMixin,
LLMManagerMixin,
RetrieverManagerMixin,
RunManagerMixin,
ToolManagerMixin,
)
__all__ = [
"AsyncCallbackHandler",
"BaseCallbackHandler",
"BaseCallbackManager",
"CallbackManagerMixin",
"ChainManagerMixin",
"LLMManagerMixin",
"RetrieverManagerMixin",
"RunManagerMixin",
"ToolManagerMixin",
]

View File

@@ -0,0 +1,53 @@
from langchain_core.callbacks.manager import (
AsyncCallbackManager,
AsyncCallbackManagerForChainGroup,
AsyncCallbackManagerForChainRun,
AsyncCallbackManagerForLLMRun,
AsyncCallbackManagerForRetrieverRun,
AsyncCallbackManagerForToolRun,
AsyncParentRunManager,
AsyncRunManager,
BaseRunManager,
CallbackManager,
CallbackManagerForChainGroup,
CallbackManagerForChainRun,
CallbackManagerForLLMRun,
CallbackManagerForRetrieverRun,
CallbackManagerForToolRun,
ParentRunManager,
RunManager,
handle_event,
trace_as_chain_group,
)
from langchain_core.tracers.context import (
collect_runs,
register_configure_hook,
tracing_v2_enabled,
)
from langchain_core.utils.env import env_var_is_set
__all__ = [
"AsyncCallbackManager",
"AsyncCallbackManagerForChainGroup",
"AsyncCallbackManagerForChainRun",
"AsyncCallbackManagerForLLMRun",
"AsyncCallbackManagerForRetrieverRun",
"AsyncCallbackManagerForToolRun",
"AsyncParentRunManager",
"AsyncRunManager",
"BaseRunManager",
"CallbackManager",
"CallbackManagerForChainGroup",
"CallbackManagerForChainRun",
"CallbackManagerForLLMRun",
"CallbackManagerForRetrieverRun",
"CallbackManagerForToolRun",
"ParentRunManager",
"RunManager",
"collect_runs",
"env_var_is_set",
"handle_event",
"register_configure_hook",
"trace_as_chain_group",
"tracing_v2_enabled",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.callbacks.stdout import StdOutCallbackHandler
__all__ = ["StdOutCallbackHandler"]

View File

@@ -0,0 +1,3 @@
from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
__all__ = ["StreamingStdOutCallbackHandler"]

View File

@@ -0,0 +1,4 @@
from langchain_core.exceptions import TracerException
from langchain_core.tracers.base import BaseTracer
__all__ = ["BaseTracer", "TracerException"]

View File

@@ -0,0 +1,6 @@
from langchain_core.tracers.evaluation import (
EvaluatorCallbackHandler,
wait_for_all_evaluators,
)
__all__ = ["EvaluatorCallbackHandler", "wait_for_all_evaluators"]

View File

@@ -0,0 +1,8 @@
from langchain_core.tracers.langchain import (
LangChainTracer,
get_client,
log_error_once,
wait_for_all_tracers,
)
__all__ = ["LangChainTracer", "get_client", "log_error_once", "wait_for_all_tracers"]

View File

@@ -0,0 +1,9 @@
from langchain_core.tracers.log_stream import (
LogEntry,
LogStreamCallbackHandler,
RunLog,
RunLogPatch,
RunState,
)
__all__ = ["LogEntry", "LogStreamCallbackHandler", "RunLog", "RunLogPatch", "RunState"]

View File

@@ -0,0 +1,3 @@
from langchain_core.tracers.root_listeners import RootListenersTracer
__all__ = ["RootListenersTracer"]

View File

@@ -0,0 +1,3 @@
from langchain_core.tracers.run_collector import RunCollectorCallbackHandler
__all__ = ["RunCollectorCallbackHandler"]

View File

@@ -0,0 +1,5 @@
from langchain_core.tracers.schemas import Run
__all__ = [
"Run",
]

View File

@@ -0,0 +1,13 @@
from langchain_core.tracers.stdout import (
ConsoleCallbackHandler,
FunctionCallbackHandler,
elapsed,
try_json_stringify,
)
__all__ = [
"ConsoleCallbackHandler",
"FunctionCallbackHandler",
"elapsed",
"try_json_stringify",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.chat_sessions import ChatSession
__all__ = ["ChatSession"]

View File

@@ -0,0 +1,3 @@
from langchain_core.chat_history import BaseChatMessageHistory
__all__ = ["BaseChatMessageHistory"]

View File

@@ -0,0 +1,3 @@
from langchain_core.documents import BaseDocumentTransformer, Document
__all__ = ["BaseDocumentTransformer", "Document"]

View File

@@ -0,0 +1,3 @@
from langchain_core.embeddings import Embeddings
__all__ = ["Embeddings"]

View File

@@ -0,0 +1,3 @@
from langchain_core.exceptions import LangChainException
__all__ = ["LangChainException"]

View File

@@ -0,0 +1,15 @@
from langchain_core.language_models import (
BaseLanguageModel,
LanguageModelInput,
LanguageModelOutput,
get_tokenizer,
)
from langchain_core.language_models.base import _get_token_ids_default_method
__all__ = [
"BaseLanguageModel",
"LanguageModelInput",
"LanguageModelOutput",
"_get_token_ids_default_method",
"get_tokenizer",
]

View File

@@ -0,0 +1,3 @@
from langchain_classic.base_memory import BaseMemory
__all__ = ["BaseMemory"]

View File

@@ -0,0 +1,51 @@
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
AnyMessage,
BaseMessage,
BaseMessageChunk,
ChatMessage,
ChatMessageChunk,
FunctionMessage,
FunctionMessageChunk,
HumanMessage,
HumanMessageChunk,
SystemMessage,
SystemMessageChunk,
ToolMessage,
ToolMessageChunk,
_message_from_dict,
get_buffer_string,
merge_content,
message_to_dict,
messages_from_dict,
messages_to_dict,
)
# Backwards compatibility.
_message_to_dict = message_to_dict
__all__ = [
"AIMessage",
"AIMessageChunk",
"AnyMessage",
"BaseMessage",
"BaseMessageChunk",
"ChatMessage",
"ChatMessageChunk",
"FunctionMessage",
"FunctionMessageChunk",
"HumanMessage",
"HumanMessageChunk",
"SystemMessage",
"SystemMessageChunk",
"ToolMessage",
"ToolMessageChunk",
"_message_from_dict",
"_message_to_dict",
"get_buffer_string",
"merge_content",
"message_to_dict",
"messages_from_dict",
"messages_to_dict",
]

View File

@@ -0,0 +1,19 @@
from langchain_core.outputs import (
ChatGeneration,
ChatGenerationChunk,
ChatResult,
Generation,
GenerationChunk,
LLMResult,
RunInfo,
)
__all__ = [
"ChatGeneration",
"ChatGenerationChunk",
"ChatResult",
"Generation",
"GenerationChunk",
"LLMResult",
"RunInfo",
]

View File

@@ -0,0 +1,25 @@
from langchain_core.exceptions import OutputParserException
from langchain_core.output_parsers import (
BaseCumulativeTransformOutputParser,
BaseGenerationOutputParser,
BaseLLMOutputParser,
BaseOutputParser,
BaseTransformOutputParser,
StrOutputParser,
)
from langchain_core.output_parsers.base import T
# Backwards compatibility.
NoOpOutputParser = StrOutputParser
__all__ = [
"BaseCumulativeTransformOutputParser",
"BaseGenerationOutputParser",
"BaseLLMOutputParser",
"BaseOutputParser",
"BaseTransformOutputParser",
"NoOpOutputParser",
"OutputParserException",
"StrOutputParser",
"T",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.prompt_values import PromptValue
__all__ = ["PromptValue"]

View File

@@ -0,0 +1,3 @@
from langchain_core.prompts import BasePromptTemplate, format_document
__all__ = ["BasePromptTemplate", "format_document"]

View File

@@ -0,0 +1,3 @@
from langchain_core.retrievers import BaseRetriever
__all__ = ["BaseRetriever"]

View File

@@ -0,0 +1,58 @@
"""LangChain **Runnable** and the **LangChain Expression Language (LCEL)**.
The LangChain Expression Language (LCEL) offers a declarative method to build
production-grade programs that harness the power of LLMs.
Programs created using LCEL and LangChain Runnables inherently support
synchronous, asynchronous, batch, and streaming operations.
Support for **async** allows servers hosting LCEL based programs to scale better
for higher concurrent loads.
**Streaming** of intermediate outputs as they're being generated allows for
creating more responsive UX.
This module contains schema and implementation of LangChain Runnables primitives.
"""
from langchain_core.runnables.base import (
Runnable,
RunnableBinding,
RunnableGenerator,
RunnableLambda,
RunnableMap,
RunnableParallel,
RunnableSequence,
RunnableSerializable,
)
from langchain_core.runnables.branch import RunnableBranch
from langchain_core.runnables.config import RunnableConfig, patch_config
from langchain_core.runnables.fallbacks import RunnableWithFallbacks
from langchain_core.runnables.passthrough import RunnablePassthrough
from langchain_core.runnables.router import RouterInput, RouterRunnable
from langchain_core.runnables.utils import (
ConfigurableField,
ConfigurableFieldMultiOption,
ConfigurableFieldSingleOption,
)
__all__ = [
"ConfigurableField",
"ConfigurableFieldMultiOption",
"ConfigurableFieldSingleOption",
"RouterInput",
"RouterRunnable",
"Runnable",
"RunnableBinding",
"RunnableBranch",
"RunnableConfig",
"RunnableGenerator",
"RunnableLambda",
"RunnableMap",
"RunnableParallel",
"RunnablePassthrough",
"RunnableSequence",
"RunnableSerializable",
"RunnableWithFallbacks",
"patch_config",
]

View File

@@ -0,0 +1,38 @@
from langchain_core.runnables.base import (
Other,
Runnable,
RunnableBinding,
RunnableBindingBase,
RunnableEach,
RunnableEachBase,
RunnableGenerator,
RunnableLambda,
RunnableLike,
RunnableParallel,
RunnableSequence,
RunnableSerializable,
coerce_to_runnable,
)
from langchain_core.runnables.utils import Input, Output
# Backwards compatibility.
RunnableMap = RunnableParallel
__all__ = [
"Input",
"Other",
"Output",
"Runnable",
"RunnableBinding",
"RunnableBindingBase",
"RunnableEach",
"RunnableEachBase",
"RunnableGenerator",
"RunnableLambda",
"RunnableLike",
"RunnableMap",
"RunnableParallel",
"RunnableSequence",
"RunnableSerializable",
"coerce_to_runnable",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.runnables.branch import RunnableBranch
__all__ = ["RunnableBranch"]

View File

@@ -0,0 +1,27 @@
from langchain_core.runnables.config import (
EmptyDict,
RunnableConfig,
acall_func_with_variable_args,
call_func_with_variable_args,
ensure_config,
get_async_callback_manager_for_config,
get_callback_manager_for_config,
get_config_list,
get_executor_for_config,
merge_configs,
patch_config,
)
__all__ = [
"EmptyDict",
"RunnableConfig",
"acall_func_with_variable_args",
"call_func_with_variable_args",
"ensure_config",
"get_async_callback_manager_for_config",
"get_callback_manager_for_config",
"get_config_list",
"get_executor_for_config",
"merge_configs",
"patch_config",
]

View File

@@ -0,0 +1,15 @@
from langchain_core.runnables.configurable import (
DynamicRunnable,
RunnableConfigurableAlternatives,
RunnableConfigurableFields,
StrEnum,
make_options_spec,
)
__all__ = [
"DynamicRunnable",
"RunnableConfigurableAlternatives",
"RunnableConfigurableFields",
"StrEnum",
"make_options_spec",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.runnables.fallbacks import RunnableWithFallbacks
__all__ = ["RunnableWithFallbacks"]

View File

@@ -0,0 +1,11 @@
from langchain_core.runnables.history import (
GetSessionHistoryCallable,
MessagesOrDictWithMessages,
RunnableWithMessageHistory,
)
__all__ = [
"GetSessionHistoryCallable",
"MessagesOrDictWithMessages",
"RunnableWithMessageHistory",
]

View File

@@ -0,0 +1,8 @@
from langchain_core.runnables.passthrough import (
RunnableAssign,
RunnablePassthrough,
aidentity,
identity,
)
__all__ = ["RunnableAssign", "RunnablePassthrough", "aidentity", "identity"]

View File

@@ -0,0 +1,3 @@
from langchain_core.runnables.retry import RunnableRetry, U
__all__ = ["RunnableRetry", "U"]

View File

@@ -0,0 +1,3 @@
from langchain_core.runnables.router import RouterInput, RouterRunnable
__all__ = ["RouterInput", "RouterRunnable"]

View File

@@ -0,0 +1,51 @@
from langchain_core.runnables.utils import (
Addable,
AddableDict,
AnyConfigurableField,
ConfigurableField,
ConfigurableFieldMultiOption,
ConfigurableFieldSingleOption,
ConfigurableFieldSpec,
GetLambdaSource,
Input,
IsFunctionArgDict,
IsLocalDict,
Output,
SupportsAdd,
aadd,
accepts_config,
accepts_run_manager,
add,
gated_coro,
gather_with_concurrency,
get_function_first_arg_dict_keys,
get_lambda_source,
get_unique_config_specs,
indent_lines_after_first,
)
__all__ = [
"Addable",
"AddableDict",
"AnyConfigurableField",
"ConfigurableField",
"ConfigurableFieldMultiOption",
"ConfigurableFieldSingleOption",
"ConfigurableFieldSpec",
"GetLambdaSource",
"Input",
"IsFunctionArgDict",
"IsLocalDict",
"Output",
"SupportsAdd",
"aadd",
"accepts_config",
"accepts_run_manager",
"add",
"gated_coro",
"gather_with_concurrency",
"get_function_first_arg_dict_keys",
"get_lambda_source",
"get_unique_config_specs",
"indent_lines_after_first",
]

View File

@@ -0,0 +1,3 @@
from langchain_core.stores import BaseStore, K, V
__all__ = ["BaseStore", "K", "V"]

View File

@@ -0,0 +1,3 @@
from langchain_core.vectorstores import VST, VectorStore, VectorStoreRetriever
__all__ = ["VST", "VectorStore", "VectorStoreRetriever"]