Tony20100/langchain_full huggingface dataset:
Class hierarchy:
BasePromptTemplate --> PipelinePromptTemplate
                       StringPromptTemplate --> PromptTemplate
                                                FewShotPromptTemplate
                                                FewShotPromptWithTemplates
                       BaseChatPromptTemplate --> AutoGPTPrompt
                                                  ChatPromptTemplate --> AgentScratchPadChatPromptTemplate
BaseMessagePromptTemplate --> MessagesPlaceholder
                              BaseStringMessagePromptTemplate --> ChatMessagePromptTemplate
                                                                  HumanMessagePromptTemplate
                                                                  AIMessagePromptTemplate
                                                                  SystemMessagePromptTemplate
Classes¶
prompts.base.BasePromptTemplate
Base class for all prompt templates, returning a prompt.
prompts.chat.AIMessagePromptTemplate
AI message prompt template.
prompts.chat.BaseChatPromptTemplate
Base class for chat prompt templates.
prompts.chat.BaseMessagePromptTemplate
Base class for message prompt templates.
prompts.chat.BaseStringMessagePromptTemplate
Base class for message prompt templates that use a string prompt template.
prompts.chat.ChatMessagePromptTemplate
Chat message prompt template.
prompts.chat.ChatPromptTemplate
Prompt template for chat models.
prompts.chat.HumanMessagePromptTemplate
Human message prompt template.
prompts.chat.MessagesPlaceholder
Prompt template that assumes variable is already list of messages.
prompts.chat.SystemMessagePromptTemplate
System message prompt template.
prompts.few_shot.FewShotChatMessagePromptTemplate
Chat prompt template that supports few-shot examples.
prompts.few_shot.FewShotPromptTemplate
Prompt template that contains few shot examples.
prompts.few_shot_with_templates.FewShotPromptWithTemplates
Prompt template that contains few shot examples.
prompts.image.ImagePromptTemplate
Image prompt template for a multimodal model.
prompts.pipeline.PipelinePromptTemplate
Prompt template for composing multiple prompt templates together.
prompts.prompt.PromptTemplate
Prompt template for a language model.
prompts.string.StringPromptTemplate
String prompt that exposes the format method, returning a prompt.
prompts.string.StringPromptTemplate
String prompt that exposes the format method, returning a prompt.
prompts.structured.StructuredPrompt
[Beta] Structured prompt template for a language model.
Functions¶
prompts.base.aformat_document(doc, prompt)
Format a document into a string based on a prompt template.
prompts.base.format_document(doc, prompt)
Format a document into a string based on a prompt template.
prompts.loading.load_prompt(path)
Unified method for loading a prompt from LangChainHub or local fs.
prompts.loading.load_prompt_from_config(config)
Load prompt from Config Dict.
prompts.string.check_valid_template(...)
Check that template string is valid.
prompts.string.get_template_variables(...)
Get the variables from the template.
prompts.string.jinja2_formatter(template, ...)
Format a template using jinja2.
prompts.string.mustache_formatter(template, ...)
Format a template using mustache.
prompts.string.mustache_schema(template)
Get the variables from a mustache template.
prompts.string.mustache_template_vars(template)
Get the variables from a mustache template.
prompts.string.validate_jinja2(template, ...)
Validate that the input variables are valid for the template.
langchain_core.retrievers¶
Retriever class returns Documents given a text query.
It is more general than a vector store. A retriever does not need to be able to
store documents, only to return (or retrieve) it. Vector stores can be used as
the backbone of a retriever, but there are other types of retrievers as well.
Class hierarchy:
BaseRetriever --> <name>Retriever  # Examples: ArxivRetriever, MergerRetriever
Main helpers:
Main helpers:
RetrieverInput, RetrieverOutput, RetrieverLike, RetrieverOutputLike,
Document, Serializable, Callbacks,
CallbackManagerForRetrieverRun, AsyncCallbackManagerForRetrieverRun
Classes¶
retrievers.BaseRetriever
Abstract base class for a Document retrieval system.
langchain_core.runnables¶
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.
Batch operations allow for processing multiple inputs in parallel.
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.
Classes¶
runnables.base.Runnable()
A unit of work that can be invoked, batched, streamed, transformed and composed.
runnables.base.RunnableBinding
Wrap a Runnable with additional functionality.
runnables.base.RunnableBindingBase
Runnable that delegates calls to another Runnable with a set of kwargs.
runnables.base.RunnableEach
Runnable that delegates calls to another Runnable with each element of the input sequence.
runnables.base.RunnableEachBase
Runnable that delegates calls to another Runnable with each element of the input sequence.
runnables.base.RunnableGenerator(transform)
Runnable that runs a generator function.
runnables.base.RunnableLambda(func[, afunc, ...])
RunnableLambda converts a python callable into a Runnable.
runnables.base.RunnableMap
alias of RunnableParallel
runnables.base.RunnableMap
alias of RunnableParallel
runnables.base.RunnableParallel
Runnable that runs a mapping of Runnables in parallel, and returns a mapping of their outputs.
runnables.base.RunnableSequence
Sequence of Runnables, where the output of each is the input of the next.
runnables.base.RunnableSerializable
Runnable that can be serialized to JSON.
runnables.branch.RunnableBranch
Runnable that selects which branch to run based on a condition.
runnables.config.ContextThreadPoolExecutor([...])
ThreadPoolExecutor that copies the context to the child thread.
runnables.config.EmptyDict
Empty dict type.
runnables.config.RunnableConfig
Configuration for a Runnable.
runnables.configurable.DynamicRunnable
Serializable Runnable that can be dynamically configured.
runnables.configurable.RunnableConfigurableAlternatives
Runnable that can be dynamically configured.
runnables.configurable.RunnableConfigurableFields
Runnable that can be dynamically configured.
runnables.configurable.StrEnum(value)
String enum.
runnables.fallbacks.RunnableWithFallbacks
Runnable that can fallback to other Runnables if it fails.
runnables.graph.Branch(condition, ends)
Branch in a graph.
runnables.graph.CurveStyle(value)
Enum for different curve styles supported by Mermaid
runnables.graph.Edge(source, target[, data, ...])
Edge in a graph.
runnables.graph.Graph(nodes, ...)
Graph of nodes and edges.
runnables.graph.LabelsDict
Dictionary of labels for nodes and edges in a graph.
runnables.graph.MermaidDrawMethod(value)
Enum for different draw methods supported by Mermaid
runnables.graph.Node(id, data)
Node in a graph.
runnables.graph.Node(id, data)
Node in a graph.
runnables.graph.NodeColors([start, end, other])
Schema for Hexadecimal color codes for different node types
runnables.graph_ascii.AsciiCanvas(cols, lines)
Class for drawing in ASCII.
runnables.graph_ascii.VertexViewer(name)
Class to define vertex box boundaries that will be accounted for during graph building by grandalf.
runnables.graph_png.PngDrawer([fontname, labels])
Helper class to draw a state graph into a PNG file.
runnables.history.RunnableWithMessageHistory
Runnable that manages chat message history for another Runnable.
runnables.passthrough.RunnableAssign
Runnable that assigns key-value pairs to Dict[str, Any] inputs.
runnables.passthrough.RunnablePassthrough
Runnable to passthrough inputs unchanged or with additional keys.
runnables.passthrough.RunnablePick
Runnable that picks keys from Dict[str, Any] inputs.
runnables.retry.RunnableRetry
Retry a Runnable if it fails.
runnables.router.RouterInput
Router input.
runnables.router.RouterRunnable
Runnable that routes to a set of Runnables based on Input['key'].
runnables.schema.EventData
Data associated with a streaming event.
runnables.schema.StreamEvent
Streaming event.
runnables.utils.AddableDict
Dictionary that can be added to another dictionary.
runnables.utils.ConfigurableField(id[, ...])
Field that can be configured by the user.
runnables.utils.ConfigurableFieldMultiOption(id, ...)
Field that can be configured by the user with multiple default values.
runnables.utils.ConfigurableFieldSingleOption(id, ...)
Field that can be configured by the user with a default value.
Field that can be configured by the user with a default value.
runnables.utils.ConfigurableFieldSpec(id, ...)
Field that can be configured by the user.
runnables.utils.FunctionNonLocals()
Get the nonlocal variables accessed of a function.
runnables.utils.GetLambdaSource()
Get the source code of a lambda function.
runnables.utils.IsFunctionArgDict()
Check if the first argument of a function is a dict.
runnables.utils.IsLocalDict(name, keys)
Check if a name is a local dict.
runnables.utils.NonLocals()
Get nonlocal variables accessed.
runnables.utils.SupportsAdd(*args, **kwargs)
Protocol for objects that support addition.
Functions¶
runnables.base.chain()
Decorate a function to make it a Runnable.
runnables.base.coerce_to_runnable(thing)
Coerce a runnable-like object into a Runnable.
runnables.config.acall_func_with_variable_args(...)
Call function that may optionally accept a run_manager and/or config.
runnables.config.call_func_with_variable_args(...)
Call function that may optionally accept a run_manager and/or config.
runnables.config.ensure_config([config])
Ensure that a config is a dict with all keys present.
runnables.config.get_async_callback_manager_for_config(config)
Get an async callback manager for a config.
runnables.config.get_callback_manager_for_config(config)
Get a callback manager for a config.
runnables.config.get_config_list(config, length)
Get a list of configs from a single config or a list of configs.
runnables.config.get_executor_for_config(config)
Get an executor for a config.
runnables.config.merge_configs(*configs)
Merge multiple configs into one.
runnables.config.merge_configs(*configs)
Merge multiple configs into one.
runnables.config.patch_config(config, *[, ...])
Patch a config with new values.
runnables.config.run_in_executor(...)
Run a function in an executor.
runnables.configurable.make_options_spec(...)
Make a ConfigurableFieldSpec for a ConfigurableFieldSingleOption or ConfigurableFieldMultiOption.
runnables.configurable.prefix_config_spec(...)
Prefix the id of a ConfigurableFieldSpec.
runnables.graph.is_uuid(value)
Check if a string is a valid UUID.
runnables.graph.node_data_json(node, *[, ...])
Convert the data of a node to a JSON-serializable format.
runnables.graph.node_data_str(node)
Convert the data of a node to a string.
runnables.graph_ascii.draw_ascii(vertices, edges)
Build a DAG and draw it in ASCII.
runnables.graph_mermaid.draw_mermaid(nodes, ...)
Draws a Mermaid graph using the provided graph data
runnables.graph_mermaid.draw_mermaid_png(...)
Draws a Mermaid graph as PNG using provided syntax.
runnables.passthrough.aidentity(x)
Async identity function
runnables.passthrough.identity(x)
Identity function
runnables.utils.aadd(addables)
Asynchronously add a sequence of addable objects together.
runnables.utils.accepts_config(callable)
Check if a callable accepts a config argument.
runnables.utils.accepts_context(callable)
Check if a callable accepts a context argument.
runnables.utils.accepts_run_manager(callable)
Check if a callable accepts a run_manager argument.
runnables.utils.add(addables)
Add a sequence of addable objects together.
runnables.utils.add(addables)
Add a sequence of addable objects together.
runnables.utils.create_model(__model_name, ...)
Create a pydantic model with the given field definitions.
runnables.utils.gated_coro(semaphore, coro)
Run a coroutine with a semaphore.
runnables.utils.gather_with_concurrency(n, ...)
Gather coroutines with a limit on the number of concurrent coroutines.
runnables.utils.get_function_first_arg_dict_keys(func)
Get the keys of the first argument of a function if it is a dict.
runnables.utils.get_function_nonlocals(func)
Get the nonlocal variables accessed by a function.
runnables.utils.get_lambda_source(func)
Get the source code of a lambda function.
runnables.utils.get_unique_config_specs(specs)
Get the unique config specs from a sequence of config specs.
runnables.utils.indent_lines_after_first(...)
Indent all lines of text after the first line.
runnables.utils.is_async_callable(func)
Check if a function is async.
runnables.utils.is_async_generator(func)
Check if a function is an async generator.
langchain_core.stores¶
Store implements the key-value stores and storage helpers.
Module provides implementations of various key-value stores that conform
to a simple key-value interface.
The primary goal of these storages is to support implementation of caching.
Classes¶
stores.BaseStore()
Abstract interface for a key-value store.
stores.InMemoryBaseStore()
In-memory implementation of the BaseStore using a dictionary.
stores.InMemoryByteStore()
In-memory store for bytes.
stores.InMemoryStore()
In-memory store for any type of data.
stores.InvalidKeyException
Raised when a key is invalid; e.g., uses incorrect characters.
stores.InvalidKeyException
Raised when a key is invalid; e.g., uses incorrect characters.
langchain_core.structured_query¶
Internal representation of a structured query language.
Classes¶
structured_query.Comparator(value)
Enumerator of the comparison operators.
structured_query.Comparison
Comparison to a value.
structured_query.Expr
Base class for all expressions.
structured_query.FilterDirective
Filtering expression.
structured_query.Operation
Llogical operation over other directives.
structured_query.Operator(value)
Enumerator of the operations.
structured_query.StructuredQuery
Structured query.
structured_query.Visitor()
Defines interface for IR translation using visitor pattern.
langchain_core.sys_info¶
sys_info prints information about the system and langchain packages
for debugging purposes.
Functions¶
sys_info.print_sys_info(*[, additional_pkgs])
Print information about the environment for debugging purposes.
langchain_core.tools¶
Tools are classes that an Agent uses to interact with the world.
Each tool has a description. Agent uses the description to choose the right
tool for the job.
Class hierarchy:
RunnableSerializable --> BaseTool --> <name>Tool  # Examples: AIPluginTool, BaseGraphQLTool
                                      <name>      # Examples: BraveSearch, HumanInputRun
