Tony20100/langchain_full huggingface dataset:
Get the namespace of the langchain object.
For example, if the class is langchain.llms.openai.OpenAI, then the
namespace is [“langchain”, “llms”, “openai”]
Return type
List[str]
get_name(suffix: Optional[str] = None, *, name: Optional[str] = None) → str¶
Get the name of the runnable.
Parameters
suffix (Optional[str]) – 
name (Optional[str]) – 
Return type
str
get_output_schema(config: Optional[RunnableConfig] = None) → Type[BaseModel]¶
Get a pydantic model that can be used to validate output to the runnable.
Runnables that leverage the configurable_fields and configurable_alternatives
methods will have a dynamic output schema that depends on which
configuration the runnable is invoked with.
This method allows to get an output schema for a specific configuration.
Parameters
config (Optional[RunnableConfig]) – A config to use when generating the schema.
Returns
A pydantic model that can be used to validate output.
Return type
Type[BaseModel]
get_prompts(config: Optional[RunnableConfig] = None) → List[BasePromptTemplate]¶
Parameters
config (Optional[RunnableConfig]) – 
Return type
List[BasePromptTemplate]
invoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶
Transform a single input into an output. Override to implement.
Parameters
input (Dict[str, Any]) – The input to the runnable.
config (Optional[RunnableConfig]) – A config to use when invoking the runnable.
The config supports standard keys like ‘tags’, ‘metadata’ for tracing
purposes, ‘max_concurrency’ for controlling how much work to do
purposes, ‘max_concurrency’ for controlling how much work to do
in parallel, and other keys. Please refer to the RunnableConfig
for more details.
kwargs (Any) – 
Returns
The output of the runnable.
Return type
Dict[str, Any]
classmethod is_lc_serializable() → bool¶
Is this class serializable?
Return type
bool
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod lc_id() → List[str]¶
A unique identifier for this class for serialization purposes.
The unique identifier is a list of strings that describes the path
to the object.
Return type
List[str]
to the object.
Return type
List[str]
map() → Runnable[List[Input], List[Output]]¶
Return a new Runnable that maps a list of inputs to a list of outputs,
by calling invoke() with each input.
Example
from langchain_core.runnables import RunnableLambda
def _lambda(x: int) -> int:
    return x + 1
