id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 115 |
|---|---|---|
679c2d8e6653-20 | Create a chain from an LLM.
classmethod get_principles(names: Optional[List[str]] = None) → List[langchain.chains.constitutional_ai.models.ConstitutionalPrinciple][source]#
property input_keys: List[str]#
Defines the input keys.
property output_keys: List[str]#
Defines the output keys.
pydantic model langchain.chains.C... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-21 | field retriever: BaseRetriever [Required]#
Index to connect to.
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, retriever: langchain.schema.BaseRetriever, condense_question_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['chat_history', 'question'], output_parser... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-22 | field qa_chain: LLMChain [Required]#
classmethod from_llm(llm: langchain.llms.base.BaseLLM, qa_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['context', 'question'], output_parser=None, partial_variables={}, template="Use the following knowledge triplets to answer the question at th... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-23 | Validators
raise_deprecation » all fields
set_verbose » verbose
field base_embeddings: Embeddings [Required]#
field llm_chain: LLMChain [Required]#
combine_embeddings(embeddings: List[List[float]]) → List[float][source]#
Combine embeddings into final embeddings.
embed_documents(texts: List[str]) → List[List[float]][sou... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-24 | field llm_chain: LLMChain [Required]#
field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no nee... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-25 | [Deprecated]
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=BashOutputParser(), partial_variables={}, template='If someone asks you to perform a task, your job is to come up with a series... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-26 | field prompt: BasePromptTemplate [Required]#
Prompt object to use.
async aapply(input_list: List[Dict[str, Any]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None) → List[Dict[str, str]][source]#
Utilize the LLM generate method for speed... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-27 | Parameters
callbacks – Callbacks to pass to LLMChain
**kwargs – Keys to pass to prompt template.
Returns
Completion from LLM.
Example
completion = llm.predict(adjective="funny")
async apredict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackMa... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-28 | Completion from LLM.
Example
completion = llm.predict(adjective="funny")
predict_and_parse(callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) → Union[str, List[str], Dict[str, str]][source]#
Call predict and then parse the ... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-29 | [Deprecated]
field list_assertions_prompt: PromptTemplate = PromptTemplate(input_variables=['statement'], output_parser=None, partial_variables={}, template='Here is a statement:\n{statement}\nMake a bullet point list of the assumptions you made when producing the above statement.\n\n', template_format='f-string', vali... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-30 | [Deprecated] Prompt to use when questioning the documents.
classmethod from_llm(llm: langchain.llms.base.BaseLLM, create_draft_answer_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='{question}\n\n', template_format='f-str... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-31 | Validators
raise_deprecation » all fields
raise_deprecation » all fields
set_verbose » verbose
field llm: Optional[BaseLanguageModel] = None#
[Deprecated] LLM wrapper to use.
field llm_chain: LLMChain [Required]#
field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-32 | [Deprecated] Prompt to use to translate to python if necessary.
classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Translate a math problem into a expres... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-33 | Example
from langchain import OpenAI, LLMSummarizationCheckerChain
llm = OpenAI(temperature=0.0)
checker_chain = LLMSummarizationCheckerChain.from_llm(llm)
Validators
raise_deprecation » all fields
raise_deprecation » all fields
set_verbose » verbose
field are_all_true_prompt: PromptTemplate = PromptTemplate(input_vari... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-34 | [Deprecated]
field check_assertions_prompt: PromptTemplate = PromptTemplate(input_variables=['assertions'], output_parser=None, partial_variables={}, template='You are an expert fact checker. You have been hired by a major news organization to fact check a very important story.\n\nHere is a bullet point list of facts:\... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-35 | Maximum number of times to check the assertions. Default to double-checking.
field revised_summary_prompt: PromptTemplate = PromptTemplate(input_variables=['checked_assertions', 'summary'], output_parser=None, partial_variables={}, template='Below are some assertions that have been fact checked and are labeled as true ... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-36 | classmethod from_llm(llm: langchain.llms.base.BaseLLM, create_assertions_prompt: langchain.prompts.prompt.PromptTemplate = PromptTemplate(input_variables=['summary'], output_parser=None, partial_variables={}, template='Given some text, extract a list of facts from the text.\n\nFormat your output as a bulleted list.\n\n... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-37 | are some assertions that have been fact checked and are labeled as true of false. If the answer is false, a suggestion is given for a correction.\n\nChecked Assertions:\n"""\n{checked_assertions}\n"""\n\nOriginal Summary:\n"""\n{summary}\n"""\n\nUsing these checked assertions, rewrite the original summary to be comple... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-38 | The sky is blue: True\n- Water is wet: True\n- The sun is a star: True\n"""\nResult: True\n\n===\n\nChecked Assertions: """\n- The sky is blue - True\n- Water is made of lava- False\n- The sun is a star - True\n"""\nResult: False\n\n===\n\nChecked Assertions:"""\n{checked_assertions}\n"""\nResult:', template_format='f-... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-39 | pydantic model langchain.chains.MapReduceChain[source]#
Map-reduce chain.
Validators
raise_deprecation » all fields
set_verbose » verbose
field combine_documents_chain: BaseCombineDocumentsChain [Required]#
Chain to use to combine documents.
field text_splitter: TextSplitter [Required]#
Text splitter to use.
classmetho... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-40 | Chain interacts with an OpenAPI endpoint using natural language.
Validators
raise_deprecation » all fields
set_verbose » verbose
field api_operation: APIOperation [Required]#
field api_request_chain: LLMChain [Required]#
field api_response_chain: Optional[LLMChain] = None#
field param_mapping: _ParamMapping [Required]#... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-41 | set_verbose » verbose
field get_answer_expr: str = 'print(solution())'#
field llm: Optional[BaseLanguageModel] = None#
[Deprecated]
field llm_chain: LLMChain [Required]# | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-42 | field prompt: BasePromptTemplate = PromptTemplate(input_variables=['question'], output_parser=None, partial_variables={}, template='Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\n\n# solution in Python:\n\n\ndef solution():\n """Olivia has $23. She bought five bagels for $... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-43 | end of wednesday?"""\n golf_balls_initial = 58\n golf_balls_lost_tuesday = 23\n golf_balls_lost_wednesday = 2\n golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday\n result = golf_balls_left\n return result\n\n\n\n\n\nQ: There were nine computers in the server ro... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-44 | toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\n\n# solution in Python:\n\n\ndef solution():\n """Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?"""\n toys_initial = 5\n mom_toys = 2\n dad_toys = ... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-45 | = 12\n denny_lollipops = jason_lollipops_initial - jason_lollipops_after\n result = denny_lollipops\n return result\n\n\n\n\n\nQ: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\n\n# solution in Python:\n\n\ndef solution():\n """Leah had 32 chocolate... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-46 | and 2 more cars arrive, how many cars are in the parking lot?"""\n cars_initial = 3\n cars_arrived = 2\n total_cars = cars_initial + cars_arrived\n result = total_cars\n return result\n\n\n\n\n\nQ: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, th... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-47 | [Deprecated]
field python_globals: Optional[Dict[str, Any]] = None#
field python_locals: Optional[Dict[str, Any]] = None#
field return_intermediate_steps: bool = False#
field stop: str = '\n\n'#
classmethod from_colored_object_prompt(llm: langchain.base_language.BaseLanguageModel, **kwargs: Any) → langchain.chains.pal.... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-48 | Chain for question-answering against an index.
Example
from langchain.llms import OpenAI
from langchain.chains import RetrievalQA
from langchain.faiss import FAISS
from langchain.vectorstores.base import VectorStoreRetriever
retriever = VectorStoreRetriever(vectorstore=FAISS(...))
retrievalQA = RetrievalQA.from_llm(llm... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-49 | [Deprecated] LLM wrapper to use.
field llm_chain: LLMChain [Required]#
field prompt: Optional[BasePromptTemplate] = None#
[Deprecated] Prompt to use to translate natural language to SQL.
field return_direct: bool = False#
Whether or not to return the result of querying the SQL table directly.
field return_intermediate_... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-50 | classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, database: langchain.sql_database.SQLDatabase, query_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['input', 'table_info', 'dialect', 'top_k'], output_parser=None, partial_variables={}, template='Given an input ques... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-51 | "SQL Query to run"\nSQLResult: "Result of the SQLQuery"\nAnswer: "Final answer here"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}', template_format='f-string', validate_template=True), decider_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['query', 'tabl... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-52 | Load the necessary chains.
pydantic model langchain.chains.SequentialChain[source]#
Chain where the outputs of one chain feed directly into next.
Validators
raise_deprecation » all fields
set_verbose » verbose
validate_chains » all fields
field chains: List[langchain.chains.base.Chain] [Required]#
field input_variables... | https://python.langchain.com/en/latest/reference/modules/chains.html |
679c2d8e6653-53 | field vectorstore: VectorStore [Required]#
Vector Database to connect to.
pydantic model langchain.chains.VectorDBQAWithSourcesChain[source]#
Question-answering with sources over a vector database.
Validators
raise_deprecation » all fields
set_verbose » verbose
validate_naming » all fields
field k: int = 4#
Number of r... | https://python.langchain.com/en/latest/reference/modules/chains.html |
352d791f3f16-0 | .rst
.pdf
Retrievers
Retrievers#
pydantic model langchain.retrievers.ChatGPTPluginRetriever[source]#
field aiosession: Optional[aiohttp.client.ClientSession] = None#
field bearer_token: str [Required]#
field filter: Optional[dict] = None#
field top_k: int = 3#
field url: str [Required]#
async aget_relevant_documents(qu... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-1 | Parameters
query – string to find relevant documents for
Returns
Sequence of relevant documents
class langchain.retrievers.DataberryRetriever(datastore_url: str, top_k: Optional[int] = None, api_key: Optional[str] = None)[source]#
async aget_relevant_documents(query: str) → List[langchain.schema.Document][source]#
Get ... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-2 | Click “Reset password”
Follow the prompts to reset the password
The format for Elastic Cloud URLs is
https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243.
add_texts(texts: Iterable[str], refresh_indices: bool = True) → List[str][source]#
Run more texts through the embeddings and add to the retriver.
Para... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-3 | Parameters
query – string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.PineconeHybridSearchRetriever[source]#
field alpha: float = 0.5#
field embeddings: langchain.embeddings.base.Embeddings [Required]#
field index: Any = None#
field sparse_encoder: Any = None#
f... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-4 | Parameters
query – string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.SVMRetriever[source]#
field embeddings: langchain.embeddings.base.Embeddings [Required]#
field index: Any = None#
field k: int = 4#
field relevancy_threshold: Optional[float] = None#
field tex... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-5 | get_relevant_documents(query: str) → List[langchain.schema.Document][source]#
Get documents relevant for a query.
Parameters
query – string to find relevant documents for
Returns
List of relevant documents
pydantic model langchain.retrievers.TimeWeightedVectorStoreRetriever[source]#
Retriever combining embededing simil... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-6 | get_relevant_documents(query: str) → List[langchain.schema.Document][source]#
Return documents that are relevant to the query.
get_salient_docs(query: str) → Dict[int, Tuple[langchain.schema.Document, float]][source]#
Return documents that are salient to the query.
class langchain.retrievers.VespaRetriever(app: Vespa, ... | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
352d791f3f16-7 | Look up similar documents in Weaviate.
previous
Vector Stores
next
Document Compressors
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/reference/modules/retrievers.html |
54af721a320a-0 | .rst
.pdf
Agents
Agents#
Interface for agents.
pydantic model langchain.agents.Agent[source]#
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 variable called “agent_scratchpad” where the agent can put its
intermediary wor... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-1 | get_allowed_tools() → Set[str][source]#
get_full_inputs(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], **kwargs: Any) → Dict[str, Any][source]#
Create the full inputs for the LLMChain from intermediate steps.
plan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Option... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-2 | field handle_parsing_errors: bool = False#
field max_execution_time: Optional[float] = None#
field max_iterations: Optional[int] = 15#
field return_intermediate_steps: bool = False#
field tools: Sequence[BaseTool] [Required]#
classmethod from_agent_and_tools(agent: Union[langchain.agents.agent.BaseSingleActionAgent, la... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-3 | ZERO_SHOT_REACT_DESCRIPTION = 'zero-shot-react-description'#
pydantic model langchain.agents.BaseMultiActionAgent[source]#
Base Agent class.
abstract async aplan(intermediate_steps: List[Tuple[langchain.schema.AgentAction, str]], callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.ca... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-4 | Save the agent.
Parameters
file_path – Path to file to save the agent to.
Example:
.. code-block:: python
# If working with agent executor
agent.agent.save(file_path=”path/agent.yaml”)
tool_run_logging_kwargs() → Dict[source]#
property return_values: List[str]#
Return values of the agent.
pydantic model langchain.agent... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-5 | Given input, decided what to do.
Parameters
intermediate_steps – Steps the LLM has taken to date,
along with observations
callbacks – Callbacks to run.
**kwargs – User inputs.
Returns
Action specifying what tool to use.
return_stopped_response(early_stopping_method: str, intermediate_steps: List[Tuple[langchain.schema.... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-6 | classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = '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 ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-7 | 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\nAssistant has access to the follo... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-8 | 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None) → langchain.prompts.prompt.PromptTemplate[source]# | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-9 | Create prompt in the style of the zero shot agent.
Parameters
tools – List of tools the agent will have access to, used to format the
prompt.
prefix – String to put before the list of tools.
suffix – String to put after the list of tools.
ai_prefix – String to use before AI output.
human_prefix – String to use before h... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-10 | classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix: str = 'Assistant is a large la... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-11 | receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of 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... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-12 | the format:\n\n```\nThought: Do I need to use a tool? No\n{ai_prefix}: [your response here]\n```', ai_prefix: str = 'AI', human_prefix: str = 'Human', input_variables: Optional[List[str]] = None, **kwargs: Any) → langchain.agents.agent.Agent[source]# | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-13 | Construct an agent from an LLM and tools.
property llm_prefix: str#
Prefix to append the llm call with.
property observation_prefix: str#
Prefix to append the observation with.
pydantic model langchain.agents.ConversationalChatAgent[source]#
An agent designed to hold a conversation in addition to using tools.
field out... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-14 | field output_parser: AgentOutputParser [Optional]#
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], system_message: str = '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 providin... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-15 | Create a prompt for this class. | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-16 | classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, system_message: str = 'Assistant is a ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-17 | it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range 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 questi... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-18 | Construct an agent from an LLM and tools.
property llm_prefix: str#
Prefix to append the llm call with.
property observation_prefix: str#
Prefix to append the observation with.
pydantic model langchain.agents.LLMSingleActionAgent[source]#
field llm_chain: langchain.chains.llm.LLMChain [Required]#
field output_parser: l... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-19 | Chain that implements the MRKL system.
Example
from langchain import OpenAI, MRKLChain
from langchain.chains.mrkl.base import ChainConfig
llm = OpenAI(temperature=0)
prompt = PromptTemplate(...)
chains = [...]
mrkl = MRKLChain.from_chains(llm=llm, prompt=prompt)
Validators
raise_deprecation » all fields
set_verbose » v... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-20 | from langchain import LLMMathChain, OpenAI, SerpAPIWrapper, MRKLChain
from langchain.chains.mrkl.base import ChainConfig
llm = OpenAI(temperature=0)
search = SerpAPIWrapper()
llm_math_chain = LLMMathChain(llm=llm)
chains = [
ChainConfig(
action_name = "Search",
action=search.search,
action_d... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-21 | Agent for the ReAct TextWorld chain.
field output_parser: langchain.agents.agent.AgentOutputParser [Optional]#
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool]) → langchain.prompts.base.BasePromptTemplate[source]#
Return default prompt.
pydantic model langchain.agents.SelfAskWithSearchChain[sour... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-22 | field output_parser: langchain.agents.agent.AgentOutputParser [Optional]#
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Respond to the human as helpfully and accurately as possible. You have access to the following tools:', suffix: str = 'Begin! Reminder to ALWAYS respond with... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-23 | Create a prompt for this class.
classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.agents.agent.AgentOutputParser] = None, prefix... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-24 | property llm_prefix: str#
Prefix to append the llm call with.
property observation_prefix: str#
Prefix to append the observation with.
pydantic model langchain.agents.Tool[source]#
Tool that takes in function or coroutine directly.
Validators
raise_deprecation » all fields
validate_func_not_partial » func
field corouti... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-25 | Agent for the MRKL chain.
field output_parser: AgentOutputParser [Optional]#
classmethod create_prompt(tools: Sequence[langchain.tools.base.BaseTool], prefix: str = 'Answer the following questions as best you can. You have access to the following tools:', suffix: str = 'Begin!\n\nQuestion: {input}\nThought:{agent_scrat... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-26 | Returns
A PromptTemplate with the template assembled from the pieces here.
classmethod from_llm_and_tools(llm: langchain.base_language.BaseLanguageModel, tools: Sequence[langchain.tools.base.BaseTool], callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, output_parser: Optional[langchain.age... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-27 | langchain.agents.create_json_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.json.toolkit.JsonToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with JSON.\nYour goal is to return a final answer ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-28 | cannot use it.\nYou should only add one key at a time to the path. You cannot add multiple keys at once.\nIf you encounter a "KeyError", go back to the previous key, look at the available keys, and try again.\n\nIf the question does not seem to be related to the JSON, just return "I don\'t know" as the answer.\nAlways ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-29 | = 'Begin!"\n\nQuestion: {input}\nThought: I should look at the keys that exist in data to see what I have access to\n{agent_scratchpad}', format_instructions: str = 'Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-30 | Construct a json agent from an LLM and tools. | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-31 | langchain.agents.create_openapi_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.openapi.toolkit.OpenAPIToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = "You are an agent designed to answer questions by making web requests to an API ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-32 | which parameters are required. For parameters with a fixed set of values, please use the spec to look at which values are allowed.\n\nUse the exact parameter names as listed in the spec, do not make up any names or abbreviate the names of parameters.\nIf you get a not found error, ensure that you are using a path that ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-33 | None, max_iterations: Optional[int] = 15, max_execution_time: Optional[float] = None, early_stopping_method: str = 'force', verbose: bool = False, return_intermediate_steps: bool = False, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]# | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-34 | Construct a json agent from an LLM and tools.
langchain.agents.create_pandas_dataframe_agent(llm: langchain.llms.base.BaseLLM, df: Any, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = '\nYou are working with a pandas dataframe in Python. The name of the dataframe is `df`.\... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-35 | langchain.agents.create_pbi_agent(llm: langchain.llms.base.BaseLLM, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-36 | should first ask which tables I have, then how each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a nice sentence that answers the question. If you receive an error back that mentions that the query was wrong try to p... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-37 | what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input questio... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-38 | Construct a pbi agent from an LLM and tools. | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-39 | langchain.agents.create_pbi_chat_agent(llm: langchain.chat_models.base.BaseChatModel, toolkit: Optional[langchain.agents.agent_toolkits.powerbi.toolkit.PowerBIToolkit], powerbi: Optional[langchain.utilities.powerbi.PowerBIDataset] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, ... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-40 | to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics. \n\nGiven an input question, create a syntactical... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-41 | each table is defined and then ask the question to query tool to create a query for me and then I should ask the query tool to execute it, finally create a complete sentence that answers the question. If you receive an error back that mentions that the query was wrong try to phrase the question differently and get a ne... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-42 | Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]# | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-43 | Construct a pbi agent from an Chat LLM and tools.
If you supply only a toolkit and no powerbi dataset, the same LLM is used for both. | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-44 | langchain.agents.create_sql_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.sql.toolkit.SQLDatabaseToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent designed to interact with a SQL database.\nGiven an input question... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-45 | rewrite the query and try again.\n\nDO NOT make any DML statements (INSERT, UPDATE, DELETE, DROP etc.) to the database.\n\nIf the question does not seem related to the database, just return "I don\'t know" as the answer.\n', suffix: str = 'Begin!\n\nQuestion: {input}\nThought: I should look at the tables in the databas... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-46 | str = 'force', verbose: bool = False, agent_executor_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict[str, Any]) → langchain.agents.agent.AgentExecutor[source]# | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-47 | Construct a sql agent from an LLM and tools.
langchain.agents.create_vectorstore_agent(llm: langchain.llms.base.BaseLLM, toolkit: langchain.agents.agent_toolkits.vectorstore.toolkit.VectorStoreToolkit, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, prefix: str = 'You are an agent desig... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-48 | Construct a vectorstore router agent from an LLM and tools.
langchain.agents.get_all_tool_names() → List[str][source]#
Get a list of all possible tool names.
langchain.agents.initialize_agent(tools: Sequence[langchain.tools.base.BaseTool], llm: langchain.base_language.BaseLanguageModel, agent: Optional[langchain.agents... | https://python.langchain.com/en/latest/reference/modules/agents.html |
54af721a320a-49 | Load tools based on their name.
Parameters
tool_names – name of tools to load.
llm – Optional language model, may be needed to initialize certain tools.
callback_manager – Optional callback manager. If not provided, default global callback manager will be used.
Returns
List of tools.
langchain.agents.tool(*args: Union[... | https://python.langchain.com/en/latest/reference/modules/agents.html |
70fdaeb2ac0b-0 | .rst
.pdf
Utilities
Utilities#
General utilities.
pydantic model langchain.utilities.ApifyWrapper[source]#
Wrapper around Apify.
To use, you should have the apify-client python package installed,
and the environment variable APIFY_API_TOKEN set with your API key, or pass
apify_api_token as a named parameter to the cons... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-1 | Return type
ApifyDatasetLoader
call_actor(actor_id: str, run_input: Dict, dataset_mapping_function: Callable[[Dict], langchain.schema.Document], *, build: Optional[str] = None, memory_mbytes: Optional[int] = None, timeout_secs: Optional[int] = None) → langchain.document_loaders.apify_dataset.ApifyDatasetLoader[source]#... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-2 | ARXIV_MAX_QUERY_LENGTH – the cut limit on the query used for the arxiv tool.
load_max_docs – a limit to the number of loaded documents
load_all_available_meta –
if True: the metadata of the loaded Documents gets all available meta info(see https://lukasschwab.me/arxiv.py/index.html#Result),
if False: the metadata gets... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-3 | Wrapper for Bing Search API.
In order to set this up, follow instructions at:
https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e
field bing_search_url: str [Required]#
field bing_subscription_key: str [Required]#
field k: int = 10#
results(query: str, num_results: int) →... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-4 | A list of dictionaries with the following keys
run(query: str) → str[source]#
pydantic model langchain.utilities.GooglePlacesAPIWrapper[source]#
Wrapper around Google Places API.
To use, you should have the googlemaps python package installed,an API key for the google maps platform,
and the enviroment variable ‘’GPLACE... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-5 | 2. To create an API key:
- Navigate to the APIs & Services→Credentials panel in Cloud Console.
- Select Create credentials, then select API key from the drop-down menu.
- The API key created dialog box displays your newly created key.
- You now have an API_KEY
3. Setup Custom Search Engine so you can search the entire ... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-6 | A list of dictionaries with the following keys
run(query: str) → str[source]#
Run query through GoogleSearch and parse result.
pydantic model langchain.utilities.GoogleSerperAPIWrapper[source]#
Wrapper around the Serper.dev Google Search API.
You can create a free API key at https://serper.dev.
To use, you should have ... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
70fdaeb2ac0b-7 | field owm: Any = None#
run(location: str) → str[source]#
Get the current weather information for a specified location.
pydantic model langchain.utilities.PowerBIDataset[source]#
Create PowerBI engine from dataset ID and credential or token.
Use either the credential or a supplied token to authenticate.
If both are supp... | https://python.langchain.com/en/latest/reference/modules/utilities.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.