Main helpers:
CallbackManagerForToolRun, AsyncCallbackManagerForToolRun
Classes¶
tools.BaseTool
Interface LangChain tools must implement.
tools.BaseToolkit
Base Toolkit representing a collection of related tools.
tools.RetrieverInput
Input to the retriever.
tools.SchemaAnnotationError
Raised when 'args_schema' is missing or has an incorrect type annotation.
tools.StructuredTool
Tool that can operate on any number of inputs.
tools.Tool
Tool that takes in function or coroutine directly.
tools.ToolException
Optional exception that tool throws when execution error occurs.
Functions¶
tools.ToolException
Optional exception that tool throws when execution error occurs.
Functions¶
tools.create_retriever_tool(retriever, name, ...)
Create a tool to do retrieval of documents.
tools.create_schema_from_function(...)
Create a pydantic schema from a function's signature.
tools.render_text_description(tools)
Render the tool name and description in plain text.
tools.render_text_description_and_args(tools)
Render the tool name, description, and args in plain text.
tools.tool(*args[, return_direct, ...])
Make tools out of functions, can be used with or without arguments.
langchain_core.tracers¶
Tracers are classes for tracing runs.
Class hierarchy:
BaseCallbackHandler --> BaseTracer --> <name>Tracer  # Examples: LangChainTracer, RootListenersTracer
                                   --> <name>  # Examples: LogStreamCallbackHandler
