id
stringlengths
14
16
text
stringlengths
4
1.28k
source
stringlengths
54
121
af1f52c14822-18
top_p (Optional[float]) – top_k (Optional[int]) – n (int) – Return type None attribute google_api_key: Optional[str] = None attribute model_name: str = 'models/chat-bison-001' Model name to use. attribute n: int = 1 Number of chat completions to generate for each prompt. Note that the API may not return the full ...
https://api.python.langchain.com/en/latest/modules/chat_models.html
af1f52c14822-19
probability sum is at least top_p. Must be in the closed interval [0.0, 1.0]. class langchain.chat_models.ChatVertexAI(*, cache=None, verbose=None, callbacks=None, callback_manager=None, tags=None, client=None, model_name='chat-bison', temperature=0.0, max_output_tokens=128, top_p=0.95, top_k=40, stop=None, project=Non...
https://api.python.langchain.com/en/latest/modules/chat_models.html
af1f52c14822-20
tags (Optional[List[str]]) – client (_LanguageModel) – model_name (str) – temperature (float) – max_output_tokens (int) – top_p (float) – top_k (int) – stop (Optional[List[str]]) – project (Optional[str]) – location (str) – credentials (Any) – Return type None attribute model_name: str = 'chat-bison' Model ...
https://api.python.langchain.com/en/latest/modules/chat_models.html
16b160b3767c-0
Prompt Templates Prompt template classes. class langchain.prompts.AIMessagePromptTemplate(*, prompt, additional_kwargs=None)[source] Bases: langchain.prompts.chat.BaseStringMessagePromptTemplate Parameters prompt (langchain.prompts.base.StringPromptTemplate) – additional_kwargs (dict) – Return type None format(**kw...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-1
Return type None format(**kwargs)[source] Format the prompt with the inputs. Parameters kwargs (Any) – Any arguments to be passed to the prompt template. Returns A formatted string. Return type str Example: prompt.format(variable1="foo") abstract format_messages(**kwargs)[source] Format kwargs into a list of messages...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-2
Parameters input_variables (List[str]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – Return type None attribute input_variables: List[str] [Required] A list of the names of the variables the prompt template expects. attribute output...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-3
Returns A formatted string. Return type str Example: prompt.format(variable1="foo") abstract format_prompt(**kwargs)[source] Create Chat Messages. Parameters kwargs (Any) – Return type langchain.schema.PromptValue partial(**kwargs)[source] Return a partial of the prompt template. Parameters kwargs (Union[str, Callab...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-4
class langchain.prompts.ChatMessagePromptTemplate(*, prompt, additional_kwargs=None, role)[source] Bases: langchain.prompts.chat.BaseStringMessagePromptTemplate Parameters prompt (langchain.prompts.base.StringPromptTemplate) – additional_kwargs (dict) – role (str) – Return type None attribute role: str [Required] ...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-5
partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – messages (List[Union[langchain.prompts.chat.BaseMessagePromptTemplate, langchain.schema.BaseMessage]]) – Return type None attribute input_variables: List[str] [Required] A list of the names of the variables the prompt template expects. attribute messa...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-6
List[langchain.schema.BaseMessage] classmethod from_messages(messages)[source] Parameters messages (Sequence[Union[langchain.prompts.chat.BaseMessagePromptTemplate, langchain.schema.BaseMessage]]) – Return type langchain.prompts.chat.ChatPromptTemplate classmethod from_role_strings(string_messages)[source] Parameter...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-7
partial(**kwargs)[source] Return a partial of the prompt template. Parameters kwargs (Union[str, Callable[[], str]]) – Return type langchain.prompts.base.BasePromptTemplate save(file_path)[source] Save the prompt. Parameters file_path (Union[pathlib.Path, str]) – Path to directory to save prompt to. Return type None...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-8
input_variables (List[str]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – examples (Optional[List[dict]]) – example_selector (Optional[langchain.prompts.example_selector.base.BaseExampleSelector]) – example_prompt (langchain.prompt...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-9
Either this or examples should be provided. attribute example_separator: str = '\n\n' String separator used to join the prefix, the examples, and suffix. attribute examples: Optional[List[dict]] = None Examples to format into the prompt. Either this or example_selector should be provided. attribute input_variables: L...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-10
dict(**kwargs)[source] Return a dictionary of the prompt. Parameters kwargs (Any) – Return type Dict format(**kwargs)[source] Format the prompt with the inputs. Parameters kwargs (Any) – Any arguments to be passed to the prompt template. Returns A formatted string. Return type str Example: prompt.format(variable1="f...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-11
Parameters input_variables (List[str]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – examples (Optional[List[dict]]) – example_selector (Optional[langchain.prompts.example_selector.base.BaseExampleSelector]) – example_prompt (langc...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-12
ExampleSelector to choose the examples to format into the prompt. Either this or examples should be provided. attribute example_separator: str = '\n\n' String separator used to join the prefix, the examples, and suffix. attribute examples: Optional[List[dict]] = None Examples to format into the prompt. Either this or...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-13
attribute validate_template: bool = True Whether or not to try validating the template. dict(**kwargs)[source] Return a dictionary of the prompt. Parameters kwargs (Any) – Return type Dict format(**kwargs)[source] Format the prompt with the inputs. Parameters kwargs (Any) – Any arguments to be passed to the prompt ...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-14
Parameters kwargs (Any) – Return type langchain.schema.BaseMessage class langchain.prompts.LengthBasedExampleSelector(*, examples, example_prompt, get_text_length=<function _get_length_based>, max_length=2048, example_text_lengths=[])[source] Bases: langchain.prompts.example_selector.base.BaseExampleSelector, pydanti...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-15
A list of the examples that the prompt template expects. attribute get_text_length: Callable[[str], int] = <function _get_length_based> Function to measure prompt length. Defaults to word count. attribute max_length: int = 2048 Max length for the prompt, beyond which examples are cut. add_example(example)[source] Ad...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-16
Bases: langchain.prompts.example_selector.semantic_similarity.SemanticSimilarityExampleSelector ExampleSelector that selects examples based on Max Marginal Relevance. This was shown to improve performance in this paper: https://arxiv.org/pdf/2211.13892.pdf Parameters vectorstore (langchain.vectorstores.base.VectorStore...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-17
the input variables instead of all variables. attribute k: int = 4 Number of examples to select. attribute vectorstore: langchain.vectorstores.base.VectorStore [Required] VectorStore than contains information about examples. classmethod from_examples(examples, embeddings, vectorstore_cls, k=4, input_keys=None, fetch_...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-18
input_keys (Optional[List[str]]) – If provided, the search is based on the input variables instead of all variables. vectorstore_cls_kwargs (Any) – optional kwargs containing url for vector store fetch_k (int) – Returns The ExampleSelector instantiated, backed by a vector store. Return type langchain.prompts.example_s...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-19
format_messages(**kwargs)[source] To a BaseMessage. Parameters kwargs (Any) – Return type List[langchain.schema.BaseMessage] property input_variables: List[str] Input variables for this prompt template. class langchain.prompts.NGramOverlapExampleSelector(*, examples, example_prompt, threshold=- 1.0)[source] Bases: ...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-20
Return type None attribute example_prompt: langchain.prompts.prompt.PromptTemplate [Required] Prompt template used to format the examples. attribute examples: List[dict] [Required] A list of the examples that the prompt template expects. attribute threshold: float = -1.0 Threshold at which algorithm stops. Set to -1...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-21
Return type None select_examples(input_variables)[source] Return list of examples sorted by ngram_overlap_score with input. Descending order. Excludes any examples with ngram_overlap_score less than or equal to threshold. Parameters input_variables (Dict[str, str]) – Return type List[dict] class langchain.prompts.Pip...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-22
Each PromptTemplate will be formatted and then passed to future prompt templates as a variable with the same name as name Parameters input_variables (List[str]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – final_prompt (langchain.pr...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-23
A formatted string. Return type str Example: prompt.format(variable1="foo") format_prompt(**kwargs)[source] Create Chat Messages. Parameters kwargs (Any) – Return type langchain.schema.PromptValue langchain.prompts.Prompt alias of langchain.prompts.prompt.PromptTemplate class langchain.prompts.PromptTemplate(*, inpu...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-24
partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – template (str) – template_format (str) – validate_template (bool) – Return type None attribute input_variables: List[str] [Required] A list of the names of the variables the prompt template expects. attribute template: str [Required] The prompt tem...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-25
prompt.format(variable1="foo") classmethod from_examples(examples, suffix, input_variables, example_separator='\n\n', prefix='', **kwargs)[source] Take examples in list format with prefix and suffix to create a prompt. Intended to be used as a way to dynamically create a prompt from examples. Parameters examples (List...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-26
The final prompt generated. Return type langchain.prompts.prompt.PromptTemplate classmethod from_file(template_file, input_variables, **kwargs)[source] Load a prompt from a file. Parameters template_file (Union[str, pathlib.Path]) – The path to the file containing the prompt template. input_variables (List[str]) – A l...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-27
serialized kwargs. These attributes must be accepted by the constructor. class langchain.prompts.SemanticSimilarityExampleSelector(*, vectorstore, k=4, example_keys=None, input_keys=None)[source] Bases: langchain.prompts.example_selector.base.BaseExampleSelector, pydantic.main.BaseModel Example selector that selects e...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-28
attribute k: int = 4 Number of examples to select. attribute vectorstore: langchain.vectorstores.base.VectorStore [Required] VectorStore than contains information about examples. add_example(example)[source] Add new example to vectorstore. Parameters example (Dict[str, str]) – Return type str classmethod from_examp...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-29
vectorstore_cls (Type[langchain.vectorstores.base.VectorStore]) – A vector store DB interface class, e.g. FAISS. k (int) – Number of examples to select input_keys (Optional[List[str]]) – If provided, the search is based on the input variables instead of all variables. vectorstore_cls_kwargs (Any) – optional kwargs cont...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-30
String prompt should expose the format method, returning a prompt. Parameters input_variables (List[str]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – partial_variables (Mapping[str, Union[str, Callable[[], str]]]) – Return type None format_prompt(**kwargs)[source] Create Chat Messages. Parameter...
https://api.python.langchain.com/en/latest/modules/prompts.html
16b160b3767c-31
Return type langchain.schema.BaseMessage langchain.prompts.load_prompt(path)[source] Unified method for loading a prompt from LangChainHub or local fs. Parameters path (Union[str, pathlib.Path]) – Return type langchain.prompts.base.BasePromptTemplate
https://api.python.langchain.com/en/latest/modules/prompts.html
c45a22bba796-0
Example Selector Logic for selecting examples to include in prompts. class langchain.prompts.example_selector.LengthBasedExampleSelector(*, examples, example_prompt, get_text_length=<function _get_length_based>, max_length=2048, example_text_lengths=[])[source] Bases: langchain.prompts.example_selector.base.BaseExamp...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-1
attribute get_text_length: Callable[[str], int] = <function _get_length_based> Function to measure prompt length. Defaults to word count. attribute max_length: int = 2048 Max length for the prompt, beyond which examples are cut. add_example(example)[source] Add new example to list. Parameters example (Dict[str, str]...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-2
ExampleSelector that selects examples based on Max Marginal Relevance. This was shown to improve performance in this paper: https://arxiv.org/pdf/2211.13892.pdf Parameters vectorstore (langchain.vectorstores.base.VectorStore) – k (int) – example_keys (Optional[List[str]]) – input_keys (Optional[List[str]]) – fetch_...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-3
embeddings (langchain.embeddings.base.Embeddings) – An iniialized embedding API interface, e.g. OpenAIEmbeddings(). vectorstore_cls (Type[langchain.vectorstores.base.VectorStore]) – A vector store DB interface class, e.g. FAISS. k (int) – Number of examples to select input_keys (Optional[List[str]]) – If provided, the ...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-4
Return type List[dict] class langchain.prompts.example_selector.NGramOverlapExampleSelector(*, examples, example_prompt, threshold=- 1.0)[source] Bases: langchain.prompts.example_selector.base.BaseExampleSelector, pydantic.main.BaseModel Select and order examples based on ngram overlap score (sentence_bleu score). htt...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-5
attribute threshold: float = -1.0 Threshold at which algorithm stops. Set to -1.0 by default. For negative threshold: select_examples sorts examples by ngram_overlap_score, but excludes none. For threshold greater than 1.0: select_examples excludes all examples, and returns an empty list. For threshold equal to 0.0: s...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-6
Return type List[dict] class langchain.prompts.example_selector.SemanticSimilarityExampleSelector(*, vectorstore, k=4, example_keys=None, input_keys=None)[source] Bases: langchain.prompts.example_selector.base.BaseExampleSelector, pydantic.main.BaseModel Example selector that selects examples based on SemanticSimilari...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-7
attribute k: int = 4 Number of examples to select. attribute vectorstore: langchain.vectorstores.base.VectorStore [Required] VectorStore than contains information about examples. add_example(example)[source] Add new example to vectorstore. Parameters example (Dict[str, str]) – Return type str classmethod from_examp...
https://api.python.langchain.com/en/latest/modules/example_selector.html
c45a22bba796-8
vectorstore_cls (Type[langchain.vectorstores.base.VectorStore]) – A vector store DB interface class, e.g. FAISS. k (int) – Number of examples to select input_keys (Optional[List[str]]) – If provided, the search is based on the input variables instead of all variables. vectorstore_cls_kwargs (Any) – optional kwargs cont...
https://api.python.langchain.com/en/latest/modules/example_selector.html
f867bb55a9e5-0
Document Transformers Transform documents langchain.document_transformers.get_stateful_documents(documents)[source] Convert a list of documents to a list of documents with state. Parameters documents (Sequence[langchain.schema.Document]) – The documents to convert. Returns A list of documents with state. Return type ...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-1
Embeddings to use for embedding document contents. attribute similarity_fn: Callable = <function cosine_similarity> Similarity function for comparing documents. Function expected to take as input two matrices (List[List[float]]) and return a matrix of scores where higher values indicate greater similarity. attribute s...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-2
Sequence[langchain.schema.Document] Text Splitters Functionality for splitting text. class langchain.text_splitter.TextSplitter(chunk_size=4000, chunk_overlap=200, length_function=<built-in function len>, keep_separator=False, add_start_index=False)[source] Bases: langchain.schema.BaseDocumentTransformer, abc.ABC Int...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-3
Parameters texts (List[str]) – metadatas (Optional[List[dict]]) – Return type List[langchain.schema.Document] split_documents(documents)[source] Split documents. Parameters documents (Iterable[langchain.schema.Document]) – Return type List[langchain.schema.Document] classmethod from_huggingface_tokenizer(tokenizer,...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-4
model_name (Optional[str]) – allowed_special (Union[Literal['all'], typing.AbstractSet[str]]) – disallowed_special (Union[Literal['all'], typing.Collection[str]]) – kwargs (Any) – Return type langchain.text_splitter.TS transform_documents(documents, **kwargs)[source] Transform sequence of documents by splitting th...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-5
Bases: langchain.text_splitter.TextSplitter Implementation of splitting text that looks at characters. Parameters separator (str) – kwargs (Any) – Return type None split_text(text)[source] Split incoming text and return chunks. Parameters text (str) – Return type List[str] class langchain.text_splitter.LineType[sou...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-6
Bases: object Implementation of splitting markdown files based on specified headers. Parameters headers_to_split_on (List[Tuple[str, str]]) – return_each_line (bool) – aggregate_lines_to_chunks(lines)[source] Combine lines with common metadata into chunks :param lines: Line of text / associated header metadata Param...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-7
Bases: object Parameters chunk_overlap (int) – tokens_per_chunk (int) – decode (Callable[[list[int]], str]) – encode (Callable[[str], List[int]]) – Return type None chunk_overlap: int tokens_per_chunk: int decode: Callable[[list[int]], str] encode: Callable[[str], List[int]] langchain.text_splitter.split_text_o...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-8
Implementation of splitting text that looks at tokens. Parameters encoding_name (str) – model_name (Optional[str]) – allowed_special (Union[Literal['all'], AbstractSet[str]]) – disallowed_special (Union[Literal['all'], Collection[str]]) – kwargs (Any) – Return type None split_text(text)[source] Split text into mu...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-9
model_name (str) – tokens_per_chunk (Optional[int]) – kwargs (Any) – Return type None split_text(text)[source] Split text into multiple components. Parameters text (str) – Return type List[str] count_tokens(*, text)[source] Parameters text (str) – Return type int class langchain.text_splitter.Language(value, nam...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-10
RST = 'rst' RUBY = 'ruby' RUST = 'rust' SCALA = 'scala' SWIFT = 'swift' MARKDOWN = 'markdown' LATEX = 'latex' HTML = 'html' SOL = 'sol' class langchain.text_splitter.RecursiveCharacterTextSplitter(separators=None, keep_separator=True, **kwargs)[source] Bases: langchain.text_splitter.TextSplitter Implementatio...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-11
Split text into multiple components. Parameters text (str) – Return type List[str] classmethod from_language(language, **kwargs)[source] Parameters language (langchain.text_splitter.Language) – kwargs (Any) – Return type langchain.text_splitter.RecursiveCharacterTextSplitter static get_separators_for_language(langu...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-12
Split incoming text and return chunks. Parameters text (str) – Return type List[str] class langchain.text_splitter.SpacyTextSplitter(separator='\n\n', pipeline='en_core_web_sm', **kwargs)[source] Bases: langchain.text_splitter.TextSplitter Implementation of splitting text that looks at sentences using Spacy. Paramete...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
f867bb55a9e5-13
Return type None class langchain.text_splitter.MarkdownTextSplitter(**kwargs)[source] Bases: langchain.text_splitter.RecursiveCharacterTextSplitter Attempts to split the text along Markdown-formatted headings. Parameters kwargs (Any) – Return type None class langchain.text_splitter.LatexTextSplitter(**kwargs)[source]...
https://api.python.langchain.com/en/latest/modules/document_transformers.html
e10fb3e7f63f-0
Agents Interface for agents. class langchain.agents.Agent(*, llm_chain, output_parser, allowed_tools=None)[source] Bases: langchain.agents.agent.BaseSingleActionAgent Class responsible for calling the language model and deciding the action. This is driven by an LLMChain. The prompt in the LLMChain MUST include a vari...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-1
async aplan(intermediate_steps, callbacks=None, **kwargs)[source] Given input, decided what to do. Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – Steps the LLM has taken to date, along with observations callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], lang...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-2
Return dictionary representation of agent. Parameters kwargs (Any) – Return type Dict classmethod from_llm_and_tools(llm, tools, callback_manager=None, output_parser=None, **kwargs)[source] Construct an agent from an LLM and tools. Parameters llm (langchain.base_language.BaseLanguageModel) – tools (Sequence[langchai...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-3
Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – kwargs (Any) – Return type Dict[str, Any] plan(intermediate_steps, callbacks=None, **kwargs)[source] Given input, decided what to do. Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – Steps the LLM has tak...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-4
Return response when agent has been stopped due to max iterations. Parameters early_stopping_method (str) – intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – kwargs (Any) – Return type langchain.schema.AgentFinish tool_run_logging_kwargs()[source] Return type Dict abstract property llm_prefix: s...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-5
Bases: langchain.chains.base.Chain Consists of an agent using tools. Parameters memory (Optional[langchain.schema.BaseMemory]) – callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallb...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-6
Return type None attribute agent: Union[BaseSingleActionAgent, BaseMultiActionAgent] [Required] The agent to run for creating a plan and determining actions to take at each step of the execution loop. attribute early_stopping_method: str = 'force' The method to use for early stopping if the agent never returns AgentF...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-7
If a string, the string itself will be sent to the LLM as an observation. If a callable function, the function will be called with the exception as an argument, and the result of that function will be passed to the agentas an observation. attribute max_execution_time: Optional[float] = None The maximum amount of wall ...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-8
The valid tools the agent can call. classmethod from_agent_and_tools(agent, tools, callback_manager=None, **kwargs)[source] Create from agent and tools. Parameters agent (Union[langchain.agents.agent.BaseSingleActionAgent, langchain.agents.agent.BaseMultiActionAgent]) – tools (Sequence[langchain.tools.base.BaseTool])...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-9
save_agent(file_path)[source] Save the underlying agent. Parameters file_path (Union[pathlib.Path, str]) – Return type None class langchain.agents.AgentOutputParser[source] Bases: langchain.schema.BaseOutputParser Return type None abstract parse(text)[source] Parse text into agent action/finish. Parameters text (st...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-10
SELF_ASK_WITH_SEARCH = 'self-ask-with-search' CONVERSATIONAL_REACT_DESCRIPTION = 'conversational-react-description' CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'chat-zero-shot-react-description' CHAT_CONVERSATIONAL_REACT_DESCRIPTION = 'chat-conversational-react-description' STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION = 'str...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-11
Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – Steps the LLM has taken to date, along with observations callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – Callbacks to run. **kwargs – User inputs. kwargs (Any)...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-12
Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – Steps the LLM has taken to date, along with observations callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – Callbacks to run. **kwargs – User inputs. kwargs (Any)...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-13
save(file_path)[source] Save the agent. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the agent to. Return type None Example: .. code-block:: python # If working with agent executor agent.agent.save(file_path=”path/agent.yaml”) tool_run_logging_kwargs()[source] Return type Dict property retur...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-14
along with observations callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – Callbacks to run. **kwargs – User inputs. kwargs (Any) – Returns Action specifying what tool to use. Return type Union[langchain.schema.AgentAction, langchain.schema.A...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-15
langchain.agents.agent.BaseSingleActionAgent get_allowed_tools()[source] Return type Optional[List[str]] abstract plan(intermediate_steps, callbacks=None, **kwargs)[source] Given input, decided what to do. Parameters intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – Steps the LLM has taken to date...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-16
Parameters early_stopping_method (str) – intermediate_steps (List[Tuple[langchain.schema.AgentAction, str]]) – kwargs (Any) – Return type langchain.schema.AgentFinish save(file_path)[source] Save the agent. Parameters file_path (Union[pathlib.Path, str]) – Path to file to save the agent to. Return type None Example...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-17
Bases: langchain.agents.agent.Agent An agent designed to hold a conversation in addition to using tools. Parameters llm_chain (langchain.chains.llm.LLMChain) – output_parser (langchain.agents.agent.AgentOutputParser) – allowed_tools (Optional[List[str]]) – ai_prefix (str) – Return type None attribute ai_prefix: str...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-18
classmethod create_prompt(tools, prefix='Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able t...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-19
help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n\nAssistant has access to the following tools:', suffix='B...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-20
Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix='AI', human_prefix='Human', input_variables=None)[source]
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-21
Create prompt in the style of the zero shot agent. Parameters tools (Sequence[langchain.tools.base.BaseTool]) – List of tools the agent will have access to, used to format the prompt. prefix (str) – String to put before the list of tools. suffix (str) – String to put after the list of tools. ai_prefix (str) – String to...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-22
classmethod from_llm_and_tools(llm, tools, callback_manager=None, output_parser=None, prefix='Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide rang...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-23
topics.\n\nOverall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.\n\nTOOLS:\n------\n...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-24
do not need to use a tool, you MUST use the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix='AI', human_prefix='Human', input_variables=None, **kwargs)[source]
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-25
Construct an agent from an LLM and tools. Parameters llm (langchain.base_language.BaseLanguageModel) – tools (Sequence[langchain.tools.base.BaseTool]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – output_parser (Optional[langchain.agents.agent.AgentOutputParser]) – prefix (str) – su...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-26
Prefix to append the observation with. class langchain.agents.ConversationalChatAgent(*, llm_chain, output_parser=None, allowed_tools=None, template_tool_response="TOOL RESPONSE: \n---------------------\n{observation}\n\nUSER'S INPUT\n--------------------\n\nOkay, so what is the response to my last comment? If using in...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-27
allowed_tools (Optional[List[str]]) – template_tool_response (str) – Return type None attribute output_parser: langchain.agents.agent.AgentOutputParser [Optional] attribute template_tool_response: str = "TOOL RESPONSE: \n---------------------\n{observation}\n\nUSER'S INPUT\n--------------------\n\nOkay, so what is t...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-28
classmethod create_prompt(tools, system_message='Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant i...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-29
can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.', human_message="TOOLS\n------\nAssistant can ask the user to use tools t...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-30
Create a prompt for this class. Parameters tools (Sequence[langchain.tools.base.BaseTool]) – system_message (str) – human_message (str) – input_variables (Optional[List[str]]) – output_parser (Optional[langchain.schema.BaseOutputParser]) – Return type langchain.prompts.base.BasePromptTemplate
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-31
classmethod from_llm_and_tools(llm, tools, callback_manager=None, output_parser=None, system_message='Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a w...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-32
of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.', human_messag...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-33
Construct an agent from an LLM and tools. Parameters llm (langchain.base_language.BaseLanguageModel) – tools (Sequence[langchain.tools.base.BaseTool]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – output_parser (Optional[langchain.agents.agent.AgentOutputParser]) – system_message (st...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-34
Parameters llm_chain (langchain.chains.llm.LLMChain) – output_parser (langchain.agents.agent.AgentOutputParser) – stop (List[str]) – Return type None attribute llm_chain: langchain.chains.llm.LLMChain [Required] attribute output_parser: langchain.agents.agent.AgentOutputParser [Required] attribute stop: List[str] ...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-35
**kwargs – User inputs. kwargs (Any) – Returns Action specifying what tool to use. Return type Union[langchain.schema.AgentAction, langchain.schema.AgentFinish] dict(**kwargs)[source] Return dictionary representation of agent. Parameters kwargs (Any) – Return type Dict plan(intermediate_steps, callbacks=None, **kwar...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-36
Return type Union[langchain.schema.AgentAction, langchain.schema.AgentFinish] tool_run_logging_kwargs()[source] Return type Dict class langchain.agents.MRKLChain(*, memory=None, callbacks=None, callback_manager=None, verbose=None, tags=None, agent, tools, return_intermediate_steps=False, max_iterations=15, max_executi...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-37
callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – callback_manager (Optional[langchain.callbacks.base.BaseCallbackManager]) – verbose (bool) – tags (Optional[List[str]]) – agent (Union[langchain.agents.agent.BaseSingleActionAgent, langcha...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-38
This is intended to be an easy way to get up and running with the MRKL chain. Parameters llm (langchain.base_language.BaseLanguageModel) – The LLM to use as the agent LLM. chains (List[langchain.agents.mrkl.base.ChainConfig]) – The chains the MRKL system has access to. **kwargs – parameters to be passed to initializati...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-39
action_name = "Search", action=search.search, action_description="useful for searching" ), ChainConfig( action_name="Calculator", action=llm_math_chain.run, action_description="useful for doing math" ) ] mrkl = MRKLChain.from_chains(llm, chains) class langchain.agents...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-40
prompt (langchain.prompts.base.BasePromptTemplate) – The prompt for this agent, should support agent_scratchpad as one of the variables. For an easy way to construct this prompt, use OpenAIFunctionsAgent.create_prompt(…) Return type None attribute llm: langchain.base_language.BaseLanguageModel [Required] attribute pro...
https://api.python.langchain.com/en/latest/modules/agents.html
e10fb3e7f63f-41
**kwargs – User inputs. callbacks (Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]]) – kwargs (Any) – Returns Action specifying what tool to use. Return type Union[langchain.schema.AgentAction, langchain.schema.AgentFinish] classmethod create_prompt(sys...
https://api.python.langchain.com/en/latest/modules/agents.html