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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.