runnable = RunnableLambda(_lambda)
print(runnable.map().invoke([1, 2, 3])) # [2, 3, 4]
Return type
Runnable[List[Input], List[Output]]
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
classmethod parse_obj(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
pick(keys: Union[str, List[str]]) → RunnableSerializable[Any, Any]¶
Pick keys from the dict output of this runnable.
Pick single key:import json
from langchain_core.runnables import RunnableLambda, RunnableMap
as_str = RunnableLambda(str)
stop_after_attempt (int) – The maximum number of attempts to make before giving up
Returns
A new Runnable that retries the original runnable on exceptions.
Return type
Runnable[Input, Output]
with_types(*, input_type: Optional[Type[Input]] = None, output_type: Optional[Type[Output]] = None) → Runnable[Input, Output]¶
Bind input and output types to a Runnable, returning a new Runnable.
Parameters
input_type (Optional[Type[Input]]) – 
output_type (Optional[Type[Output]]) – 
Return type
Runnable[Input, Output]
property InputType: Type[Input]¶
The type of input this runnable accepts specified as a type annotation.
property OutputType: Type[Output]¶
The type of output this runnable produces specified as a type annotation.
property config_specs: List[ConfigurableFieldSpec]¶
List configurable fields for this runnable.
property input_keys: List[str]¶
Keys expected to be in the chain input.
property input_schema: Type[BaseModel]¶
The type of input this runnable accepts specified as a pydantic model.
property lc_attributes: Dict¶
List of attribute names that should be included in the serialized kwargs.
These attributes must be accepted by the constructor.
property lc_secrets: Dict[str, str]¶
A map of constructor argument names to secret ids.
For example,{“openai_api_key”: “OPENAI_API_KEY”}
name: Optional[str] = None¶
The name of the runnable. Used for debugging and tracing.
property output_keys: List[str]¶
Keys expected to be in the chain output.
property output_schema: Type[BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
langchain_experimental.video_captioning.models.BaseModel¶
class langchain_experimental.video_captioning.models.BaseModel(start_time: int, end_time: int)[source]¶
Attributes
end_time
start_time
Methods
__init__(start_time, end_time)
from_srt(start_time, end_time, *args)
Parameters
start_time (int) – 
end_time (int) – 
__init__(start_time: int, end_time: int) → None[source]¶
Parameters
start_time (int) – 
end_time (int) – 
Return type
None
classmethod from_srt(start_time: str, end_time: str, *args: Any) → BaseModel[source]¶
Parameters
start_time (str) – 
end_time (str) – 
args (Any) – 
Return type
BaseModel
langchain_experimental.video_captioning.models.AudioModel¶
class langchain_experimental.video_captioning.models.AudioModel(start_time: int, end_time: int, subtitle_text: str)[source]¶
Attributes
end_time
start_time
subtitle_text
Methods
__init__(start_time, end_time, subtitle_text)
from_srt(start_time, end_time, *args)
Parameters
start_time (int) – 
end_time (int) – 
subtitle_text (str) – 
__init__(start_time: int, end_time: int, subtitle_text: str) → None[source]¶
Parameters
start_time (int) – 
end_time (int) – 
subtitle_text (str) – 
Return type
None
classmethod from_srt(start_time: str, end_time: str, *args: Any) → BaseModel¶
Parameters
start_time (str) – 
end_time (str) – 
args (Any) – 
Return type
BaseModel
langchain_experimental.video_captioning.services.audio_service.AudioProcessor¶
class langchain_experimental.video_captioning.services.audio_service.AudioProcessor(api_key: str, output_audio_path: str = 'output_audio.mp3')[source]¶
Methods
__init__(api_key[, output_audio_path])
process(video_file_path[, run_manager])
Parameters
api_key (str) – 
output_audio_path (str) – 
__init__(api_key: str, output_audio_path: str = 'output_audio.mp3')[source]¶
Parameters
api_key (str) – 
output_audio_path (str) – 
process(video_file_path: str, run_manager: Optional[CallbackManagerForChainRun] = None) → list[source]¶
Parameters
video_file_path (str) – 
run_manager (Optional[CallbackManagerForChainRun]) – 
Return type
list
langchain_experimental.video_captioning.services.caption_service.CaptionProcessor¶
class langchain_experimental.video_captioning.services.caption_service.CaptionProcessor(llm: BaseLanguageModel, verbose: bool = True, similarity_threshold: int = 80, use_unclustered_models: bool = False)[source]¶
Methods
__init__(llm[, verbose, ...])
process(video_models[, run_manager])
Parameters
llm (BaseLanguageModel) – 
verbose (bool) – 
similarity_threshold (int) – 
use_unclustered_models (bool) – 
__init__(llm: BaseLanguageModel, verbose: bool = True, similarity_threshold: int = 80, use_unclustered_models: bool = False) → None[source]¶
Parameters
llm (BaseLanguageModel) – 
verbose (bool) – 
similarity_threshold (int) – 
use_unclustered_models (bool) – 
Return type
None
process(video_models: List[VideoModel], run_manager: Optional[CallbackManagerForChainRun] = None) → List[VideoModel][source]¶
Parameters
video_models (List[VideoModel]) – 
run_manager (Optional[CallbackManagerForChainRun]) – 
Return type
List[VideoModel]
langchain_experimental.video_captioning.models.VideoModel¶
class langchain_experimental.video_captioning.models.VideoModel(start_time: int, end_time: int, image_description: str)[source]¶
Attributes
end_time
image_description
start_time
Methods
__init__(start_time, end_time, image_description)
from_srt(start_time, end_time, *args)
similarity_score(other)
Parameters
start_time (int) – 
end_time (int) – 
image_description (str) – 
__init__(start_time: int, end_time: int, image_description: str) → None[source]¶
Parameters
start_time (int) – 
end_time (int) – 
image_description (str) – 
Return type
None
classmethod from_srt(start_time: str, end_time: str, *args: Any) → BaseModel¶
Parameters
start_time (str) – 
end_time (str) – 
args (Any) – 
Return type
BaseModel
similarity_score(other: VideoModel) → float[source]¶
Parameters
other (VideoModel) – 
Return type
float
langchain_experimental.video_captioning.services.image_service.ImageProcessor¶
class langchain_experimental.video_captioning.services.image_service.ImageProcessor(frame_skip: int = -1, threshold: int = 3000000)[source]¶
Methods
__init__([frame_skip, threshold])
process(video_file_path[, run_manager])
Parameters
frame_skip (int) – 
threshold (int) – 
__init__(frame_skip: int = -1, threshold: int = 3000000) → None[source]¶
Parameters
frame_skip (int) – 
threshold (int) – 
Return type
None
process(video_file_path: str, run_manager: Optional[CallbackManagerForChainRun] = None) → list[source]¶
Parameters
video_file_path (str) – 
run_manager (Optional[CallbackManagerForChainRun]) – 
Return type
list
langchain_experimental.video_captioning.models.CaptionModel¶
class langchain_experimental.video_captioning.models.CaptionModel(start_time: int, end_time: int, closed_caption: str)[source]¶
Attributes
closed_caption
end_time
start_time
Methods
__init__(start_time, end_time, closed_caption)
add_subtitle_text(subtitle_text)
from_audio_model(audio_model)
from_srt(start_time, end_time, *args)
from_video_model(video_model)
to_srt_entry(index)
Parameters
start_time (int) – 
end_time (int) – 
closed_caption (str) – 
__init__(start_time: int, end_time: int, closed_caption: str) → None[source]¶
Parameters
start_time (int) – 
end_time (int) – 
closed_caption (str) – 
Return type
None
add_subtitle_text(subtitle_text: str) → CaptionModel[source]¶
Parameters
subtitle_text (str) – 
Return type
CaptionModel
classmethod from_audio_model(audio_model: AudioModel) → CaptionModel[source]¶
Parameters
audio_model (AudioModel) – 
Return type
CaptionModel
classmethod from_srt(start_time: str, end_time: str, *args: Any) → BaseModel¶
Parameters
start_time (str) – 
end_time (str) – 
args (Any) – 
Return type
BaseModel
classmethod from_video_model(video_model: VideoModel) → CaptionModel[source]¶
Parameters
video_model (VideoModel) – 
Return type
CaptionModel
to_srt_entry(index: int) → str[source]¶
Parameters
index (int) – 
Return type
str
langchain_experimental.video_captioning.services.srt_service.SRTProcessor¶
class langchain_experimental.video_captioning.services.srt_service.SRTProcessor[source]¶
Methods
__init__()
process(caption_models)
Generates the full SRT content from a list of caption models.
__init__()¶
static process(caption_models: List[CaptionModel]) → str[source]¶
Generates the full SRT content from a list of caption models.
Parameters
caption_models (List[CaptionModel]) – 
Return type
str
langchain_experimental.video_captioning.services.combine_service.CombineProcessor¶
class langchain_experimental.video_captioning.services.combine_service.CombineProcessor(llm: BaseLanguageModel, verbose: bool = True, char_limit: int = 20)[source]¶
Methods
__init__(llm[, verbose, char_limit])
process(video_models, audio_models[, ...])
Parameters
llm (BaseLanguageModel) – 
verbose (bool) – 
char_limit (int) – 
__init__(llm: BaseLanguageModel, verbose: bool = True, char_limit: int = 20)[source]¶
Parameters
llm (BaseLanguageModel) – 
verbose (bool) – 
char_limit (int) – 
process(video_models: List[VideoModel], audio_models: List[AudioModel], run_manager: Optional[CallbackManagerForChainRun] = None) → List[CaptionModel][source]¶
Parameters
video_models (List[VideoModel]) – 
audio_models (List[AudioModel]) – 
run_manager (Optional[CallbackManagerForChainRun]) – 
Return type
List[CaptionModel]
langchain_google_vertexai.evaluators.evaluation.VertexPairWiseStringEvaluator¶
class langchain_google_vertexai.evaluators.evaluation.VertexPairWiseStringEvaluator(metric: str, **kwargs)[source]¶
Evaluate the perplexity of a predicted string.
Attributes
requires_input
Whether this evaluator requires an input string.
requires_reference
Whether this evaluator requires a reference label.
Methods
__init__(metric, **kwargs)
aevaluate_string_pairs(*, prediction, ...[, ...])
Asynchronously evaluate the output string pairs.
evaluate_string_pairs(*, prediction, ...[, ...])
Evaluate the output string pairs.
Parameters
metric (str) – 
__init__(metric: str, **kwargs)[source]¶
Parameters
metric (str) – 
async aevaluate_string_pairs(*, prediction: str, prediction_b: str, reference: Optional[str] = None, input: Optional[str] = None, **kwargs: Any) → dict¶
Asynchronously evaluate the output string pairs.
Parameters
prediction (str) – The output string from the first model.
prediction_b (str) – The output string from the second model.
reference (Optional[str], optional) – The expected output / reference string.
input (Optional[str], optional) – The input string.
**kwargs – Additional keyword arguments, such as callbacks and optional reference strings.
Returns
A dictionary containing the preference, scores, and/or other information.
Return type
dict
evaluate_string_pairs(*, prediction: str, prediction_b: str, reference: Optional[str] = None, input: Optional[str] = None, **kwargs: Any) → dict¶
Evaluate the output string pairs.
Parameters
prediction (str) – The output string from the first model.
prediction_b (str) – The output string from the second model.
langchain_google_vertexai.evaluators.evaluation.VertexStringEvaluator¶
class langchain_google_vertexai.evaluators.evaluation.VertexStringEvaluator(metric: str, **kwargs)[source]¶
Evaluate the perplexity of a predicted string.
Attributes
evaluation_name
The name of the evaluation.
requires_input
Whether this evaluator requires an input string.
requires_reference
Whether this evaluator requires a reference label.
Methods
__init__(metric, **kwargs)
aevaluate_strings(*, prediction[, ...])
Asynchronously evaluate Chain or LLM output, based on optional input and label.
evaluate(examples, predictions, *[, ...])
evaluate_strings(*, prediction[, reference, ...])
Evaluate Chain or LLM output, based on optional input and label.
Parameters
metric (str) – 
__init__(metric: str, **kwargs)[source]¶
Parameters
metric (str) – 
async aevaluate_strings(*, prediction: str, reference: Optional[str] = None, input: Optional[str] = None, **kwargs: Any) → dict¶
Asynchronously evaluate Chain or LLM output, based on optional input and label.
Parameters
prediction (str) – The LLM or chain prediction to evaluate.
reference (Optional[str], optional) – The reference label to evaluate against.
input (Optional[str], optional) – The input to consider during evaluation.
**kwargs – Additional keyword arguments, including callbacks, tags, etc.
Returns
The evaluation results containing the score or value.
Return type
dict
Returns
The evaluation results containing the score or value.
Return type
dict
evaluate(examples: Sequence[Dict[str, str]], predictions: Sequence[Dict[str, str]], *, question_key: str = 'context', answer_key: str = 'reference', prediction_key: str = 'prediction', instruction_key: str = 'instruction', **kwargs: Any) → List[dict][source]¶
Parameters
examples (Sequence[Dict[str, str]]) – 
predictions (Sequence[Dict[str, str]]) – 
question_key (str) – 
answer_key (str) – 
prediction_key (str) – 
instruction_key (str) – 
kwargs (Any) – 
Return type
List[dict]
evaluate_strings(*, prediction: str, reference: Optional[str] = None, input: Optional[str] = None, **kwargs: Any) → dict¶
Evaluate Chain or LLM output, based on optional input and label.
Parameters
prediction (str) – The LLM or chain prediction to evaluate.
reference (Optional[str], optional) – The reference label to evaluate against.
input (Optional[str], optional) – The input to consider during evaluation.
**kwargs – Additional keyword arguments, including callbacks, tags, etc.
Returns
The evaluation results containing the score or value.
Return type
dict
langchain_google_community.texttospeech.TextToSpeechTool¶
class langchain_google_community.texttospeech.TextToSpeechTool[source]¶
Bases: BaseTool
Tool that queries the Google Cloud Text to Speech API.
In order to set this up, follow instructions at:
https://cloud.google.com/text-to-speech/docs/before-you-begin
Initializes private fields.
param args_schema: Optional[Type[BaseModel]] = None¶
Pydantic model class to validate and parse the tool’s input arguments.
param callback_manager: Optional[BaseCallbackManager] = None¶
Deprecated. Please use callbacks instead.
param callbacks: Callbacks = None¶
Callbacks to be called during tool execution.
param description: str = 'A wrapper around Google Cloud Text-to-Speech. Useful for when you need to synthesize audio from text. It supports multiple languages, including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi. '¶
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
param handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False¶
Handle the content of the ToolException thrown.
param handle_validation_error: Optional[Union[bool, str, Callable[[ValidationError], str]]] = False¶
Handle the content of the ValidationError thrown.
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the tool. Defaults to None
This metadata will be associated with each call to this tool,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a tool with its use case.
param return_direct: bool = False¶
Whether to return the tool’s output directly. Setting this to True means
langchain_google_community.documentai_warehouse.DocumentAIWarehouseRetriever¶
class langchain_google_community.documentai_warehouse.DocumentAIWarehouseRetriever[source]¶
Bases: BaseRetriever
A retriever based on Document AI Warehouse.
Documents should be created and documents should be uploadedin a separate flow, and this retriever uses only Document AI
schema_id provided to search for relevant documents.
More info: https://cloud.google.com/document-ai-warehouse.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param location: str = 'us'¶
Google Cloud location where Document AI Warehouse is placed.
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the retriever. Defaults to None
This metadata will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
param project_number: str [Required]¶
Google Cloud project number, should contain digits only.
param qa_size_limit: int = 5¶
The limit on the number of documents returned.
param schema_id: Optional[str] = None¶
Document AI Warehouse schema to query against.
If nothing is provided, all documents in the project will be searched.
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
use case.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation runs ainvoke in parallel using asyncio.gather.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently;
e.g., if the underlying runnable uses an API which supports a batch mode.
Parameters
inputs (List[Input]) – 
config (Optional[Union[RunnableConfig, List[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Optional[Any]) – 
Return type
List[Output]
async abatch_as_completed(inputs: Sequence[Input], config: Optional[Union[RunnableConfig, Sequence[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → AsyncIterator[Tuple[int, Union[Output, Exception]]]¶
Run ainvoke in parallel on a list of inputs,
yielding results as they complete.
Parameters
inputs (Sequence[Input]) – 
config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – 
return_exceptions (bool) – 
kwargs (Optional[Any]) – 
Return type
AsyncIterator[Tuple[int, Union[Output, Exception]]]
async aget_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) → List[Document]¶
[Deprecated] Asynchronously get documents relevant to a query.
Users should favor using .ainvoke or .abatch rather than
aget_relevant_documents directly.
aget_relevant_documents directly.
Parameters
query (str) – string to find relevant documents for
callbacks (Callbacks) – Callback manager or list of callbacks
tags (Optional[List[str]]) – Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
metadata (Optional[Dict[str, Any]]) – Optional metadata associated with the retriever. Defaults to None
This metadata will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
run_name (Optional[str]) – Optional name for the run.
kwargs (Any) – 
Returns
List of relevant documents
Return type
List[Document]
Notes
Deprecated since version langchain-core==0.1.46: Use ainvoke instead.
async ainvoke(input: str, config: Optional[RunnableConfig] = None, **kwargs: Any) → List[Document]¶
Asynchronously invoke the retriever to get relevant documents.
Main entry point for asynchronous retriever invocations.
Parameters
input (str) – The query string
config (Optional[RunnableConfig]) – Configuration for the retriever
**kwargs (Any) – Additional arguments to pass to the retriever
Returns
List of relevant documents
Return type
List[Document]
Examples:
await retriever.ainvoke("query")
assign(**kwargs: Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any], Mapping[str, Union[Runnable[Dict[str, Any], Any], Callable[[Dict[str, Any]], Any]]]]) → RunnableSerializable[Any, Any]¶
Assigns new fields to the dict output of this runnable.
Returns a new runnable.
from langchain_community.llms.fake import FakeStreamingListLLM