Tony20100/langchain_full huggingface dataset:
Returns
A sequence of optional values associated with the keys.
If a key is not found, the corresponding value will be None.
Return type
List[Optional[V]]
async amset(key_value_pairs: Sequence[Tuple[str, V]]) → None¶
Set the values for the given keys.
Parameters
key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.
Return type
None
async ayield_keys(*, prefix: Optional[str] = None) → AsyncIterator[str]¶
Get an iterator over keys that match the given prefix.
Parameters
prefix (str) – The prefix to match.
Returns
An iterator over keys that match the given prefix.
This method is allowed to return an iterator over either K or str
depending on what makes more sense for the given store.
Return type
Iterator[K | str]
decode_value(value: Any) → Any[source]¶
Decodes value from Astra DB
Parameters
value (Any) – 
Return type
Any
encode_value(value: Any) → Any[source]¶
Encodes value for Astra DB
Parameters
value (Any) – 
Return type
Any
mdelete(keys: Sequence[str]) → None¶
Delete the given keys and their associated values.
Parameters
keys (Sequence[K]) – A sequence of keys to delete.
Return type
None
mget(keys: Sequence[str]) → List[Optional[V]]¶
Get the values associated with the given keys.
Parameters
keys (Sequence[K]) – A sequence of keys.
Returns
A sequence of optional values associated with the keys.
If a key is not found, the corresponding value will be None.
Return type
List[Optional[V]]
mset(key_value_pairs: Sequence[Tuple[str, V]]) → None¶
Set the values for the given keys.
Parameters
Set the values for the given keys.
Parameters
key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.
Return type
None
yield_keys(*, prefix: Optional[str] = None) → Iterator[str]¶
Get an iterator over keys that match the given prefix.
Parameters
prefix (str) – The prefix to match.
Returns
An iterator over keys that match the given prefix.
This method is allowed to return an iterator over either K or str
depending on what makes more sense for the given store.
Return type
Iterator[K | str]
Examples using AstraDBStore¶
Astra DB
langchain_community.storage.cassandra.CassandraByteStore¶
class langchain_community.storage.cassandra.CassandraByteStore(table: str, *, session: Optional[Session] = None, keyspace: Optional[str] = None, setup_mode: SetupMode = SetupMode.SYNC)[source]¶
Methods
__init__(table, *[, session, keyspace, ...])
aensure_db_setup()
amdelete(keys)
Delete the given keys and their associated values.
amget(keys)
Get the values associated with the given keys.
amset(key_value_pairs)
Set the values for the given keys.
ayield_keys(*[, prefix])
Get an iterator over keys that match the given prefix.
ensure_db_setup()
get_delete_statement()
get_insert_statement()
get_select_statement()
mdelete(keys)
Delete the given keys and their associated values.
mget(keys)
Get the values associated with the given keys.
mset(key_value_pairs)
Set the values for the given keys.
yield_keys(*[, prefix])
Get an iterator over keys that match the given prefix.
Parameters
table (str) – 
session (Optional[Session]) – 
keyspace (Optional[str]) – 
setup_mode (SetupMode) – 
__init__(table: str, *, session: Optional[Session] = None, keyspace: Optional[str] = None, setup_mode: SetupMode = SetupMode.SYNC) → None[source]¶
Parameters
table (str) – 
session (Optional[Session]) – 
keyspace (Optional[str]) – 
setup_mode (SetupMode) – 
Return type
None
async aensure_db_setup() → None[source]¶
Return type
None
async amdelete(keys: Sequence[str]) → None[source]¶
Return type
None
async amdelete(keys: Sequence[str]) → None[source]¶
Delete the given keys and their associated values.
Parameters
keys (Sequence[K]) – A sequence of keys to delete.
Return type
None
async amget(keys: Sequence[str]) → List[Optional[bytes]][source]¶
Get the values associated with the given keys.
Parameters
keys (Sequence[K]) – A sequence of keys.
Returns
A sequence of optional values associated with the keys.
If a key is not found, the corresponding value will be None.
Return type
List[Optional[bytes]]
async amset(key_value_pairs: Sequence[Tuple[str, bytes]]) → None[source]¶
Set the values for the given keys.
Parameters
key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.
Return type
None
async ayield_keys(*, prefix: Optional[str] = None) → AsyncIterator[str][source]¶
Get an iterator over keys that match the given prefix.
Parameters
prefix (str) – The prefix to match.
Returns
An iterator over keys that match the given prefix.
This method is allowed to return an iterator over either K or str
depending on what makes more sense for the given store.
Return type
Iterator[K | str]
ensure_db_setup() → None[source]¶
Return type
None
get_delete_statement() → PreparedStatement[source]¶
Return type
PreparedStatement
get_insert_statement() → PreparedStatement[source]¶
Return type
PreparedStatement
get_select_statement() → PreparedStatement[source]¶
Return type
PreparedStatement
mdelete(keys: Sequence[str]) → None[source]¶
Delete the given keys and their associated values.
Parameters
keys (Sequence[K]) – A sequence of keys to delete.
Return type
None
keys (Sequence[K]) – A sequence of keys to delete.
Return type
None
mget(keys: Sequence[str]) → List[Optional[bytes]][source]¶
Get the values associated with the given keys.
Parameters
keys (Sequence[K]) – A sequence of keys.
Returns
A sequence of optional values associated with the keys.
If a key is not found, the corresponding value will be None.
Return type
List[Optional[bytes]]
mset(key_value_pairs: Sequence[Tuple[str, bytes]]) → None[source]¶
Set the values for the given keys.
Parameters
key_value_pairs (Sequence[Tuple[K, V]]) – A sequence of key-value pairs.
Return type
None
yield_keys(*, prefix: Optional[str] = None) → Iterator[str][source]¶
Get an iterator over keys that match the given prefix.
Parameters
prefix (str) – The prefix to match.
Returns
An iterator over keys that match the given prefix.
This method is allowed to return an iterator over either K or str
depending on what makes more sense for the given store.
Return type
Iterator[K | str]
Examples using CassandraByteStore¶
Cassandra
langchain_community.storage.astradb.AstraDBBaseStore¶
class langchain_community.storage.astradb.AstraDBBaseStore(*args: Any, **kwargs: Any)[source]¶
Base class for the DataStax AstraDB data store.
Methods
__init__(*args, **kwargs)
amdelete(keys)
Delete the given keys and their associated values.
amget(keys)
Get the values associated with the given keys.
amset(key_value_pairs)
Set the values for the given keys.
ayield_keys(*[, prefix])
Get an iterator over keys that match the given prefix.
decode_value(value)
Decodes value from Astra DB
encode_value(value)
Encodes value for Astra DB
mdelete(keys)
Delete the given keys and their associated values.
mget(keys)
Get the values associated with the given keys.
mset(key_value_pairs)
Set the values for the given keys.
yield_keys(*[, prefix])
Get an iterator over keys that match the given prefix.
Parameters
args (Any) – 
kwargs (Any) – 
__init__(*args: Any, **kwargs: Any) → None[source]¶
Parameters
args (Any) – 
kwargs (Any) – 
Return type
None
async amdelete(keys: Sequence[str]) → None[source]¶
Delete the given keys and their associated values.
Parameters
keys (Sequence[K]) – A sequence of keys to delete.
Return type
None
async amget(keys: Sequence[str]) → List[Optional[V]][source]¶
Get the values associated with the given keys.
Parameters
keys (Sequence[K]) – A sequence of keys.
Returns
A sequence of optional values associated with the keys.
If a key is not found, the corresponding value will be None.
Return type
langchain_upstage.layout_analysis.UpstageLayoutAnalysisLoader¶
class langchain_upstage.layout_analysis.UpstageLayoutAnalysisLoader(file_path: Union[str, Path, List[str], List[Path]], output_type: Union[Literal['text', 'html'], dict] = 'html', split: Literal['none', 'element', 'page'] = 'none', api_key: Optional[str] = None, use_ocr: bool = False, exclude: list = ['header', 'footer'])[source]¶
Upstage Layout Analysis.
To use, you should have the environment variable UPSTAGE_API_KEY
set with your API key or pass it as a named parameter to the constructor.
Example
from langchain_upstage import UpstageLayoutAnalysis
file_path = "/PATH/TO/YOUR/FILE.pdf"
loader = UpstageLayoutAnalysis(
            file_path, split="page", output_type="text"
         )
