id
stringlengths
14
16
text
stringlengths
20
3.26k
source
stringlengths
65
181
a120bec9ca06-1
transformed_document = await qa_transformer.atransform_documents(documents) Methods __init__(properties[, openai_api_key, ...]) atransform_documents(documents, **kwargs) Extracts properties from text documents using doctran. transform_documents(documents, **kwargs) Extracts properties from text documents using doctran....
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.doctran_text_extract.DoctranPropertyExtractor.html
6265e13d12e8-0
langchain_community.document_transformers.beautiful_soup_transformer.get_navigable_strings¶ langchain_community.document_transformers.beautiful_soup_transformer.get_navigable_strings(element: Any, *, remove_comments: bool = False) → Iterator[str][source]¶ Get all navigable strings from a BeautifulSoup element. Paramete...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.beautiful_soup_transformer.get_navigable_strings.html
39e8bd8a6abb-0
langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter¶ class langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter[source]¶ Bases: BaseDocumentTransformer, BaseModel Perform K-means clustering on document vectors. Returns an arbitrary...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter.html
39e8bd8a6abb-1
kwargs (Any) – Returns A list of transformed Documents. Return type Sequence[Document] classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶ Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter.html
39e8bd8a6abb-2
self (Model) – Returns new model instance Return type Model dict(*, 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: bo...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter.html
39e8bd8a6abb-3
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...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter.html
39e8bd8a6abb-4
ref_template (unicode) – Return type DictStrAny classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶ Parameters by_alias (bool) – ref_template (unicode) – dumps_kwargs (Any) – Return type unicode transform_documents(documents: Sequence[Do...
https://api.python.langchain.com/en/latest/document_transformers/langchain_community.document_transformers.embeddings_redundant_filter.EmbeddingsClusteringFilter.html
bf0f912852d4-0
langchain_experimental.generative_agents.memory.GenerativeAgentMemory¶ class langchain_experimental.generative_agents.memory.GenerativeAgentMemory[source]¶ Bases: BaseMemory Memory for the generative agent. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the inp...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-1
Add an observations or memories to the agent’s memory. Parameters memory_content (str) – now (Optional[datetime]) – Return type List[str] add_memory(memory_content: str, now: Optional[datetime] = None) → List[str][source]¶ Add an observation or memory to the agent’s memory. Parameters memory_content (str) – now (Opt...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-2
values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶ Duplicate a model, optionally choose which fields to include, exclude an...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-3
exclude_unset (bool) – exclude_defaults (bool) – exclude_none (bool) – Return type DictStrAny fetch_memories(observation: str, now: Optional[datetime] = None) → List[Document][source]¶ Fetch related memories. Parameters observation (str) – now (Optional[datetime]) – Return type List[Document] format_memories_detai...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-4
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, Map...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-5
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_pi...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
bf0f912852d4-6
SerializedNotImplemented classmethod update_forward_refs(**localns: Any) → None¶ Try to update ForwardRefs on fields based on this Model, globalns and localns. Parameters localns (Any) – Return type None classmethod validate(value: Any) → Model¶ Parameters value (Any) – Return type Model property lc_attributes: Dict¶...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.memory.GenerativeAgentMemory.html
88c73d88f8e3-0
langchain_experimental.generative_agents.generative_agent.GenerativeAgent¶ class langchain_experimental.generative_agents.generative_agent.GenerativeAgent[source]¶ Bases: BaseModel Agent as a character with memory and innate characteristics. Create a new model by parsing and validating input data from keyword arguments...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html
88c73d88f8e3-1
Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values Parameters _fields_set (Optional[SetStr]) – values (Any) – Return type Model copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html
88c73d88f8e3-2
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) – Return type DictStrAny classmethod from_orm(obj: Any) → Model...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html
88c73d88f8e3-3
now (Optional[datetime]) – Return type str 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, exclu...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html
88c73d88f8e3-4
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_pi...
https://api.python.langchain.com/en/latest/generative_agents/langchain_experimental.generative_agents.generative_agent.GenerativeAgent.html
7ac48834f3ca-0
langchain_experimental.llm_bash.base.LLMBashChain¶ class langchain_experimental.llm_bash.base.LLMBashChain[source]¶ Bases: Chain Chain that interprets a prompt and executes bash operations. Example from langchain.chains import LLMBashChain from langchain_community.llms import OpenAI llm_bash = LLMBashChain.from_llm(Ope...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-1
and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a chain with its use case. param prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), template='If someone asks you to perform a task, your job is ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-2
accessible via langchain.globals.get_verbose(). __call__(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = Non...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-3
Return type Dict[str, Any] Notes Deprecated since version langchain==0.1.0: Use invoke instead. 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 para...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-4
Return type AsyncIterator[Tuple[int, Union[Output, Exception]]] async acall(inputs: Union[Dict[str, Any], Any], return_only_outputs: bool = False, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-5
Returns A dict of named outputs. Should contain all outputs specified inChain.output_keys. Return type Dict[str, Any] Notes Deprecated since version langchain==0.1.0: Use ainvoke instead. async ainvoke(input: Dict[str, Any], config: Optional[RunnableConfig] = None, **kwargs: Any) → Dict[str, Any]¶ Default implementatio...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-6
A dictionary of all inputs, including those added by the chain’s memory. Return type Dict[str, str] async aprep_outputs(inputs: Dict[str, str], outputs: Dict[str, str], return_only_outputs: bool = False) → Dict[str, str]¶ Validate and prepare chain outputs, and save info about this run to memory. Parameters inputs (Dic...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-7
addition to tags passed to the chain during construction, but only these runtime tags will propagate to calls to other objects. **kwargs (Any) – If the chain expects multiple inputs, they can be passed in directly as keyword arguments. metadata (Optional[Dict[str, Any]]) – **kwargs – Returns The chain output. Return ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-8
) llm = FakeStreamingListLLM(responses=["foo-lish"]) chain: Runnable = prompt | llm | {"str": StrOutputParser()} chain_with_assign = chain.assign(hello=itemgetter("str") | llm) print(chain_with_assign.input_schema.schema()) # {'title': 'PromptInput', 'type': 'object', 'properties': {'question': {'title': 'Question', 't...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-9
kwargs (Optional[Any]) – Return type AsyncIterator[Output] astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Opti...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-10
Below is a table that illustrates some evens that might be emitted by various chains. Metadata fields have been omitted from the table for brevity. Chain definitions have been included after the table. ATTENTION This reference table is for the V2 version of the schema. event name chunk input output on_chat_model_start ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-11
format_docs: def format_docs(docs: List[Document]) -> str: '''Format the docs.''' return ", ".join([doc.page_content for doc in docs]) format_docs = RunnableLambda(format_docs) some_tool: @tool def some_tool(x: int, y: str) -> dict: '''Some_tool.''' return {"x": x, "y": y} prompt: template = ChatPromptT...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-12
}, ] Parameters input (Any) – The input to the runnable. config (Optional[RunnableConfig]) – The config to use for the runnable. version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1. Users should use v2. v1 is for backwards compatibility and will be deprecated in 0.4.0. No default will be as...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-13
An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: O...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-14
exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags. kwargs (Any) – Return type Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]] async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of a...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-15
yielding results as they complete. Parameters inputs (Sequence[Input]) – config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type Iterator[Tuple[int, Union[Output, Exception]]] bind(**kwargs: Any) → Runnable[Input, Output]¶ Bind arguments t...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-16
Return type Type[BaseModel] configurable_alternatives(which: ConfigurableField, *, default_key: str = 'default', prefix_keys: bool = False, **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶ Configure alternatives for runnables that can be set at runt...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-17
max_tokens=ConfigurableField( id="output_token_number", name="Max tokens in the output", description="The maximum number of tokens in the output", ) ) # max_tokens = 20 print( "max_tokens_20: ", model.invoke("tell me something about chess").content ) # max_tokens = 200 print("max_tok...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-18
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(**kwargs: Any) → Dict¶ Dictionary ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-19
Parameters llm (BaseLanguageModel) – prompt (BasePromptTemplate) – kwargs (Any) – Return type LLMBashChain classmethod from_orm(obj: Any) → Model¶ Parameters obj (Any) – Return type Model get_graph(config: Optional[RunnableConfig] = None) → Graph¶ Return a graph representation of this runnable. Parameters config (O...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-20
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 co...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-21
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, excl...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-22
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_pi...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-23
json_only_chain = chain.pick("json") json_only_chain.invoke("[1, 2, 3]") # -> [1, 2, 3] Pick list of keys:from typing import Any import json from langchain_core.runnables import RunnableLambda, RunnableMap as_str = RunnableLambda(str) as_json = RunnableLambda(json.loads) def as_bytes(x: Any) -> bytes: return bytes(...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-24
return x * 2 runnable_1 = RunnableLambda(add_one) runnable_2 = RunnableLambda(mul_two) sequence = runnable_1.pipe(runnable_2) # Or equivalently: # sequence = runnable_1 | runnable_2 # sequence = RunnableSequence(first=runnable_1, last=runnable_2) sequence.invoke(1) await sequence.ainvoke(1) # -> 4 sequence.batch([1, 2,...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-25
return_only_outputs (bool) – Whether to only return the chain outputs. If False, inputs are also added to the final outputs. Returns A dict of the final chain outputs. Return type Dict[str, str] run(*args: Any, callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, tags: Optional[List[str]] ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-26
# -> "The temperature in Boise is..." # Suppose we have a multi-input chain that takes a 'question' string # and 'context' string: question = "What's the temperature in Boise, Idaho?" context = "Weather report for Boise, Idaho on 07/03/23..." chain.run(question=question, context=context) # -> "The temperature in Boise ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-27
Iterator[Output] to_json() → Union[SerializedConstructor, SerializedNotImplemented]¶ Serialize the runnable to JSON. Return type Union[SerializedConstructor, SerializedNotImplemented] to_json_not_implemented() → SerializedNotImplemented¶ Return type SerializedNotImplemented transform(input: Iterator[Input], config: Opt...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-28
Example: Parameters on_start (Optional[AsyncListener]) – on_end (Optional[AsyncListener]) – on_error (Optional[AsyncListener]) – Return type Runnable[Input, Output] with_config(config: Optional[RunnableConfig] = None, **kwargs: Any) → Runnable[Input, Output]¶ Bind config to a Runnable, returning a new Runnable. Para...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-29
exceptions will not be passed to fallbacks. If used, the base runnable and its fallbacks must accept a dictionary as input. Returns A new Runnable that will try the original runnable, and then each fallback in order, upon failures. Return type RunnableWithFallbacksT[Input, Output] with_listeners(*, on_start: Optional[U...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-30
on_end=fn_end ) chain.invoke(2) Parameters on_start (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) – on_end (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) – on_error (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) – Ret...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
7ac48834f3ca-31
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]]) – ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.base.LLMBashChain.html
30fba74d63fa-0
langchain_experimental.llm_bash.bash.BashProcess¶ class langchain_experimental.llm_bash.bash.BashProcess(strip_newlines: bool = False, return_err_output: bool = False, persistent: bool = False)[source]¶ Wrapper for starting subprocesses. Uses the python built-in subprocesses.run() Persistent processes are not available...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.bash.BashProcess.html
30fba74d63fa-1
Uses regex to remove the command from the output Parameters output (str) – a process’ output string command (str) – the executed command Return type str run(commands: Union[str, List[str]]) → str[source]¶ Run commands in either an existing persistent subprocess or on in a new subprocess environment. Parameters commands...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.bash.BashProcess.html
5b566a64b9f8-0
langchain_experimental.llm_bash.prompt.BashOutputParser¶ class langchain_experimental.llm_bash.prompt.BashOutputParser[source]¶ Bases: BaseOutputParser Parser for bash output. Create a new model by parsing and validating input data from keyword arguments. Raises ValidationError if the input data cannot be parsed to for...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-1
Return type AsyncIterator[Tuple[int, Union[Output, Exception]]] async ainvoke(input: Union[str, BaseMessage], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → T¶ Default implementation of ainvoke, calls invoke from a thread. The default implementation allows usage of async code even if the runnable d...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-2
from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import SystemMessagePromptTemplate from langchain_core.runnables import Runnable from operator import itemgetter prompt = ( SystemMessagePromptTemplate.from_template("You are a nice assistant.") + "{question}" ) llm = FakeStre...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-3
kwargs (Optional[Any]) – Return type AsyncIterator[Output] astream_events(input: Any, config: Optional[RunnableConfig] = None, *, version: Literal['v1', 'v2'], include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Opti...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-4
Below is a table that illustrates some evens that might be emitted by various chains. Metadata fields have been omitted from the table for brevity. Chain definitions have been included after the table. ATTENTION This reference table is for the V2 version of the schema. event name chunk input output on_chat_model_start ...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-5
format_docs: def format_docs(docs: List[Document]) -> str: '''Format the docs.''' return ", ".join([doc.page_content for doc in docs]) format_docs = RunnableLambda(format_docs) some_tool: @tool def some_tool(x: int, y: str) -> dict: '''Some_tool.''' return {"x": x, "y": y} prompt: template = ChatPromptT...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-6
}, ] Parameters input (Any) – The input to the runnable. config (Optional[RunnableConfig]) – The config to use for the runnable. version (Literal['v1', 'v2']) – The version of the schema to use either v2 or v1. Users should use v2. v1 is for backwards compatibility and will be deprecated in 0.4.0. No default will be as...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-7
An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: O...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-8
exclude_tags (Optional[Sequence[str]]) – Exclude logs with these tags. kwargs (Any) – Return type Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]] async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) → AsyncIterator[Output]¶ Default implementation of a...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-9
yielding results as they complete. Parameters inputs (Sequence[Input]) – config (Optional[Union[RunnableConfig, Sequence[RunnableConfig]]]) – return_exceptions (bool) – kwargs (Optional[Any]) – Return type Iterator[Tuple[int, Union[Output, Exception]]] bind(**kwargs: Any) → Runnable[Input, Output]¶ Bind arguments t...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-10
Return type Type[BaseModel] configurable_alternatives(which: ConfigurableField, *, default_key: str = 'default', prefix_keys: bool = False, **kwargs: Union[Runnable[Input, Output], Callable[[], Runnable[Input, Output]]]) → RunnableSerializable[Input, Output]¶ Configure alternatives for runnables that can be set at runt...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-11
max_tokens=ConfigurableField( id="output_token_number", name="Max tokens in the output", description="The maximum number of tokens in the output", ) ) # max_tokens = 20 print( "max_tokens_20: ", model.invoke("tell me something about chess").content ) # max_tokens = 200 print("max_tok...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-12
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data deep (bool) – set to True to make a deep copy of the model self (Model) – Returns new model instance Return type Model dict(**kwargs: Any) → Dict¶ Return dict...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-13
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]) –...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-14
in parallel, and other keys. Please refer to the RunnableConfig for more details. Returns The output of the runnable. Return type T classmethod is_lc_serializable() → bool¶ Is this class serializable? Return type bool json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-15
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...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-16
Parse a list of candidate model Generations into a specific format. The return value is parsed from only the first Generation in the result, whichis assumed to be the highest-likelihood Generation. Parameters result (List[Generation]) – A list of Generations to be parsed. The Generations are assumed to be different can...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-17
as_str = RunnableLambda(str) as_json = RunnableLambda(json.loads) def as_bytes(x: Any) -> bytes: return bytes(x, "utf-8") chain = RunnableMap( str=as_str, json=as_json, bytes=RunnableLambda(as_bytes) ) chain.invoke("[1, 2, 3]") # -> {"str": "[1, 2, 3]", "json": [1, 2, 3], "bytes": b"[1, 2, 3]"} json_and...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-18
sequence.invoke(1) await sequence.ainvoke(1) # -> 4 sequence.batch([1, 2, 3]) await sequence.abatch([1, 2, 3]) # -> [4, 6, 8] Parameters others (Union[Runnable[Any, Other], Callable[[Any], Other]]) – name (Optional[str]) – Return type RunnableSerializable[Input, Other] classmethod schema(by_alias: bool = True, ref_te...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-19
Default implementation of transform, which buffers input and then calls stream. Subclasses should override this method if they can start producing output while input is still being generated. Parameters input (Iterator[Input]) – config (Optional[RunnableConfig]) – kwargs (Optional[Any]) – Return type Iterator[Output...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-20
config (Optional[RunnableConfig]) – kwargs (Any) – Return type Runnable[Input, Output] with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,), exception_key: Optional[str] = None) → RunnableWithFallbacksT[Input, Output]¶ Add fallb...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-21
Return type RunnableWithFallbacksT[Input, Output] with_listeners(*, on_start: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_end: Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]] = None, on_error: Optional[Union[Callable[[Run], None], Callable[[Run,...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-22
on_error (Optional[Union[Callable[[Run], None], Callable[[Run, RunnableConfig], None]]]) – Return type Runnable[Input, Output] with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) → Runnable[I...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
5b566a64b9f8-23
output_type (Optional[Type[Output]]) – Return type Runnable[Input, Output] property InputType: Any¶ The type of input this runnable accepts specified as a type annotation. property OutputType: Type[T]¶ The type of output this runnable produces specified as a type annotation. property config_specs: List[ConfigurableFie...
https://api.python.langchain.com/en/latest/llm_bash/langchain_experimental.llm_bash.prompt.BashOutputParser.html
a6ab0fa5d05f-0
langchain_google_community.bigquery.BigQueryLoader¶ class langchain_google_community.bigquery.BigQueryLoader(query: str, project: Optional[str] = None, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, credentials: Optional[Credentials] = None)[source]¶ Load from the Google...
https://api.python.langchain.com/en/latest/bigquery/langchain_google_community.bigquery.BigQueryLoader.html
a6ab0fa5d05f-1
load_and_split([text_splitter]) Load Documents and split into chunks. __init__(query: str, project: Optional[str] = None, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None, credentials: Optional[Credentials] = None)[source]¶ Initialize BigQuery document loader. Parameters qu...
https://api.python.langchain.com/en/latest/bigquery/langchain_google_community.bigquery.BigQueryLoader.html
a6ab0fa5d05f-2
Defaults to RecursiveCharacterTextSplitter. Returns List of Documents. Return type List[Document]
https://api.python.langchain.com/en/latest/bigquery/langchain_google_community.bigquery.BigQueryLoader.html
a32c098a1990-0
langchain_text_splitters.python.PythonCodeTextSplitter¶ class langchain_text_splitters.python.PythonCodeTextSplitter(**kwargs: Any)[source]¶ Attempts to split the text along Python syntax. Initialize a PythonCodeTextSplitter. Methods __init__(**kwargs) Initialize a PythonCodeTextSplitter. atransform_documents(documents...
https://api.python.langchain.com/en/latest/python/langchain_text_splitters.python.PythonCodeTextSplitter.html
a32c098a1990-1
Create documents from a list of texts. Parameters texts (List[str]) – metadatas (Optional[List[dict]]) – Return type List[Document] classmethod from_huggingface_tokenizer(tokenizer: Any, **kwargs: Any) → TextSplitter¶ Text splitter that uses HuggingFace tokenizer to count length. Parameters tokenizer (Any) – kwargs ...
https://api.python.langchain.com/en/latest/python/langchain_text_splitters.python.PythonCodeTextSplitter.html
a32c098a1990-2
Parameters text (str) – Return type List[str] transform_documents(documents: Sequence[Document], **kwargs: Any) → Sequence[Document]¶ Transform sequence of documents by splitting them. Parameters documents (Sequence[Document]) – kwargs (Any) – Return type Sequence[Document]
https://api.python.langchain.com/en/latest/python/langchain_text_splitters.python.PythonCodeTextSplitter.html
1e3aa089c9f1-0
langchain_community.docstore.base.Docstore¶ class langchain_community.docstore.base.Docstore[source]¶ Interface to access to place that stores documents. Methods __init__() delete(ids) Deleting IDs from in memory dictionary. search(search) Search for document. __init__()¶ delete(ids: List) → None[source]¶ Deleting IDs ...
https://api.python.langchain.com/en/latest/docstore/langchain_community.docstore.base.Docstore.html
33570c0bbc64-0
langchain_community.docstore.in_memory.InMemoryDocstore¶ class langchain_community.docstore.in_memory.InMemoryDocstore(_dict: Optional[Dict[str, Document]] = None)[source]¶ Simple in memory docstore in the form of a dict. Initialize with dict. Methods __init__([_dict]) Initialize with dict. add(texts) Add texts to in m...
https://api.python.langchain.com/en/latest/docstore/langchain_community.docstore.in_memory.InMemoryDocstore.html
9688755dd4b5-0
langchain_community.docstore.arbitrary_fn.DocstoreFn¶ class langchain_community.docstore.arbitrary_fn.DocstoreFn(lookup_fn: Callable[[str], Union[Document, str]])[source]¶ Docstore via arbitrary lookup function. This is useful when: it’s expensive to construct an InMemoryDocstore/dict you retrieve documents from remote...
https://api.python.langchain.com/en/latest/docstore/langchain_community.docstore.arbitrary_fn.DocstoreFn.html
4fe34177d037-0
langchain_community.docstore.base.AddableMixin¶ class langchain_community.docstore.base.AddableMixin[source]¶ Mixin class that supports adding texts. Methods __init__() add(texts) Add more documents. __init__()¶ abstract add(texts: Dict[str, Document]) → None[source]¶ Add more documents. Parameters texts (Dict[str, Doc...
https://api.python.langchain.com/en/latest/docstore/langchain_community.docstore.base.AddableMixin.html
c650361c3da8-0
langchain_community.docstore.wikipedia.Wikipedia¶ class langchain_community.docstore.wikipedia.Wikipedia[source]¶ Wikipedia API. Check that wikipedia package is installed. Methods __init__() Check that wikipedia package is installed. delete(ids) Deleting IDs from in memory dictionary. search(search) Try to search for w...
https://api.python.langchain.com/en/latest/docstore/langchain_community.docstore.wikipedia.Wikipedia.html
01e680dec4f4-0
langchain_community.llms.huggingface_hub.HuggingFaceHub¶ class langchain_community.llms.huggingface_hub.HuggingFaceHub[source]¶ Bases: LLM [Deprecated] HuggingFaceHub models. ! This class is deprecated, you should use HuggingFaceEndpoint instead. To use, you should have the huggingface_hub python package installed, an...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-1
param metadata: Optional[Dict[str, Any]] = None¶ Metadata to add to the run trace. param model_kwargs: Optional[dict] = None¶ Keyword arguments to pass to the model. param repo_id: Optional[str] = None¶ Model name to use. If not provided, the default model for the chosen task will be used. param tags: Optional[List[str...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-2
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[Union[...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-3
Return type AsyncIterator[Tuple[int, Union[Output, Exception]]] async agenerate(prompts: List[str], stop: Optional[List[str]] = None, callbacks: Union[List[BaseCallbackHandler], BaseCallbackManager, None, List[Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]]]] = None, *, tags: Optional[Union[List[str], L...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-4
tags (Optional[Union[List[str], List[List[str]]]]) – metadata (Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]) – run_name (Optional[Union[str, List[str]]]) – run_id (Optional[Union[UUID, List[Optional[UUID]]]]) – **kwargs – Returns An LLMResult, which contains a list of candidate Generations for each inputp...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-5
functionality, such as logging or streaming, throughout generation. **kwargs (Any) – Arbitrary additional keyword arguments. These are usually passed to the model provider API call. Returns An LLMResult, which contains a list of candidate Generations for each inputprompt and additional model provider-specific output. R...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-6
Parameters messages (List[BaseMessage]) – stop (Optional[Sequence[str]]) – kwargs (Any) – Return type BaseMessage 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, An...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-7
Return type RunnableSerializable[Any, Any] async astream(input: Union[PromptValue, str, Sequence[Union[BaseMessage, List[str], Tuple[str, str], str, Dict[str, Any]]]], config: Optional[RunnableConfig] = None, *, stop: Optional[List[str]] = None, **kwargs: Any) → AsyncIterator[str]¶ Default implementation of astream, wh...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-8
A child runnable that gets invoked as part of the execution of a parent runnable is assigned its own unique ID. parent_ids: List[str] - The IDs of the parent runnables thatgenerated the event. The root runnable will have an empty list. The order of the parent IDs is from the root to the immediate parent. Only available...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-9
on_tool_end some_tool {“x”: 1, “y”: “2”} on_retriever_start [retriever name] {“query”: “hello”} on_retriever_end [retriever name] {“query”: “hello”} [Document(…), ..] on_prompt_start [template_name] {“question”: “hello”} on_prompt_end [template_name] {“question”: “hello”} ChatPromptValue(messages: [SystemMessage, …]) H...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-10
"event": "on_chain_start", "metadata": {}, "name": "reverse", "tags": [], }, { "data": {"chunk": "olleh"}, "event": "on_chain_stream", "metadata": {}, "name": "reverse", "tags": [], }, { "data": {"output": "olleh"}, "event":...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html
01e680dec4f4-11
of astream_events is built on top of astream_log. Returns An async stream of StreamEvents. Return type AsyncIterator[StreamEvent] Notes async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, with_streamed_output_list: bool = True, include_names: Optional[Sequence[str]] = None, incl...
https://api.python.langchain.com/en/latest/llms/langchain_community.llms.huggingface_hub.HuggingFaceHub.html