Classes¶
tracers.base.AsyncBaseTracer(*[, _schema_format])
Async Base interface for tracers.
tracers.base.BaseTracer(*[, _schema_format])
Base interface for tracers.
tracers.evaluation.EvaluatorCallbackHandler(...)
Tracer that runs a run evaluator whenever a run is persisted.
tracers.event_stream.RunInfo
Information about a run.
tracers.langchain.LangChainTracer([...])
Implementation of the SharedTracer that POSTS to the LangChain endpoint.
tracers.log_stream.LogEntry
A single entry in the run log.
tracers.log_stream.LogStreamCallbackHandler(*)
Tracer that streams run logs to a stream.
tracers.log_stream.RunLog(*ops, state)
Run log.
tracers.log_stream.RunLogPatch(*ops)
Patch to the run log.
tracers.log_stream.RunState
State of the run.
Patch to the run log.
tracers.log_stream.RunState
State of the run.
tracers.root_listeners.AsyncRootListenersTracer(*, ...)
Async Tracer that calls listeners on run start, end, and error.
tracers.root_listeners.RootListenersTracer(*, ...)
Tracer that calls listeners on run start, end, and error.
tracers.run_collector.RunCollectorCallbackHandler([...])
Tracer that collects all nested runs in a list.
tracers.schemas.BaseRun
[Deprecated] Base class for Run.
tracers.schemas.ChainRun
[Deprecated] Class for ChainRun.
tracers.schemas.LLMRun
[Deprecated] Class for LLMRun.
tracers.schemas.Run
Run schema for the V2 API in the Tracer.
tracers.schemas.ToolRun
[Deprecated] Class for ToolRun.
tracers.schemas.TracerSession
[Deprecated] TracerSessionV1 schema for the V2 API.
tracers.schemas.TracerSessionBase
[Deprecated] Base class for TracerSession.
tracers.schemas.TracerSessionV1
[Deprecated] TracerSessionV1 schema.
tracers.schemas.TracerSessionV1Base
[Deprecated] Base class for TracerSessionV1.
tracers.schemas.TracerSessionV1Create
[Deprecated] Create class for TracerSessionV1.
tracers.stdout.ConsoleCallbackHandler(**kwargs)
Tracer that prints to the console.
tracers.stdout.FunctionCallbackHandler(...)
Tracer that calls a function with a single str parameter.
Functions¶
tracers.context.collect_runs()
Collect all run traces in context.
tracers.context.register_configure_hook(...)
Register a configure hook.
tracers.context.tracing_enabled([session_name])
Throw an error because this has been replaced by tracing_v2_enabled.
Throw an error because this has been replaced by tracing_v2_enabled.
tracers.context.tracing_v2_enabled([...])
Instruct LangChain to log all runs in context to LangSmith.
tracers.evaluation.wait_for_all_evaluators()
Wait for all tracers to finish.
tracers.langchain.get_client()
Get the client.
tracers.langchain.log_error_once(method, ...)
Log an error once.
tracers.langchain.wait_for_all_tracers()
Wait for all tracers to finish.
tracers.langchain_v1.LangChainTracerV1(...)
Throw an error because this has been replaced by LangChainTracer.
tracers.langchain_v1.get_headers(*args, **kwargs)
Throw an error because this has been replaced by get_headers.
tracers.schemas.RunTypeEnum()
[Deprecated] RunTypeEnum.
tracers.stdout.elapsed(run)
Get the elapsed time of a run.
tracers.stdout.try_json_stringify(obj, fallback)
Try to stringify an object to JSON.
langchain_core.utils¶
Utility functions for LangChain.
These functions do not depend on any other LangChain module.
Classes¶
utils.aiter.NoLock()
Dummy lock that provides the proper interface but no protection
utils.aiter.Tee(iterable[, n, lock])
Create n separate asynchronous iterators over iterable.
utils.aiter.atee
alias of Tee
utils.formatting.StrictFormatter()
Formatter that checks for extra keys.
utils.function_calling.FunctionDescription
Representation of a callable function to send to an LLM.
utils.function_calling.ToolDescription
Representation of a callable function to the OpenAI API.
utils.iter.NoLock()
Dummy lock that provides the proper interface but no protection
utils.iter.Tee(iterable[, n, lock])
utils.iter.Tee(iterable[, n, lock])
Create n separate asynchronous iterators over iterable
utils.iter.safetee
alias of Tee
utils.mustache.ChevronError
Custom exception for Chevron errors.
Functions¶
utils.aiter.py_anext(iterator[, default])
Pure-Python implementation of anext() for testing purposes.
utils.aiter.tee_peer(iterator, buffer, ...)
An individual iterator of a tee()
utils.env.env_var_is_set(env_var)
Check if an environment variable is set.
utils.env.get_from_dict_or_env(data, key, ...)
Get a value from a dictionary or an environment variable.
utils.env.get_from_env(key, env_key[, default])
Get a value from a dictionary or an environment variable.
utils.function_calling.convert_pydantic_to_openai_function(...)
[Deprecated] Converts a Pydantic model to a function description for the OpenAI API.
utils.function_calling.convert_pydantic_to_openai_tool(...)
[Deprecated] Converts a Pydantic model to a function description for the OpenAI API.
utils.function_calling.convert_python_function_to_openai_function(...)
[Deprecated] Convert a Python function to an OpenAI function-calling API compatible dict.
utils.function_calling.convert_to_openai_function(...)
Convert a raw function/class to an OpenAI function.
utils.function_calling.convert_to_openai_tool(tool)
Convert a raw function/class to an OpenAI tool.
utils.function_calling.format_tool_to_openai_function(tool)
[Deprecated] Format tool into the OpenAI function API.
utils.function_calling.format_tool_to_openai_tool(tool)
[Deprecated] Format tool into the OpenAI function API.
utils.function_calling.tool_example_to_messages(...)
Convert an example into a list of messages that can be fed into an LLM.
Convert an example into a list of messages that can be fed into an LLM.
utils.html.extract_sub_links(raw_html, url, *)
Extract all links from a raw html string and convert into absolute paths.
utils.html.find_all_links(raw_html, *[, pattern])
Extract all links from a raw html string.
utils.image.encode_image(image_path)
Get base64 string from image URI.
utils.image.image_to_data_url(image_path)
utils.input.get_bolded_text(text)
Get bolded text.
utils.input.get_color_mapping(items[, ...])
Get mapping for items to a support color.
utils.input.get_colored_text(text, color)
Get colored text.
utils.input.print_text(text[, color, end, file])
Print text with highlighting and no end characters.
utils.interactive_env.is_interactive_env()
Determine if running within IPython or Jupyter.
utils.iter.batch_iterate(size, iterable)
Utility batching function.
utils.iter.tee_peer(iterator, buffer, peers, ...)
An individual iterator of a tee()
utils.json.parse_and_check_json_markdown(...)
Parse a JSON string from a Markdown string and check that it contains the expected keys.
utils.json.parse_json_markdown(json_string, *)
Parse a JSON string from a Markdown string.
utils.json.parse_partial_json(s, *[, strict])
Parse a JSON string that may be missing closing braces.
utils.json_schema.dereference_refs(schema_obj, *)
Try to substitute $refs in JSON Schema.
utils.loading.try_load_from_hub(*args, **kwargs)
[Deprecated]
utils.mustache.grab_literal(template, l_del)
Parse a literal from the template.
utils.mustache.l_sa_check(template, literal, ...)