Initializes an instance of the Upstage document loader.
Parameters
file_path (Union[str, Path, List[str], List[Path]) – The path to the document
to be loaded.
output_type (Union[OutputType, dict], optional) – The type of output to be
generated by the parser.
Defaults to “html”.
split (SplitType, optional) – The type of splitting to be applied.
Defaults to “none” (no splitting).
api_key (str, optional) – The API key for accessing the Upstage API.
Defaults to None, in which case it will be
fetched from the environment variable
UPSTAGE_API_KEY.
use_ocr (bool, optional) – Extract text from images in the document.
Defaults to False. (Use text info in PDF file)
exclude (list, optional) – Exclude specific elements from
the output.
Defaults to [“header”, “footer”].
Methods
the output.
Defaults to [“header”, “footer”].
Methods
__init__(file_path[, output_type, split, ...])
Initializes an instance of the Upstage document loader.
alazy_load()
A lazy loader for Documents.
aload()
Load data into Document objects.
lazy_load()
Lazily loads and parses the document using the UpstageLayoutAnalysisParser.
load()
Loads and parses the document using the UpstageLayoutAnalysisParser.
load_and_split([text_splitter])
Load Documents and split into chunks.
merge_and_split(documents[, splitter])
Merges the page content and metadata of multiple documents into a single document, or splits the documents using a custom splitter.
__init__(file_path: Union[str, Path, List[str], List[Path]], output_type: Union[Literal['text', 'html'], dict] = 'html', split: Literal['none', 'element', 'page'] = 'none', api_key: Optional[str] = None, use_ocr: bool = False, exclude: list = ['header', 'footer'])[source]¶
Initializes an instance of the Upstage document loader.
Parameters
file_path (Union[str, Path, List[str], List[Path]) – The path to the document
to be loaded.
output_type (Union[OutputType, dict], optional) – The type of output to be
generated by the parser.
Defaults to “html”.
split (SplitType, optional) – The type of splitting to be applied.
Defaults to “none” (no splitting).
api_key (str, optional) – The API key for accessing the Upstage API.
Defaults to None, in which case it will be
fetched from the environment variable
UPSTAGE_API_KEY.
fetched from the environment variable
UPSTAGE_API_KEY.
use_ocr (bool, optional) – Extract text from images in the document.
Defaults to False. (Use text info in PDF file)
exclude (list, optional) – Exclude specific elements from
the output.
Defaults to [“header”, “footer”].
async alazy_load() → AsyncIterator[Document]¶
A lazy loader for Documents.
Return type
AsyncIterator[Document]
async aload() → List[Document]¶
Load data into Document objects.
Return type
List[Document]
lazy_load() → Iterator[Document][source]¶
Lazily loads and parses the document using the UpstageLayoutAnalysisParser.
Returns
An iterator of Document objects representing the parsed layout analysis.
Return type
Iterator[Document]
load() → List[Document][source]¶
Loads and parses the document using the UpstageLayoutAnalysisParser.
Returns
A list of Document objects representing the parsed layout analysis.
Return type
List[Document]
load_and_split(text_splitter: Optional[TextSplitter] = None) → List[Document]¶
Load Documents and split into chunks. Chunks are returned as Documents.
Do not override this method. It should be considered to be deprecated!
Parameters
text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents.
Defaults to RecursiveCharacterTextSplitter.
Returns
List of Documents.
Return type
List[Document]
merge_and_split(documents: List[Document], splitter: Optional[object] = None) → List[Document][source]¶
Merges the page content and metadata of multiple documents into a single
document, or splits the documents using a custom splitter.
Parameters
documents (list) – A list of Document objects to be merged and split.
Parameters
documents (list) – A list of Document objects to be merged and split.
splitter (object, optional) – An optional splitter object that implements the
split_documents method. If provided, the documents will be split using
this splitter. Defaults to None, in which case the documents are merged.
Returns
A list of Document objects. If no splitter is provided, a single
Document object is returned with the merged content and combined metadata.
If a splitter is provided, the documents are split and a list of Document
objects is returned.
Return type
list
Raises
AssertionError – If a splitter is provided but it does not implement the
split_documents –
langchain_upstage.layout_analysis.validate_file_path¶
langchain_upstage.layout_analysis.validate_file_path(file_path: Union[str, Path, List[str], List[Path]]) → None[source]¶
Validates if a file exists at the given file path.
Parameters
file_path (Union[str, Path, List[str], List[Path]) – The file path(s) to be
validated.
Raises
FileNotFoundError – If the file or any of the files in the list do not exist.
Return type
None
langchain_upstage.layout_analysis.get_from_param_or_env¶
langchain_upstage.layout_analysis.get_from_param_or_env(key: str, param: Optional[str] = None, env_key: Optional[str] = None, default: Optional[str] = None) → str[source]¶
Get a value from a param or an environment variable.
Parameters
key (str) – 
param (Optional[str]) – 
env_key (Optional[str]) – 
default (Optional[str]) – 
Return type
str
langchain_google_vertexai.gemma.GemmaChatVertexAIModelGarden¶
class langchain_google_vertexai.gemma.GemmaChatVertexAIModelGarden[source]¶
Bases: _GemmaBase, _BaseVertexAIModelGarden, BaseChatModel
Needed for mypy typing to recognize model_name as a valid arg.
param additional_headers: Optional[Dict[str, str]] = None¶
A key-value dictionary representing additional headers for the model call
param allowed_model_args: Optional[List[str]] = ['temperature', 'top_p', 'top_k', 'max_tokens']¶
Allowed optional args to be passed to the model.
param api_endpoint: Optional[str] = None¶
Desired API endpoint, e.g., us-central1-aiplatform.googleapis.com
param api_transport: Optional[str] = None¶
The desired API transport method, can be either ‘grpc’ or ‘rest’
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED] Callback manager to add to the run trace.
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None¶
A callback which returns client certificate bytes and private key bytes both
param credentials: Any = None¶
The default custom credentials (google.auth.credentials.Credentials) to use
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param endpoint_id: str [Required]¶
A name of an endpoint where the model has been deployed.
param full_model_name: Optional[str] = None¶
The full name of the model’s endpoint.
param location: str = 'us-central1'¶
The default location to use when making API calls.
param max_retries: int = 6¶
The maximum number of retries to make when generating.
param max_tokens: Optional[int] = None¶
The maximum number of tokens to generate.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: Optional[str] = None (alias 'model')¶
Underlying model name.
param parse_response: bool = False¶
Whether to post-process the chat response and clean repeations
param project: Optional[str] = None¶
The default GCP project to use when making Vertex API calls.
param prompt_arg: str = 'prompt'¶
param request_parallelism: int = 5¶
The amount of parallelism allowed for requests issued to VertexAI models.
param result_arg: Optional[str] = 'generated_text'¶
Set result_arg to None if output of the model is expected to be a string.
param single_example_per_request: bool = True¶
LLM endpoint currently serves only the first example in the request
param stop: Optional[List[str]] = None (alias 'stop_sequences')¶
Optional list of stop words to use when generating.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: Optional[float] = None¶
The temperature to use for sampling.
param top_k: Optional[int] = None¶
The temperature to use for sampling.
param top_k: Optional[int] = None¶
The top-k value to use for sampling.
param top_p: Optional[float] = None¶
The top-p value to use for sampling.
param verbose: bool [Optional]¶
Whether to print out response text.
__call__(messages: List[BaseMessage], stop: Optional[List[str]] = None, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, **kwargs: Any) → BaseMessage¶
[Deprecated]
Notes
Deprecated since version langchain-core==0.1.7: Use invoke instead.
Parameters
messages (List[BaseMessage]) – 
stop (Optional[List[str]]) – 
callbacks (Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]) – 
kwargs (Any) – 
Return type
BaseMessage
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]
Parameters
input_type (Optional[Type[Input]]) – 
output_type (Optional[Type[Output]]) – 
Return type
Runnable[Input, Output]
property InputType: TypeAlias¶
Get the input type for this runnable.
property OutputType: Any¶
Get the output type for this runnable.
property async_prediction_client: PredictionServiceAsyncClient¶
Returns PredictionServiceClient.
property config_specs: List[ConfigurableFieldSpec]¶
List configurable fields for this runnable.
property endpoint_path: str¶
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_schema: Type[BaseModel]¶
The type of output this runnable produces specified as a pydantic model.
property prediction_client: PredictionServiceClient¶
Returns PredictionServiceClient.
task_executor: ClassVar[Optional[Executor]] = FieldInfo(exclude=True, extra={})¶
Examples using GemmaChatVertexAIModelGarden¶
Google Cloud Vertex AI
langchain_google_vertexai.gemma.GemmaLocalKaggle¶
class langchain_google_vertexai.gemma.GemmaLocalKaggle[source]¶
Bases: _GemmaLocalKaggleBase, BaseLLM
Local gemma chat model loaded from Kaggle.
Only needed for typing.
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param keras_backend: str = 'jax'¶
param max_tokens: Optional[int] = None¶
The maximum number of tokens to generate.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: str = 'gemma_2b_en' (alias 'model')¶
Gemma model name.
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: Optional[float] = None¶
The temperature to use for sampling.
param top_k: Optional[int] = None¶
The top-k value to use for sampling.
param top_p: Optional[float] = None¶
The top-p value to use for sampling.
param verbose: bool [Optional]¶
Whether to print out response text.
langchain_google_vertexai.gemma.GemmaChatLocalHF¶
class langchain_google_vertexai.gemma.GemmaChatLocalHF[source]¶
Bases: _GemmaLocalHFBase, BaseChatModel
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 cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param cache_dir: Optional[str] = None¶
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED] Callback manager to add to the run trace.
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶
Optional encoder to use for counting tokens.
param hf_access_token: str [Required]¶
param max_tokens: Optional[int] = None¶
The maximum number of tokens to generate.
param metadata: Optional[Dict[str, Any]] = None¶
Metadata to add to the run trace.
param model_name: str = 'gemma_2b_en' (alias 'model')¶
Gemma model name.
param parse_response: bool = False¶
Whether to post-process the chat response and clean repeations
param tags: Optional[List[str]] = None¶
Tags to add to the run trace.
param temperature: Optional[float] = None¶
The temperature to use for sampling.
param top_k: Optional[int] = None¶
langchain_google_vertexai.gemma.GemmaVertexAIModelGarden¶
class langchain_google_vertexai.gemma.GemmaVertexAIModelGarden[source]¶
Bases: VertexAIModelGarden
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 additional_headers: Optional[Dict[str, str]] = None¶
A key-value dictionary representing additional headers for the model call
param allowed_model_args: Optional[List[str]] = ['temperature', 'top_p', 'top_k', 'max_tokens']¶
Allowed optional args to be passed to the model.
param api_endpoint: Optional[str] = None¶
Desired API endpoint, e.g., us-central1-aiplatform.googleapis.com
param api_transport: Optional[str] = None¶
The desired API transport method, can be either ‘grpc’ or ‘rest’
param cache: Union[BaseCache, bool, None] = None¶
Whether to cache the response.
If true, will use the global cache.
If false, will not use a cache
If None, will use the global cache if it’s set, otherwise no cache.
If instance of BaseCache, will use the provided cache.
Caching is not currently supported for streaming methods of models.
param callback_manager: Optional[BaseCallbackManager] = None¶
[DEPRECATED]
param callbacks: Callbacks = None¶
Callbacks to add to the run trace.
param client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None¶
A callback which returns client certificate bytes and private key bytes both
param credentials: Any = None¶
The default custom credentials (google.auth.credentials.Credentials) to use
param custom_get_token_ids: Optional[Callable[[str], List[int]]] = None¶