id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
343e8c2dfb9d-2
β›“ Using LangChain with DuckDuckGO Wikipedia & PythonREPL Tools β›“ Building Custom Tools and Agents with LangChain (gpt-3.5-turbo) β›“ LangChain Retrieval QA Over Multiple Files with ChromaDB β›“ LangChain Retrieval QA with Instructor Embeddings & ChromaDB for PDFs β›“ LangChain + Retrieval Local LLMs for Retrieval QA - No OpenAI!!! # LangChain by Prompt Engineering: LangChain Crash Course β€” All You Need to Know to Build Powerful Apps with LLMs Working with MULTIPLE PDF Files in LangChain: ChatGPT for your Data ChatGPT for YOUR OWN PDF files with LangChain Talk to YOUR DATA without OpenAI APIs: LangChain ⛓️ CHATGPT For WEBSITES: Custom ChatBOT # LangChain by Chat with data LangChain Beginner’s Tutorial for Typescript/Javascript GPT-4 Tutorial: How to Chat With Multiple PDF Files (~1000 pages of Tesla’s 10-K Annual Reports) GPT-4 & LangChain Tutorial: How to Chat With A 56-Page PDF Document (w/Pinecone) β›“ LangChain & Supabase Tutorial: How to Build a ChatGPT Chatbot For Your Website # Get SH*T Done with Prompt Engineering and LangChain by Venelin Valkov Getting Started with LangChain: Load Custom Data, Run OpenAI Models, Embeddings and ChatGPT Loaders, Indexes & Vectorstores in LangChain: Question Answering on PDF files with ChatGPT LangChain Models: ChatGPT, Flan Alpaca, OpenAI Embeddings, Prompt Templates & Streaming LangChain Chains: Use ChatGPT to Build Conversational Agents, Summaries and Q&A on Text With LLMs
https://python.langchain.com/en/latest/getting_started/tutorials.html
343e8c2dfb9d-3
Analyze Custom CSV Data with GPT-4 using Langchain β›“ Build ChatGPT Chatbots with LangChain Memory: Understanding and Implementing Memory in Conversations β›“ icon marks a new video [last update 2023-05-15] previous Concepts next Models Contents By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/getting_started/tutorials.html
dde8ccbe81af-0
.md .pdf Installation Contents Official Releases Installing from source Installation# Official Releases# LangChain is available on PyPi, so to it is easily installable with: pip install langchain That will install the bare minimum requirements of LangChain. A lot of the value of LangChain comes when integrating it with various model providers, datastores, etc. By default, the dependencies needed to do that are NOT installed. However, there are two other ways to install LangChain that do bring in those dependencies. To install modules needed for the common LLM providers, run: pip install langchain[llms] To install all modules needed for all integrations, run: pip install langchain[all] Note that if you are using zsh, you’ll need to quote square brackets when passing them as an argument to a command, for example: pip install 'langchain[all]' Installing from source# If you want to install from source, you can do so by cloning the repo and running: pip install -e . previous SQL Question Answering Benchmarking: Chinook next API References Contents Official Releases Installing from source By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/installation.html
3d7df8197c0e-0
.rst .pdf Indexes Indexes# Indexes refer to ways to structure documents so that LLMs can best interact with them. LangChain has a number of modules that help you load, structure, store, and retrieve documents. Docstore Text Splitter Document Loaders Vector Stores Retrievers Document Compressors Document Transformers previous Embeddings next Docstore By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/indexes.html
8c640b026879-0
.rst .pdf Prompts Prompts# The reference guides here all relate to objects for working with Prompts. PromptTemplates Example Selector Output Parsers previous How to serialize prompts next PromptTemplates By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/prompts.html
59b8f739182d-0
.rst .pdf Models Models# LangChain provides interfaces and integrations for a number of different types of models. LLMs Chat Models Embeddings previous API References next Chat Models By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/models.html
2cce72709802-0
.rst .pdf Agents Agents# Reference guide for Agents and associated abstractions. Agents Tools Agent Toolkits previous Memory next Agents By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/agents.html
bc9445ed5abf-0
.rst .pdf Experimental Modules Contents Autonomous Agents Generative Agents Experimental Modules# This module contains experimental modules and reproductions of existing work using LangChain primitives. Autonomous Agents# Here, we document the BabyAGI and AutoGPT classes from the langchain.experimental module. class langchain.experimental.BabyAGI(*, memory: Optional[langchain.schema.BaseMemory] = None, callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None, verbose: bool = None, task_list: collections.deque = None, task_creation_chain: langchain.chains.base.Chain, task_prioritization_chain: langchain.chains.base.Chain, execution_chain: langchain.chains.base.Chain, task_id_counter: int = 1, vectorstore: langchain.vectorstores.base.VectorStore, max_iterations: Optional[int] = None)[source]# Controller model for the BabyAGI agent. model Config[source]# Configuration for this pydantic object. arbitrary_types_allowed = True# execute_task(objective: str, task: str, k: int = 5) β†’ str[source]# Execute a task. classmethod from_llm(llm: langchain.base_language.BaseLanguageModel, vectorstore: langchain.vectorstores.base.VectorStore, verbose: bool = False, task_execution_chain: Optional[langchain.chains.base.Chain] = None, **kwargs: Dict[str, Any]) β†’ langchain.experimental.autonomous_agents.baby_agi.baby_agi.BabyAGI[source]# Initialize the BabyAGI Controller. get_next_task(result: str, task_description: str, objective: str) β†’ List[Dict][source]# Get the next task.
https://python.langchain.com/en/latest/reference/modules/experimental.html
bc9445ed5abf-1
Get the next task. property input_keys: List[str]# Input keys this chain expects. property output_keys: List[str]# Output keys this chain expects. prioritize_tasks(this_task_id: int, objective: str) β†’ List[Dict][source]# Prioritize tasks. class langchain.experimental.AutoGPT(ai_name: str, memory: langchain.vectorstores.base.VectorStoreRetriever, chain: langchain.chains.llm.LLMChain, output_parser: langchain.experimental.autonomous_agents.autogpt.output_parser.BaseAutoGPTOutputParser, tools: List[langchain.tools.base.BaseTool], feedback_tool: Optional[langchain.tools.human.tool.HumanInputRun] = None)[source]# Agent class for interacting with Auto-GPT. Generative Agents# Here, we document the GenerativeAgent and GenerativeAgentMemory classes from the langchain.experimental module. class langchain.experimental.GenerativeAgent(*, name: str, age: Optional[int] = None, traits: str = 'N/A', status: str, memory: langchain.experimental.generative_agents.memory.GenerativeAgentMemory, llm: langchain.base_language.BaseLanguageModel, verbose: bool = False, summary: str = '', summary_refresh_seconds: int = 3600, last_refreshed: datetime.datetime = None, daily_summaries: List[str] = None)[source]# A character with memory and innate characteristics. model Config[source]# Configuration for this pydantic object. arbitrary_types_allowed = True# field age: Optional[int] = None# The optional age of the character. field daily_summaries: List[str] [Optional]# Summary of the events in the plan that the agent took.
https://python.langchain.com/en/latest/reference/modules/experimental.html
bc9445ed5abf-2
Summary of the events in the plan that the agent took. generate_dialogue_response(observation: str, now: Optional[datetime.datetime] = None) β†’ Tuple[bool, str][source]# React to a given observation. generate_reaction(observation: str, now: Optional[datetime.datetime] = None) β†’ Tuple[bool, str][source]# React to a given observation. get_full_header(force_refresh: bool = False, now: Optional[datetime.datetime] = None) β†’ str[source]# Return a full header of the agent’s status, summary, and current time. get_summary(force_refresh: bool = False, now: Optional[datetime.datetime] = None) β†’ str[source]# Return a descriptive summary of the agent. field last_refreshed: datetime.datetime [Optional]# The last time the character’s summary was regenerated. field llm: langchain.base_language.BaseLanguageModel [Required]# The underlying language model. field memory: langchain.experimental.generative_agents.memory.GenerativeAgentMemory [Required]# The memory object that combines relevance, recency, and β€˜importance’. field name: str [Required]# The character’s name. field status: str [Required]# The traits of the character you wish not to change. summarize_related_memories(observation: str) β†’ str[source]# Summarize memories that are most relevant to an observation. field summary: str = ''# Stateful self-summary generated via reflection on the character’s memory. field summary_refresh_seconds: int = 3600# How frequently to re-generate the summary. field traits: str = 'N/A'# Permanent traits to ascribe to the character.
https://python.langchain.com/en/latest/reference/modules/experimental.html
bc9445ed5abf-3
field traits: str = 'N/A'# Permanent traits to ascribe to the character. class langchain.experimental.GenerativeAgentMemory(*, llm: langchain.base_language.BaseLanguageModel, memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever, verbose: bool = False, reflection_threshold: Optional[float] = None, current_plan: List[str] = [], importance_weight: float = 0.15, aggregate_importance: float = 0.0, max_tokens_limit: int = 1200, queries_key: str = 'queries', most_recent_memories_token_key: str = 'recent_memories_token', add_memory_key: str = 'add_memory', relevant_memories_key: str = 'relevant_memories', relevant_memories_simple_key: str = 'relevant_memories_simple', most_recent_memories_key: str = 'most_recent_memories', now_key: str = 'now', reflecting: bool = False)[source]# add_memory(memory_content: str, now: Optional[datetime.datetime] = None) β†’ List[str][source]# Add an observation or memory to the agent’s memory. field aggregate_importance: float = 0.0# Track the sum of the β€˜importance’ of recent memories. Triggers reflection when it reaches reflection_threshold. clear() β†’ None[source]# Clear memory contents. field current_plan: List[str] = []# The current plan of the agent. fetch_memories(observation: str, now: Optional[datetime.datetime] = None) β†’ List[langchain.schema.Document][source]# Fetch related memories. field importance_weight: float = 0.15# How much weight to assign the memory importance. field llm: langchain.base_language.BaseLanguageModel [Required]# The core language model.
https://python.langchain.com/en/latest/reference/modules/experimental.html
bc9445ed5abf-4
The core language model. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Return key-value pairs given the text input to the chain. field memory_retriever: langchain.retrievers.time_weighted_retriever.TimeWeightedVectorStoreRetriever [Required]# The retriever to fetch related memories. property memory_variables: List[str]# Input keys this memory class will load dynamically. pause_to_reflect(now: Optional[datetime.datetime] = None) β†’ List[str][source]# Reflect on recent observations and generate β€˜insights’. field reflection_threshold: Optional[float] = None# When aggregate_importance exceeds reflection_threshold, stop to reflect. save_context(inputs: Dict[str, Any], outputs: Dict[str, Any]) β†’ None[source]# Save the context of this model run to memory. previous Utilities next Integrations Contents Autonomous Agents Generative Agents By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/experimental.html
208b595ffd27-0
.rst .pdf Memory Memory# class langchain.memory.CassandraChatMessageHistory(contact_points: List[str], session_id: str, port: int = 9042, username: str = 'cassandra', password: str = 'cassandra', keyspace_name: str = 'chat_history', table_name: str = 'message_store')[source]# Chat message history that stores history in Cassandra. :param contact_points: list of ips to connect to Cassandra cluster :param session_id: arbitrary key that is used to store the messages of a single chat session. Parameters port – port to connect to Cassandra cluster username – username to connect to Cassandra cluster password – password to connect to Cassandra cluster keyspace_name – name of the keyspace to use table_name – name of the table to use add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in Cassandra clear() β†’ None[source]# Clear session memory from Cassandra property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from Cassandra pydantic model langchain.memory.ChatMessageHistory[source]# field messages: List[langchain.schema.BaseMessage] = []# add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store clear() β†’ None[source]# Remove all messages from the store pydantic model langchain.memory.CombinedMemory[source]# Class for combining multiple memories’ data together. Validators check_input_key Β» memories check_repeated_memory_variable Β» memories
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-1
Validators check_input_key Β» memories check_repeated_memory_variable Β» memories field memories: List[langchain.schema.BaseMemory] [Required]# For tracking all the memories that should be accessed. clear() β†’ None[source]# Clear context from this session for every memory. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Load all vars from sub-memories. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this session for every memory. property memory_variables: List[str]# All the memory variables that this instance provides. pydantic model langchain.memory.ConversationBufferMemory[source]# Buffer for storing conversation memory. field ai_prefix: str = 'AI'# field human_prefix: str = 'Human'# load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. property buffer: Any# String buffer of memory. pydantic model langchain.memory.ConversationBufferWindowMemory[source]# Buffer for storing conversation memory. field ai_prefix: str = 'AI'# field human_prefix: str = 'Human'# field k: int = 5# load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Return history buffer. property buffer: List[langchain.schema.BaseMessage]# String buffer of memory. pydantic model langchain.memory.ConversationEntityMemory[source]# Entity extractor & summarizer to memory. field ai_prefix: str = 'AI'# field chat_history_key: str = 'history'# field entity_cache: List[str] = []#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-2
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last line of conversation. As a guideline, a proper noun is generally capitalized. You should definitely extract all names and places.\n\nThe conversation history is provided just in case of a coreference (e.g. "What do you know about him" where "him" is defined in a previous line) -- ignore items mentioned there that are not in the last line.\n\nReturn the output as a single comma-separated list, or NONE if there is nothing of note to return (e.g. the user is just issuing a greeting or having a simple conversation).\n\nEXAMPLE\nConversation history:\nPerson #1: how\'s it going today?\nAI: "It\'s going great! How about you?"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: "That sounds like a lot of work! What kind of things are you
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-3
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\'s it going today?\nAI: "It\'s going great! How about you?"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: "That sounds like a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff. I\'m working with Person #2.\nOutput: Langchain, Person #2\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:', template_format='f-string', validate_template=True)#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-4
field entity_store: langchain.memory.entity.BaseEntityStore [Optional]# field entity_summarization_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['entity', 'summary', 'history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant helping a human keep track of facts about relevant people, places, and concepts in their life. Update the summary of the provided entity in the "Entity" section based on the last line of your conversation with the human. If you are writing the summary for the first time, return a single sentence.\nThe update should only include facts that are relayed in the last line of conversation about the provided entity, and should only contain facts about the provided entity.\n\nIf there is no new information about the provided entity or the information is not worth noting (not an important or relevant fact to remember long-term), return the existing summary unchanged.\n\nFull conversation history (for context):\n{history}\n\nEntity to summarize:\n{entity}\n\nExisting summary of {entity}:\n{summary}\n\nLast line of conversation:\nHuman: {input}\nUpdated summary:', template_format='f-string', validate_template=True)# field human_prefix: str = 'Human'# field k: int = 3# field llm: langchain.base_language.BaseLanguageModel [Required]# clear() β†’ None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. property buffer: List[langchain.schema.BaseMessage]# pydantic model langchain.memory.ConversationKGMemory[source]# Knowledge graph memory for storing conversation memory.
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-5
Knowledge graph memory for storing conversation memory. Integrates with external knowledge graph to store and retrieve information about knowledge triples in the conversation. field ai_prefix: str = 'AI'#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-6
field entity_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template='You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last line of conversation. As a guideline, a proper noun is generally capitalized. You should definitely extract all names and places.\n\nThe conversation history is provided just in case of a coreference (e.g. "What do you know about him" where "him" is defined in a previous line) -- ignore items mentioned there that are not in the last line.\n\nReturn the output as a single comma-separated list, or NONE if there is nothing of note to return (e.g. the user is just issuing a greeting or having a simple conversation).\n\nEXAMPLE\nConversation history:\nPerson #1: how\'s it going today?\nAI: "It\'s going great! How about you?"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: "That sounds like a lot of work! What kind of things are you
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-7
a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how\'s it going today?\nAI: "It\'s going great! How about you?"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: "That sounds like a lot of work! What kind of things are you doing to make Langchain better?"\nLast line:\nPerson #1: i\'m trying to improve Langchain\'s interfaces, the UX, its integrations with various products the user might want ... a lot of stuff. I\'m working with Person #2.\nOutput: Langchain, Person #2\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:', template_format='f-string', validate_template=True)#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-8
field human_prefix: str = 'Human'# field k: int = 2# field kg: langchain.graphs.networkx_graph.NetworkxEntityGraph [Optional]#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-9
field knowledge_extraction_prompt: langchain.prompts.base.BasePromptTemplate = PromptTemplate(input_variables=['history', 'input'], output_parser=None, partial_variables={}, template="You are a networked intelligence helping a human track knowledge triples about all relevant people, things, concepts, etc. and integrating them with your knowledge stored within your weights as well as that stored in a knowledge graph. Extract all of the knowledge triples from the last line of conversation. A knowledge triple is a clause that contains a subject, a predicate, and an object. The subject is the entity being described, the predicate is the property of the subject that is being described, and the object is the value of the property.\n\nEXAMPLE\nConversation history:\nPerson #1: Did you hear aliens landed in Area 51?\nAI: No, I didn't hear that. What do you know about Area 51?\nPerson #1: It's a secret military base in Nevada.\nAI: What do you know about Nevada?\nLast line of conversation:\nPerson #1: It's a state in the US. It's also the number 1 producer of gold in
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-10
It's also the number 1 producer of gold in the US.\n\nOutput: (Nevada, is a, state)<|>(Nevada, is in, US)<|>(Nevada, is the number 1 producer of, gold)\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: Hello.\nAI: Hi! How are you?\nPerson #1: I'm good. How are you?\nAI: I'm good too.\nLast line of conversation:\nPerson #1: I'm going to the store.\n\nOutput: NONE\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: What do you know about Descartes?\nAI: Descartes was a French philosopher, mathematician, and scientist who lived in the 17th century.\nPerson #1: The Descartes I'm referring to is a standup comedian and interior designer from Montreal.\nAI: Oh yes, He is a comedian and an interior designer. He has been in the industry for 30 years. His favorite food is baked bean pie.\nLast line of conversation:\nPerson #1: Oh huh. I know Descartes likes to drive antique
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-11
huh. I know Descartes likes to drive antique scooters and play the mandolin.\nOutput: (Descartes, likes to drive, antique scooters)<|>(Descartes, plays, mandolin)\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:", template_format='f-string', validate_template=True)#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-12
field llm: langchain.base_language.BaseLanguageModel [Required]# field summary_message_cls: Type[langchain.schema.BaseMessage] = <class 'langchain.schema.SystemMessage'># Number of previous utterances to include in the context. clear() β†’ None[source]# Clear memory contents. get_current_entities(input_string: str) β†’ List[str][source]# get_knowledge_triplets(input_string: str) β†’ List[langchain.graphs.networkx_graph.KnowledgeTriple][source]# load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. pydantic model langchain.memory.ConversationStringBufferMemory[source]# Buffer for storing conversation memory. field ai_prefix: str = 'AI'# Prefix to use for AI generated responses. field buffer: str = ''# field human_prefix: str = 'Human'# field input_key: Optional[str] = None# field output_key: Optional[str] = None# clear() β†’ None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. property memory_variables: List[str]# Will always return list of memory variables. :meta private: pydantic model langchain.memory.ConversationSummaryBufferMemory[source]# Buffer with summarizer for storing conversation memory. field max_token_limit: int = 2000# field memory_key: str = 'history'# field moving_summary_buffer: str = ''#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-13
field memory_key: str = 'history'# field moving_summary_buffer: str = ''# clear() β†’ None[source]# Clear memory contents. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. prune() β†’ None[source]# Prune buffer if it exceeds max token limit save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. property buffer: List[langchain.schema.BaseMessage]# pydantic model langchain.memory.ConversationSummaryMemory[source]# Conversation summarizer to memory. field buffer: str = ''# clear() β†’ None[source]# Clear memory contents. classmethod from_messages(llm: langchain.base_language.BaseLanguageModel, chat_memory: langchain.schema.BaseChatMessageHistory, *, summarize_step: int = 2, **kwargs: Any) β†’ langchain.memory.summary.ConversationSummaryMemory[source]# load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. pydantic model langchain.memory.ConversationTokenBufferMemory[source]# Buffer for storing conversation memory. field ai_prefix: str = 'AI'# field human_prefix: str = 'Human'# field llm: langchain.base_language.BaseLanguageModel [Required]# field max_token_limit: int = 2000# field memory_key: str = 'history'# load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Any][source]# Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-14
Save context from this conversation to buffer. Pruned. property buffer: List[langchain.schema.BaseMessage]# String buffer of memory. class langchain.memory.CosmosDBChatMessageHistory(cosmos_endpoint: str, cosmos_database: str, cosmos_container: str, session_id: str, user_id: str, credential: Any = None, connection_string: Optional[str] = None, ttl: Optional[int] = None, cosmos_client_kwargs: Optional[dict] = None)[source]# Chat history backed by Azure CosmosDB. add_ai_message(message: str) β†’ None[source]# Add a AI message to the memory. add_user_message(message: str) β†’ None[source]# Add a user message to the memory. clear() β†’ None[source]# Clear session memory from this memory and cosmos. load_messages() β†’ None[source]# Retrieve the messages from Cosmos prepare_cosmos() β†’ None[source]# Prepare the CosmosDB client. Use this function or the context manager to make sure your database is ready. upsert_messages(new_message: Optional[langchain.schema.BaseMessage] = None) β†’ None[source]# Update the cosmosdb item. class langchain.memory.DynamoDBChatMessageHistory(table_name: str, session_id: str)[source]# Chat message history that stores history in AWS DynamoDB. This class expects that a DynamoDB table with name table_name and a partition Key of SessionId is present. Parameters table_name – name of the DynamoDB table session_id – arbitrary key that is used to store the messages of a single chat session. add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-15
add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in DynamoDB clear() β†’ None[source]# Clear session memory from DynamoDB property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from DynamoDB class langchain.memory.FileChatMessageHistory(file_path: str)[source]# Chat message history that stores history in a local file. Parameters file_path – path of the local file to store the messages. add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in the local file clear() β†’ None[source]# Clear session memory from the local file property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from the local file class langchain.memory.InMemoryEntityStore[source]# Basic in-memory entity store. clear() β†’ None[source]# Delete all entities from store. delete(key: str) β†’ None[source]# Delete entity value from store. exists(key: str) β†’ bool[source]# Check if entity exists in store. get(key: str, default: Optional[str] = None) β†’ Optional[str][source]# Get entity value from store. set(key: str, value: Optional[str]) β†’ None[source]# Set entity value in store. store: Dict[str, Optional[str]] = {}#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-16
Set entity value in store. store: Dict[str, Optional[str]] = {}# class langchain.memory.MomentoChatMessageHistory(session_id: str, cache_client: momento.CacheClient, cache_name: str, *, key_prefix: str = 'message_store:', ttl: Optional[timedelta] = None, ensure_cache_exists: bool = True)[source]# Chat message history cache that uses Momento as a backend. See https://gomomento.com/ add_ai_message(message: str) β†’ None[source]# Store an AI message in the cache. Parameters message (str) – The message to store. add_user_message(message: str) β†’ None[source]# Store a user message in the cache. Parameters message (str) – The message to store. clear() β†’ None[source]# Remove the session’s messages from the cache. Raises SdkException – Momento service or network error. Exception – Unexpected response. classmethod from_client_params(session_id: str, cache_name: str, ttl: timedelta, *, configuration: Optional[momento.config.Configuration] = None, auth_token: Optional[str] = None, **kwargs: Any) β†’ MomentoChatMessageHistory[source]# Construct cache from CacheClient parameters. property messages: list[langchain.schema.BaseMessage]# Retrieve the messages from Momento. Raises SdkException – Momento service or network error Exception – Unexpected response Returns List of cached messages Return type list[BaseMessage] class langchain.memory.MongoDBChatMessageHistory(connection_string: str, session_id: str, database_name: str = 'chat_history', collection_name: str = 'message_store')[source]# Chat message history that stores history in MongoDB. Parameters connection_string – connection string to connect to MongoDB session_id – arbitrary key that is used to store the messages
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-17
session_id – arbitrary key that is used to store the messages of a single chat session. database_name – name of the database to use collection_name – name of the collection to use add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in MongoDB clear() β†’ None[source]# Clear session memory from MongoDB property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from MongoDB class langchain.memory.PostgresChatMessageHistory(session_id: str, connection_string: str = 'postgresql://postgres:mypassword@localhost/chat_history', table_name: str = 'message_store')[source]# add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in PostgreSQL clear() β†’ None[source]# Clear session memory from PostgreSQL property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from PostgreSQL pydantic model langchain.memory.ReadOnlySharedMemory[source]# A memory wrapper that is read-only and cannot be changed. field memory: langchain.schema.BaseMemory [Required]# clear() β†’ None[source]# Nothing to clear, got a memory like a vault. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Load memory variables from memory. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Nothing should be saved or changed
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-18
Nothing should be saved or changed property memory_variables: List[str]# Return memory variables. class langchain.memory.RedisChatMessageHistory(session_id: str, url: str = 'redis://localhost:6379/0', key_prefix: str = 'message_store:', ttl: Optional[int] = None)[source]# add_ai_message(message: str) β†’ None[source]# Add an AI message to the store add_user_message(message: str) β†’ None[source]# Add a user message to the store append(message: langchain.schema.BaseMessage) β†’ None[source]# Append the message to the record in Redis clear() β†’ None[source]# Clear session memory from Redis property key: str# Construct the record key to use property messages: List[langchain.schema.BaseMessage]# Retrieve the messages from Redis class langchain.memory.RedisEntityStore(session_id: str = 'default', url: str = 'redis://localhost:6379/0', key_prefix: str = 'memory_store', ttl: Optional[int] = 86400, recall_ttl: Optional[int] = 259200, *args: Any, **kwargs: Any)[source]# Redis-backed Entity store. Entities get a TTL of 1 day by default, and that TTL is extended by 3 days every time the entity is read back. clear() β†’ None[source]# Delete all entities from store. delete(key: str) β†’ None[source]# Delete entity value from store. exists(key: str) β†’ bool[source]# Check if entity exists in store. property full_key_prefix: str# get(key: str, default: Optional[str] = None) β†’ Optional[str][source]# Get entity value from store. key_prefix: str = 'memory_store'# recall_ttl: Optional[int] = 259200#
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-19
recall_ttl: Optional[int] = 259200# redis_client: Any# session_id: str = 'default'# set(key: str, value: Optional[str]) β†’ None[source]# Set entity value in store. ttl: Optional[int] = 86400# pydantic model langchain.memory.SimpleMemory[source]# Simple memory for storing context or other bits of information that shouldn’t ever change between prompts. field memories: Dict[str, Any] = {}# clear() β†’ None[source]# Nothing to clear, got a memory like a vault. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, str][source]# Return key-value pairs given the text input to the chain. If None, return all memories save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Nothing should be saved or changed, my memory is set in stone. property memory_variables: List[str]# Input keys this memory class will load dynamically. pydantic model langchain.memory.VectorStoreRetrieverMemory[source]# Class for a VectorStore-backed memory object. field input_key: Optional[str] = None# Key name to index the inputs to load_memory_variables. field memory_key: str = 'history'# Key name to locate the memories in the result of load_memory_variables. field retriever: langchain.vectorstores.base.VectorStoreRetriever [Required]# VectorStoreRetriever object to connect to. field return_docs: bool = False# Whether or not to return the result of querying the database directly. clear() β†’ None[source]# Nothing to clear. load_memory_variables(inputs: Dict[str, Any]) β†’ Dict[str, Union[List[langchain.schema.Document], str]][source]# Return history buffer.
https://python.langchain.com/en/latest/reference/modules/memory.html
208b595ffd27-20
Return history buffer. save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) β†’ None[source]# Save context from this conversation to buffer. property memory_variables: List[str]# The list of keys emitted from the load_memory_variables method. previous Document Transformers next Agents By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/memory.html
34698d3baa80-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 constructor. field apify_client: Any = None# field apify_client_async: Any = None# async acall_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]# Run an Actor on the Apify platform and wait for results to be ready. Parameters actor_id (str) – The ID or name of the Actor on the Apify platform. run_input (Dict) – The input object of the Actor that you’re trying to run. dataset_mapping_function (Callable) – A function that takes a single dictionary (an Apify dataset item) and converts it to an instance of the Document class. build (str, optional) – Optionally specifies the actor build to run. It can be either a build tag or build number. memory_mbytes (int, optional) – Optional memory limit for the run, in megabytes. timeout_secs (int, optional) – Optional timeout for the run, in seconds. Returns A loader that will fetch the records from theActor run’s default dataset. Return type ApifyDatasetLoader
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-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]# Run an Actor on the Apify platform and wait for results to be ready. Parameters actor_id (str) – The ID or name of the Actor on the Apify platform. run_input (Dict) – The input object of the Actor that you’re trying to run. dataset_mapping_function (Callable) – A function that takes a single dictionary (an Apify dataset item) and converts it to an instance of the Document class. build (str, optional) – Optionally specifies the actor build to run. It can be either a build tag or build number. memory_mbytes (int, optional) – Optional memory limit for the run, in megabytes. timeout_secs (int, optional) – Optional timeout for the run, in seconds. Returns A loader that will fetch the records from theActor run’s default dataset. Return type ApifyDatasetLoader pydantic model langchain.utilities.ArxivAPIWrapper[source]# Wrapper around ArxivAPI. To use, you should have the arxiv python package installed. https://lukasschwab.me/arxiv.py/index.html This wrapper will use the Arxiv API to conduct searches and fetch document summaries. By default, it will return the document summaries of the top-k results. It limits the Document content by doc_content_chars_max. Set doc_content_chars_max=None if you don’t want to limit the content size. Parameters top_k_results – number of the top-scored document used for the arxiv tool
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-2
Parameters top_k_results – number of the top-scored document used for the arxiv tool 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 only the most informative fields. field arxiv_exceptions: Any = None# field doc_content_chars_max: int = 4000# field load_all_available_meta: bool = False# field load_max_docs: int = 100# field top_k_results: int = 3# load(query: str) β†’ List[langchain.schema.Document][source]# Run Arxiv search and get the article texts plus the article meta information. See https://lukasschwab.me/arxiv.py/index.html#Search Returns: a list of documents with the document.page_content in text format run(query: str) β†’ str[source]# Run Arxiv search and get the article meta information. See https://lukasschwab.me/arxiv.py/index.html#Search See https://lukasschwab.me/arxiv.py/index.html#Result It uses only the most informative fields of article meta information. class langchain.utilities.BashProcess(strip_newlines: bool = False, return_err_output: bool = False, persistent: bool = False)[source]# Executes bash commands and returns the output. process_output(output: str, command: str) β†’ str[source]# run(commands: Union[str, List[str]]) β†’ str[source]# Run commands and return final output. pydantic model langchain.utilities.BingSearchAPIWrapper[source]#
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-3
pydantic model langchain.utilities.BingSearchAPIWrapper[source]# 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) β†’ List[Dict][source]# Run query through BingSearch and return metadata. Parameters query – The query to search for. num_results – The number of results to return. Returns snippet - The description of the result. title - The title of the result. link - The link to the result. Return type A list of dictionaries with the following keys run(query: str) β†’ str[source]# Run query through BingSearch and parse result. pydantic model langchain.utilities.DuckDuckGoSearchAPIWrapper[source]# Wrapper for DuckDuckGo Search API. Free and does not require any setup field k: int = 10# field max_results: int = 5# field region: Optional[str] = 'wt-wt'# field safesearch: str = 'moderate'# field time: Optional[str] = 'y'# get_snippets(query: str) β†’ List[str][source]# Run query through DuckDuckGo and return concatenated results. results(query: str, num_results: int) β†’ List[Dict[str, str]][source]# Run query through DuckDuckGo and return metadata. Parameters query – The query to search for. num_results – The number of results to return. Returns snippet - The description of the result.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-4
Returns snippet - The description of the result. title - The title of the result. link - The link to the result. Return type 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 β€˜β€™GPLACES_API_KEY’’ set with your API key , or pass β€˜gplaces_api_key’ as a named parameter to the constructor. By default, this will return the all the results on the input query.You can use the top_k_results argument to limit the number of results. Example from langchain import GooglePlacesAPIWrapper gplaceapi = GooglePlacesAPIWrapper() field gplaces_api_key: Optional[str] = None# field top_k_results: Optional[int] = None# fetch_place_details(place_id: str) β†’ Optional[str][source]# format_place_details(place_details: Dict[str, Any]) β†’ Optional[str][source]# run(query: str) β†’ str[source]# Run Places search and get k number of places that exists that match. pydantic model langchain.utilities.GoogleSearchAPIWrapper[source]# Wrapper for Google Search API. Adapted from: Instructions adapted from https://stackoverflow.com/questions/ 37083058/ programmatically-searching-google-in-python-using-custom-search TODO: DOCS for using it 1. Install google-api-python-client - If you don’t already have a Google account, sign up. - If you have never created a Google APIs Console project, read the Managing Projects page and create a project in the Google API Console. - Install the library using pip install google-api-python-client
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-5
- Install the library using pip install google-api-python-client The current version of the library is 2.70.0 at this time 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 web - Create a custom search engine in this link. - In Sites to search, add any valid URL (i.e. www.stackoverflow.com). - That’s all you have to fill up, the rest doesn’t matter. In the left-side menu, click Edit search engine β†’ {your search engine name} β†’ Setup Set Search the entire web to ON. Remove the URL you added from the list of Sites to search. Under Search engine ID you’ll find the search-engine-ID. 4. Enable the Custom Search API - Navigate to the APIs & Servicesβ†’Dashboard panel in Cloud Console. - Click Enable APIs and Services. - Search for Custom Search API and click on it. - Click Enable. URL for it: https://console.cloud.google.com/apis/library/customsearch.googleapis .com field google_api_key: Optional[str] = None# field google_cse_id: Optional[str] = None# field k: int = 10# field siterestrict: bool = False# results(query: str, num_results: int) β†’ List[Dict][source]# Run query through GoogleSearch and return metadata. Parameters query – The query to search for. num_results – The number of results to return. Returns snippet - The description of the result. title - The title of the result. link - The link to the result.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-6
title - The title of the result. link - The link to the result. Return type 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 the environment variable SERPER_API_KEY set with your API key, or pass serper_api_key as a named parameter to the constructor. Example from langchain import GoogleSerperAPIWrapper google_serper = GoogleSerperAPIWrapper() field aiosession: Optional[aiohttp.client.ClientSession] = None# field gl: str = 'us'# field hl: str = 'en'# field k: int = 10# field serper_api_key: Optional[str] = None# field tbs: Optional[str] = None# field type: Literal['news', 'search', 'places', 'images'] = 'search'# async aresults(query: str, **kwargs: Any) β†’ Dict[source]# Run query through GoogleSearch. async arun(query: str, **kwargs: Any) β†’ str[source]# Run query through GoogleSearch and parse result async. results(query: str, **kwargs: Any) β†’ Dict[source]# Run query through GoogleSearch. run(query: str, **kwargs: Any) β†’ str[source]# Run query through GoogleSearch and parse result. pydantic model langchain.utilities.GraphQLAPIWrapper[source]# Wrapper around GraphQL API. To use, you should have the gql python package installed. This wrapper will use the GraphQL API to conduct queries.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-7
This wrapper will use the GraphQL API to conduct queries. field custom_headers: Optional[Dict[str, str]] = None# field graphql_endpoint: str [Required]# run(query: str) β†’ str[source]# Run a GraphQL query and get the results. pydantic model langchain.utilities.LambdaWrapper[source]# Wrapper for AWS Lambda SDK. Docs for using: pip install boto3 Create a lambda function using the AWS Console or CLI Run aws configure and enter your AWS credentials field awslambda_tool_description: Optional[str] = None# field awslambda_tool_name: Optional[str] = None# field function_name: Optional[str] = None# run(query: str) β†’ str[source]# Invoke Lambda function and parse result. pydantic model langchain.utilities.MetaphorSearchAPIWrapper[source]# Wrapper for Metaphor Search API. field k: int = 10# field metaphor_api_key: str [Required]# results(query: str, num_results: int) β†’ List[Dict][source]# Run query through Metaphor Search and return metadata. Parameters query – The query to search for. num_results – The number of results to return. Returns title - The title of the url - The url author - Author of the content, if applicable. Otherwise, None. date_created - Estimated date created, in YYYY-MM-DD format. Otherwise, None. Return type A list of dictionaries with the following keys async results_async(query: str, num_results: int) β†’ List[Dict][source]# Get results from the Metaphor Search API asynchronously. pydantic model langchain.utilities.OpenWeatherMapAPIWrapper[source]# Wrapper for OpenWeatherMap API using PyOWM. Docs for using:
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-8
Wrapper for OpenWeatherMap API using PyOWM. Docs for using: Go to OpenWeatherMap and sign up for an API key Save your API KEY into OPENWEATHERMAP_API_KEY env variable pip install pyowm field openweathermap_api_key: Optional[str] = None# 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 supplied the credential is used to generate a token. The impersonated_user_name is the UPN of a user to be impersonated. If the model is not RLS enabled, this will be ignored. Validators fix_table_names Β» table_names token_or_credential_present Β» all fields field aiosession: Optional[aiohttp.ClientSession] = None# field credential: Optional[TokenCredential] = None# field dataset_id: str [Required]# field group_id: Optional[str] = None# field impersonated_user_name: Optional[str] = None# field sample_rows_in_table_info: int = 1# Constraints exclusiveMinimum = 0 maximum = 10 field schemas: Dict[str, str] [Optional]# field table_names: List[str] [Required]# field token: Optional[str] = None# async aget_table_info(table_names: Optional[Union[List[str], str]] = None) β†’ str[source]# Get information about specified tables. async arun(command: str) β†’ Any[source]# Execute a DAX command and return the result asynchronously. get_schemas() β†’ str[source]# Get the available schema’s.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-9
get_schemas() β†’ str[source]# Get the available schema’s. get_table_info(table_names: Optional[Union[List[str], str]] = None) β†’ str[source]# Get information about specified tables. get_table_names() β†’ Iterable[str][source]# Get names of tables available. run(command: str) β†’ Any[source]# Execute a DAX command and return a json representing the results. property headers: Dict[str, str]# Get the token. property request_url: str# Get the request url. property table_info: str# Information about all tables in the database. pydantic model langchain.utilities.PythonREPL[source]# Simulates a standalone Python REPL. field globals: Optional[Dict] [Optional] (alias '_globals')# field locals: Optional[Dict] [Optional] (alias '_locals')# run(command: str) β†’ str[source]# Run command with own globals/locals and returns anything printed. pydantic model langchain.utilities.SearxSearchWrapper[source]# Wrapper for Searx API. To use you need to provide the searx host by passing the named parameter searx_host or exporting the environment variable SEARX_HOST. In some situations you might want to disable SSL verification, for example if you are running searx locally. You can do this by passing the named parameter unsecure. You can also pass the host url scheme as http to disable SSL. Example from langchain.utilities import SearxSearchWrapper searx = SearxSearchWrapper(searx_host="http://localhost:8888") Example with SSL disabled:from langchain.utilities import SearxSearchWrapper # note the unsecure parameter is not needed if you pass the url scheme as # http
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-10
# note the unsecure parameter is not needed if you pass the url scheme as # http searx = SearxSearchWrapper(searx_host="http://localhost:8888", unsecure=True) Validators disable_ssl_warnings Β» unsecure validate_params Β» all fields field aiosession: Optional[Any] = None# field categories: Optional[List[str]] = []# field engines: Optional[List[str]] = []# field headers: Optional[dict] = None# field k: int = 10# field params: dict [Optional]# field query_suffix: Optional[str] = ''# field searx_host: str = ''# field unsecure: bool = False# async aresults(query: str, num_results: int, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β†’ List[Dict][source]# Asynchronously query with json results. Uses aiohttp. See results for more info. async arun(query: str, engines: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β†’ str[source]# Asynchronously version of run. results(query: str, num_results: int, engines: Optional[List[str]] = None, categories: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β†’ List[Dict][source]# Run query through Searx API and returns the results with metadata. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. num_results – Limit the number of results to return. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra parameters to pass to the searx API.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-11
**kwargs – extra parameters to pass to the searx API. Returns {snippet: The description of the result. title: The title of the result. link: The link to the result. engines: The engines used for the result. category: Searx category of the result. } Return type Dict with the following keys run(query: str, engines: Optional[List[str]] = None, categories: Optional[List[str]] = None, query_suffix: Optional[str] = '', **kwargs: Any) β†’ str[source]# Run query through Searx API and parse results. You can pass any other params to the searx query API. Parameters query – The query to search for. query_suffix – Extra suffix appended to the query. engines – List of engines to use for the query. categories – List of categories to use for the query. **kwargs – extra parameters to pass to the searx API. Returns The result of the query. Return type str Raises ValueError – If an error occured with the query. Example This will make a query to the qwant engine: from langchain.utilities import SearxSearchWrapper searx = SearxSearchWrapper(searx_host="http://my.searx.host") searx.run("what is the weather in France ?", engine="qwant") # the same result can be achieved using the `!` syntax of searx # to select the engine using `query_suffix` searx.run("what is the weather in France ?", query_suffix="!qwant") pydantic model langchain.utilities.SerpAPIWrapper[source]# Wrapper around SerpAPI. To use, you should have the google-search-results python package installed,
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-12
To use, you should have the google-search-results python package installed, and the environment variable SERPAPI_API_KEY set with your API key, or pass serpapi_api_key as a named parameter to the constructor. Example from langchain import SerpAPIWrapper serpapi = SerpAPIWrapper() field aiosession: Optional[aiohttp.client.ClientSession] = None# field params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}# field serpapi_api_key: Optional[str] = None# async aresults(query: str) β†’ dict[source]# Use aiohttp to run query through SerpAPI and return the results async. async arun(query: str, **kwargs: Any) β†’ str[source]# Run query through SerpAPI and parse result async. get_params(query: str) β†’ Dict[str, str][source]# Get parameters for SerpAPI. results(query: str) β†’ dict[source]# Run query through SerpAPI and return the raw result. run(query: str, **kwargs: Any) β†’ str[source]# Run query through SerpAPI and parse result. class langchain.utilities.SparkSQL(spark_session: Optional[SparkSession] = None, catalog: Optional[str] = None, schema: Optional[str] = None, ignore_tables: Optional[List[str]] = None, include_tables: Optional[List[str]] = None, sample_rows_in_table_info: int = 3)[source]# classmethod from_uri(database_uri: str, engine_args: Optional[dict] = None, **kwargs: Any) β†’ langchain.utilities.spark_sql.SparkSQL[source]# Creating a remote Spark Session via Spark connect. For example: SparkSQL.from_uri(β€œsc://localhost:15002”)
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-13
For example: SparkSQL.from_uri(β€œsc://localhost:15002”) get_table_info(table_names: Optional[List[str]] = None) β†’ str[source]# get_table_info_no_throw(table_names: Optional[List[str]] = None) β†’ str[source]# Get information about specified tables. Follows best practices as specified in: Rajkumar et al, 2022 (https://arxiv.org/abs/2204.00498) If sample_rows_in_table_info, the specified number of sample rows will be appended to each table description. This can increase performance as demonstrated in the paper. get_usable_table_names() β†’ Iterable[str][source]# Get names of tables available. run(command: str, fetch: str = 'all') β†’ str[source]# run_no_throw(command: str, fetch: str = 'all') β†’ str[source]# Execute a SQL command and return a string representing the results. If the statement returns rows, a string of the results is returned. If the statement returns no rows, an empty string is returned. If the statement throws an error, the error message is returned. pydantic model langchain.utilities.TextRequestsWrapper[source]# Lightweight wrapper around requests library. The main purpose of this wrapper is to always return a text output. field aiosession: Optional[aiohttp.client.ClientSession] = None# field headers: Optional[Dict[str, str]] = None# async adelete(url: str, **kwargs: Any) β†’ str[source]# DELETE the URL and return the text asynchronously. async aget(url: str, **kwargs: Any) β†’ str[source]# GET the URL and return the text asynchronously. async apatch(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]#
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-14
PATCH the URL and return the text asynchronously. async apost(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]# POST to the URL and return the text asynchronously. async aput(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]# PUT the URL and return the text asynchronously. delete(url: str, **kwargs: Any) β†’ str[source]# DELETE the URL and return the text. get(url: str, **kwargs: Any) β†’ str[source]# GET the URL and return the text. patch(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]# PATCH the URL and return the text. post(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]# POST to the URL and return the text. put(url: str, data: Dict[str, Any], **kwargs: Any) β†’ str[source]# PUT the URL and return the text. property requests: langchain.requests.Requests# pydantic model langchain.utilities.TwilioAPIWrapper[source]# Sms Client using Twilio. To use, you should have the twilio python package installed, and the environment variables TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_FROM_NUMBER, or pass account_sid, auth_token, and from_number as named parameters to the constructor. Example from langchain.utilities.twilio import TwilioAPIWrapper twilio = TwilioAPIWrapper( account_sid="ACxxx", auth_token="xxx", from_number="+10123456789" ) twilio.run('test', '+12484345508') field account_sid: Optional[str] = None# Twilio account string identifier.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-15
field account_sid: Optional[str] = None# Twilio account string identifier. field auth_token: Optional[str] = None# Twilio auth token. field from_number: Optional[str] = None# A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format, an [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) that is enabled for the type of message you want to send. Phone numbers or [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from Twilio also work here. You cannot, for example, spoof messages from a private cell phone number. If you are using messaging_service_sid, this parameter must be empty. run(body: str, to: str) β†’ str[source]# Run body through Twilio and respond with message sid. Parameters body – The text of the message you want to send. Can be up to 1,600 characters in length. to – The destination phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) format for SMS/MMS or [Channel user address](https://www.twilio.com/docs/sms/channels#channel-addresses) for other 3rd-party channels. pydantic model langchain.utilities.WikipediaAPIWrapper[source]# Wrapper around WikipediaAPI. To use, you should have the wikipedia python package installed. This wrapper will use the Wikipedia API to conduct searches and fetch page summaries. By default, it will return the page summaries of the top-k results.
https://python.langchain.com/en/latest/reference/modules/utilities.html
34698d3baa80-16
fetch page summaries. By default, it will return the page summaries of the top-k results. It limits the Document content by doc_content_chars_max. field doc_content_chars_max: int = 4000# field lang: str = 'en'# field load_all_available_meta: bool = False# field top_k_results: int = 3# load(query: str) β†’ List[langchain.schema.Document][source]# Run Wikipedia search and get the article text plus the meta information. See Returns: a list of documents. run(query: str) β†’ str[source]# Run Wikipedia search and get page summaries. pydantic model langchain.utilities.WolframAlphaAPIWrapper[source]# Wrapper for Wolfram Alpha. Docs for using: Go to wolfram alpha and sign up for a developer account Create an app and get your APP ID Save your APP ID into WOLFRAM_ALPHA_APPID env variable pip install wolframalpha field wolfram_alpha_appid: Optional[str] = None# run(query: str) β†’ str[source]# Run query through WolframAlpha and parse result. previous Agent Toolkits next Experimental Modules By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/utilities.html
f52ed74cb18d-0
.rst .pdf Tools Tools# Core toolkit implementations. pydantic model langchain.tools.AIPluginTool[source]# field api_spec: str [Required]# field args_schema: Type[AIPluginToolSchema] = <class 'langchain.tools.plugin.AIPluginToolSchema'># Pydantic model class to validate and parse the tool’s input arguments. field plugin: AIPlugin [Required]# classmethod from_plugin_url(url: str) β†’ langchain.tools.plugin.AIPluginTool[source]# pydantic model langchain.tools.APIOperation[source]# A model for a single API operation. field base_url: str [Required]# The base URL of the operation. field description: Optional[str] = None# The description of the operation. field method: langchain.tools.openapi.utils.openapi_utils.HTTPVerb [Required]# The HTTP method of the operation. field operation_id: str [Required]# The unique identifier of the operation. field path: str [Required]# The path of the operation. field properties: Sequence[langchain.tools.openapi.utils.api_models.APIProperty] [Required]# field request_body: Optional[langchain.tools.openapi.utils.api_models.APIRequestBody] = None# The request body of the operation. classmethod from_openapi_spec(spec: langchain.tools.openapi.utils.openapi_utils.OpenAPISpec, path: str, method: str) β†’ langchain.tools.openapi.utils.api_models.APIOperation[source]# Create an APIOperation from an OpenAPI spec. classmethod from_openapi_url(spec_url: str, path: str, method: str) β†’ langchain.tools.openapi.utils.api_models.APIOperation[source]# Create an APIOperation from an OpenAPI URL. to_typescript() β†’ str[source]# Get typescript string representation of the operation.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-1
to_typescript() β†’ str[source]# Get typescript string representation of the operation. static ts_type_from_python(type_: Union[str, Type, tuple, None, enum.Enum]) β†’ str[source]# property body_params: List[str]# property path_params: List[str]# property query_params: List[str]# pydantic model langchain.tools.AzureCogsFormRecognizerTool[source]# Tool that queries the Azure Cognitive Services Form Recognizer API. In order to set this up, follow instructions at: https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/get-started-sdks-rest-api?view=form-recog-3.0.0&pivots=programming-language-python pydantic model langchain.tools.AzureCogsImageAnalysisTool[source]# Tool that queries the Azure Cognitive Services Image Analysis API. In order to set this up, follow instructions at: https://learn.microsoft.com/en-us/azure/cognitive-services/computer-vision/quickstarts-sdk/image-analysis-client-library-40 pydantic model langchain.tools.AzureCogsSpeech2TextTool[source]# Tool that queries the Azure Cognitive Services Speech2Text API. In order to set this up, follow instructions at: https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-speech-to-text?pivots=programming-language-python pydantic model langchain.tools.AzureCogsText2SpeechTool[source]# Tool that queries the Azure Cognitive Services Text2Speech API. In order to set this up, follow instructions at: https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-text-to-speech?pivots=programming-language-python pydantic model langchain.tools.BaseTool[source]# Interface LangChain tools must implement.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-2
pydantic model langchain.tools.BaseTool[source]# Interface LangChain tools must implement. field args_schema: Optional[Type[pydantic.main.BaseModel]] = None# Pydantic model class to validate and parse the tool’s input arguments. field callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None# Deprecated. Please use callbacks instead. field callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None# Callbacks to be called during tool execution. field description: str [Required]# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str [Required]# The unique name of the tool that clearly communicates its purpose. field return_direct: bool = False# Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. field verbose: bool = False# Whether to log the tool’s progress. async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) β†’ Any[source]# Run the tool asynchronously. run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None, **kwargs: Any) β†’ Any[source]# Run the tool.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-3
Run the tool. property args: dict# property is_single_input: bool# Whether the tool only accepts a single input. pydantic model langchain.tools.BingSearchResults[source]# Tool that has capability to query the Bing Search API and get back json. field api_wrapper: langchain.utilities.bing_search.BingSearchAPIWrapper [Required]# field num_results: int = 4# pydantic model langchain.tools.BingSearchRun[source]# Tool that adds the capability to query the Bing search API. field api_wrapper: langchain.utilities.bing_search.BingSearchAPIWrapper [Required]# pydantic model langchain.tools.ClickTool[source]# field args_schema: Type[BaseModel] = <class 'langchain.tools.playwright.click.ClickToolInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Click on an element with the given CSS selector'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'click_element'# The unique name of the tool that clearly communicates its purpose. field playwright_strict: bool = False# Whether to employ Playwright’s strict mode when clicking on elements. field playwright_timeout: float = 1000# Timeout (in ms) for Playwright to wait for element to be ready. field visible_only: bool = True# Whether to consider only visible elements. pydantic model langchain.tools.CopyFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.copy.FileCopyInput'># Pydantic model class to validate and parse the tool’s input arguments.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-4
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Create a copy of a file in a specified location'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'copy_file'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.CurrentWebPageTool[source]# field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Returns the URL of the current page'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'current_webpage'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.DeleteFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.delete.FileDeleteInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Delete a file'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'file_delete'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.DuckDuckGoSearchResults[source]# Tool that queries the Duck Duck Go Search API and get back json. field api_wrapper: langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper [Optional]# field num_results: int = 4#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-5
field num_results: int = 4# pydantic model langchain.tools.DuckDuckGoSearchRun[source]# Tool that adds the capability to query the DuckDuckGo search API. field api_wrapper: langchain.utilities.duckduckgo_search.DuckDuckGoSearchAPIWrapper [Optional]# pydantic model langchain.tools.ExtractHyperlinksTool[source]# Extract all hyperlinks on the page. field args_schema: Type[BaseModel] = <class 'langchain.tools.playwright.extract_hyperlinks.ExtractHyperlinksToolInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Extract all hyperlinks on the current webpage'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'extract_hyperlinks'# The unique name of the tool that clearly communicates its purpose. static scrape_page(page: Any, html_content: str, absolute_urls: bool) β†’ str[source]# pydantic model langchain.tools.ExtractTextTool[source]# field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Extract all the text on the current webpage'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'extract_text'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.FileSearchTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.file_search.FileSearchInput'>#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-6
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Recursively search for files in a subdirectory that match the regex pattern'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'file_search'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GetElementsTool[source]# field args_schema: Type[BaseModel] = <class 'langchain.tools.playwright.get_elements.GetElementsToolInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Retrieve elements in the current web page matching the given CSS selector'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'get_elements'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailCreateDraft[source]# field args_schema: Type[langchain.tools.gmail.create_draft.CreateDraftSchema] = <class 'langchain.tools.gmail.create_draft.CreateDraftSchema'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to create a draft email with the provided message fields.'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'create_gmail_draft'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailGetMessage[source]#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-7
pydantic model langchain.tools.GmailGetMessage[source]# field args_schema: Type[langchain.tools.gmail.get_message.SearchArgsSchema] = <class 'langchain.tools.gmail.get_message.SearchArgsSchema'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to fetch an email by message ID. Returns the thread ID, snipet, body, subject, and sender.'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'get_gmail_message'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailGetThread[source]# field args_schema: Type[langchain.tools.gmail.get_thread.GetThreadSchema] = <class 'langchain.tools.gmail.get_thread.GetThreadSchema'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to search for email messages. The input must be a valid Gmail query. The output is a JSON list of messages.'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'get_gmail_thread'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailSearch[source]# field args_schema: Type[langchain.tools.gmail.search.SearchArgsSchema] = <class 'langchain.tools.gmail.search.SearchArgsSchema'># Pydantic model class to validate and parse the tool’s input arguments.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-8
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Use this tool to search for email messages or threads. The input must be a valid Gmail query. The output is a JSON list of the requested resource.'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'search_gmail'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GmailSendMessage[source]# field description: str = 'Use this tool to send email messages. The input is the message, recipents'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'send_gmail_message'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.GooglePlacesTool[source]# Tool that adds the capability to query the Google places API. field api_wrapper: langchain.utilities.google_places_api.GooglePlacesAPIWrapper [Optional]# pydantic model langchain.tools.GoogleSearchResults[source]# Tool that has capability to query the Google Search API and get back json. field api_wrapper: langchain.utilities.google_search.GoogleSearchAPIWrapper [Required]# field num_results: int = 4# pydantic model langchain.tools.GoogleSearchRun[source]# Tool that adds the capability to query the Google search API. field api_wrapper: langchain.utilities.google_search.GoogleSearchAPIWrapper [Required]# pydantic model langchain.tools.GoogleSerperResults[source]# Tool that has capability to query the Serper.dev Google Search API and get back json.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-9
Tool that has capability to query the Serper.dev Google Search API and get back json. field api_wrapper: langchain.utilities.google_serper.GoogleSerperAPIWrapper [Optional]# pydantic model langchain.tools.GoogleSerperRun[source]# Tool that adds the capability to query the Serper.dev Google search API. field api_wrapper: langchain.utilities.google_serper.GoogleSerperAPIWrapper [Required]# pydantic model langchain.tools.HumanInputRun[source]# Tool that adds the capability to ask user for input. field input_func: Callable [Optional]# field prompt_func: Callable[[str], None] [Optional]# pydantic model langchain.tools.IFTTTWebhook[source]# IFTTT Webhook. Parameters name – name of the tool description – description of the tool url – url to hit with the json event. field url: str [Required]# pydantic model langchain.tools.InfoPowerBITool[source]# Tool for getting metadata about a PowerBI Dataset. field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# pydantic model langchain.tools.ListDirectoryTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.list_dir.DirectoryListingInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'List files and directories in a specified folder'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'list_directory'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.ListPowerBITool[source]# Tool for getting tables names.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-10
Tool for getting tables names. field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# pydantic model langchain.tools.MetaphorSearchResults[source]# Tool that has capability to query the Metaphor Search API and get back json. field api_wrapper: langchain.utilities.metaphor_search.MetaphorSearchAPIWrapper [Required]# pydantic model langchain.tools.MoveFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.move.FileMoveInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Move or rename a file from one location to another'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'move_file'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.NavigateBackTool[source]# Navigate back to the previous page in the browser history. field args_schema: Type[BaseModel] = <class 'pydantic.main.BaseModel'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Navigate back to the previous page in the browser history'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'previous_webpage'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.NavigateTool[source]# field args_schema: Type[BaseModel] = <class 'langchain.tools.playwright.navigate.NavigateToolInput'>#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-11
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Navigate a browser to the specified URL'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'navigate_browser'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.OpenAPISpec[source]# OpenAPI Model that removes misformatted parts of the spec. classmethod from_file(path: Union[str, pathlib.Path]) β†’ langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# Get an OpenAPI spec from a file path. classmethod from_spec_dict(spec_dict: dict) β†’ langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# Get an OpenAPI spec from a dict. classmethod from_text(text: str) β†’ langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# Get an OpenAPI spec from a text. classmethod from_url(url: str) β†’ langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# Get an OpenAPI spec from a URL. static get_cleaned_operation_id(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation, path: str, method: str) β†’ str[source]# Get a cleaned operation id from an operation id. get_methods_for_path(path: str) β†’ List[str][source]# Return a list of valid methods for the specified path. get_operation(path: str, method: str) β†’ openapi_schema_pydantic.v3.v3_1_0.operation.Operation[source]# Get the operation object for a given path and HTTP method.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-12
Get the operation object for a given path and HTTP method. get_parameters_for_operation(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation) β†’ List[openapi_schema_pydantic.v3.v3_1_0.parameter.Parameter][source]# Get the components for a given operation. get_referenced_schema(ref: openapi_schema_pydantic.v3.v3_1_0.reference.Reference) β†’ openapi_schema_pydantic.v3.v3_1_0.schema.Schema[source]# Get a schema (or nested reference) or err. get_request_body_for_operation(operation: openapi_schema_pydantic.v3.v3_1_0.operation.Operation) β†’ Optional[openapi_schema_pydantic.v3.v3_1_0.request_body.RequestBody][source]# Get the request body for a given operation. classmethod parse_obj(obj: dict) β†’ langchain.tools.openapi.utils.openapi_utils.OpenAPISpec[source]# property base_url: str# Get the base url. pydantic model langchain.tools.OpenWeatherMapQueryRun[source]# Tool that adds the capability to query using the OpenWeatherMap API. field api_wrapper: langchain.utilities.openweathermap.OpenWeatherMapAPIWrapper [Optional]# pydantic model langchain.tools.QueryPowerBITool[source]# Tool for querying a Power BI Dataset. Validators raise_deprecation Β» all fields validate_llm_chain_input_variables Β» llm_chain
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-13
Validators raise_deprecation Β» all fields validate_llm_chain_input_variables Β» llm_chain field examples: Optional[str] = '\nQuestion: How many rows are in the table <table>?\nDAX: EVALUATE ROW("Number of rows", COUNTROWS(<table>))\n----\nQuestion: How many rows are in the table <table> where <column> is not empty?\nDAX: EVALUATE ROW("Number of rows", COUNTROWS(FILTER(<table>, <table>[<column>] <> "")))\n----\nQuestion: What was the average of <column> in <table>?\nDAX: EVALUATE ROW("Average", AVERAGE(<table>[<column>]))\n----\n'# field llm_chain: langchain.chains.llm.LLMChain [Required]# field max_iterations: int = 5# field powerbi: langchain.utilities.powerbi.PowerBIDataset [Required]# field session_cache: Dict[str, Any] [Optional]#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-14
field template: Optional[str] = '\nAnswer the question below with a DAX query that can be sent to Power BI. DAX queries have a simple syntax comprised of just one required keyword, EVALUATE, and several optional keywords: ORDER BY, START AT, DEFINE, MEASURE, VAR, TABLE, and COLUMN. Each keyword defines a statement used for the duration of the query. Any time < or > are used in the text below it means that those values need to be replaced by table, columns or other things. If the question is not something you can answer with a DAX query, reply with "I cannot answer this" and the question will be escalated to a human.\n\nSome DAX functions return a table instead of a scalar, and must be wrapped in a function that evaluates the table and returns a scalar; unless the table is a single column, single row table, then it is treated as a scalar value. Most DAX functions require one or more arguments, which can include tables, columns, expressions, and values. However, some functions,
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-15
columns, expressions, and values. However, some functions, such as PI, do not require any arguments, but always require parentheses to indicate the null argument. For example, you must always type PI(), not PI. You can also nest functions within other functions. \n\nSome commonly used functions are:\nEVALUATE <table> - At the most basic level, a DAX query is an EVALUATE statement containing a table expression. At least one EVALUATE statement is required, however, a query can contain any number of EVALUATE statements.\nEVALUATE <table> ORDER BY <expression> ASC or DESC - The optional ORDER BY keyword defines one or more expressions used to sort query results. Any expression that can be evaluated for each row of the result is valid.\nEVALUATE <table> ORDER BY <expression> ASC or DESC START AT <value> or <parameter> - The optional START AT keyword is used inside an ORDER BY clause. It defines the value at which the query results begin.\nDEFINE MEASURE | VAR; EVALUATE <table> - The optional DEFINE keyword
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-16
VAR; EVALUATE <table> - The optional DEFINE keyword introduces one or more calculated entity definitions that exist only for the duration of the query. Definitions precede the EVALUATE statement and are valid for all EVALUATE statements in the query. Definitions can be variables, measures, tables1, and columns1. Definitions can reference other definitions that appear before or after the current definition. At least one definition is required if the DEFINE keyword is included in a query.\nMEASURE <table name>[<measure name>] = <scalar expression> - Introduces a measure definition in a DEFINE statement of a DAX query.\nVAR <name> = <expression> - Stores the result of an expression as a named variable, which can then be passed as an argument to other measure expressions. Once resultant values have been calculated for a variable expression, those values do not change, even if the variable is referenced in another expression.\n\nFILTER(<table>,<filter>) - Returns a table that represents a subset of another table or expression, where <filter> is a Boolean expression that is to be
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-17
<filter> is a Boolean expression that is to be evaluated for each row of the table. For example, [Amount] > 0 or [Region] = "France"\nROW(<name>, <expression>) - Returns a table with a single row containing values that result from the expressions given to each column.\nDISTINCT(<column>) - Returns a one-column table that contains the distinct values from the specified column. In other words, duplicate values are removed and only unique values are returned. This function cannot be used to Return values into a cell or column on a worksheet; rather, you nest the DISTINCT function within a formula, to get a list of distinct values that can be passed to another function and then counted, summed, or used for other operations.\nDISTINCT(<table>) - Returns a table by removing duplicate rows from another table or expression.\n\nAggregation functions, names with a A in it, handle booleans and empty strings in appropriate ways, while the same function without A only uses the numeric values in a column. Functions names with an X in it can include a
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-18
Functions names with an X in it can include a expression as an argument, this will be evaluated for each row in the table and the result will be used in the regular function calculation, these are the functions:\nCOUNT(<column>), COUNTA(<column>), COUNTX(<table>,<expression>), COUNTAX(<table>,<expression>), COUNTROWS([<table>]), COUNTBLANK(<column>), DISTINCTCOUNT(<column>), DISTINCTCOUNTNOBLANK (<column>) - these are all variantions of count functions.\nAVERAGE(<column>), AVERAGEA(<column>), AVERAGEX(<table>,<expression>) - these are all variantions of average functions.\nMAX(<column>), MAXA(<column>), MAXX(<table>,<expression>) - these are all variantions of max functions.\nMIN(<column>), MINA(<column>), MINX(<table>,<expression>) - these are all variantions of min functions.\nPRODUCT(<column>), PRODUCTX(<table>,<expression>) - these are all variantions of product functions.\nSUM(<column>), SUMX(<table>,<expression>) - these are all variantions of sum functions.\n\nDate and time functions:\nDATE(year, month, day) - Returns a date value that represents the specified year,
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-19
Returns a date value that represents the specified year, month, and day.\nDATEDIFF(date1, date2, <interval>) - Returns the difference between two date values, in the specified interval, that can be SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.\nDATEVALUE(<date_text>) - Returns a date value that represents the specified date.\nYEAR(<date>), QUARTER(<date>), MONTH(<date>), DAY(<date>), HOUR(<date>), MINUTE(<date>), SECOND(<date>) - Returns the part of the date for the specified date.\n\nFinally, make sure to escape double quotes with a single backslash, and make sure that only table names have single quotes around them, while names of measures or the values of columns that you want to compare against are in escaped double quotes. Newlines are not necessary and can be skipped. The queries are serialized as json and so will have to fit be compliant with json syntax. Sometimes you will get a question, a DAX query and a error, in that case you need to rewrite the DAX query to get
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-20
case you need to rewrite the DAX query to get the correct answer.\n\nThe following tables exist: {tables}\n\nand the schema\'s for some are given here:\n{schemas}\n\nExamples:\n{examples}\n\nQuestion: {tool_input}\nDAX: \n'#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-21
pydantic model langchain.tools.ReadFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.read.ReadFileInput'># Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Read file from disk'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'read_file'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.SceneXplainTool[source]# Tool that adds the capability to explain images. field api_wrapper: langchain.utilities.scenexplain.SceneXplainAPIWrapper [Optional]# pydantic model langchain.tools.ShellTool[source]# Tool to run shell commands. field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.shell.tool.ShellInput'># Schema for input arguments. field description: str = 'Run shell commands on this Linux machine.'# Description of tool. field name: str = 'terminal'# Name of tool. field process: langchain.utilities.bash.BashProcess [Optional]# Bash process to run commands. pydantic model langchain.tools.SteamshipImageGenerationTool[source]# field model_name: ModelName [Required]# field return_urls: Optional[bool] = False# field size: Optional[str] = '512x512'# field steamship: Steamship [Required]# pydantic model langchain.tools.StructuredTool[source]# Tool that can operate on any number of inputs. field args_schema: Type[pydantic.main.BaseModel] [Required]# The input arguments’ schema. The tool schema.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-22
The input arguments’ schema. The tool schema. field coroutine: Optional[Callable[[...], Awaitable[Any]]] = None# The asynchronous version of the function. field description: str = ''# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field func: Callable[[...], Any] [Required]# The function to run when the tool is called. classmethod from_function(func: Callable, name: Optional[str] = None, description: Optional[str] = None, return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, infer_schema: bool = True, **kwargs: Any) β†’ langchain.tools.base.StructuredTool[source]# property args: dict# The tool’s input arguments. pydantic model langchain.tools.Tool[source]# Tool that takes in function or coroutine directly. field args_schema: Optional[Type[pydantic.main.BaseModel]] = None# Pydantic model class to validate and parse the tool’s input arguments. field callback_manager: Optional[langchain.callbacks.base.BaseCallbackManager] = None# Deprecated. Please use callbacks instead. field callbacks: Optional[Union[List[langchain.callbacks.base.BaseCallbackHandler], langchain.callbacks.base.BaseCallbackManager]] = None# Callbacks to be called during tool execution. field coroutine: Optional[Callable[[...], Awaitable[str]]] = None# The asynchronous version of the function. field description: str = ''# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field func: Callable[[...], str] [Required]# The function to run when the tool is called.
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-23
The function to run when the tool is called. field name: str [Required]# The unique name of the tool that clearly communicates its purpose. field return_direct: bool = False# Whether to return the tool’s output directly. Setting this to True means that after the tool is called, the AgentExecutor will stop looping. field verbose: bool = False# Whether to log the tool’s progress. classmethod from_function(func: Callable, name: str, description: str, return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, **kwargs: Any) β†’ langchain.tools.base.Tool[source]# Initialize tool from a function. property args: dict# The tool’s input arguments. pydantic model langchain.tools.VectorStoreQATool[source]# Tool for the VectorDBQA chain. To be initialized with name and chain. static get_description(name: str, description: str) β†’ str[source]# pydantic model langchain.tools.VectorStoreQAWithSourcesTool[source]# Tool for the VectorDBQAWithSources chain. static get_description(name: str, description: str) β†’ str[source]# pydantic model langchain.tools.WikipediaQueryRun[source]# Tool that adds the capability to search using the Wikipedia API. field api_wrapper: langchain.utilities.wikipedia.WikipediaAPIWrapper [Required]# pydantic model langchain.tools.WolframAlphaQueryRun[source]# Tool that adds the capability to query using the Wolfram Alpha SDK. field api_wrapper: langchain.utilities.wolfram_alpha.WolframAlphaAPIWrapper [Required]# pydantic model langchain.tools.WriteFileTool[source]# field args_schema: Type[pydantic.main.BaseModel] = <class 'langchain.tools.file_management.write.WriteFileInput'>#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-24
Pydantic model class to validate and parse the tool’s input arguments. field description: str = 'Write file to disk'# Used to tell the model how/when/why to use the tool. You can provide few-shot examples as a part of the description. field name: str = 'write_file'# The unique name of the tool that clearly communicates its purpose. pydantic model langchain.tools.YouTubeSearchTool[source]# pydantic model langchain.tools.ZapierNLAListActions[source]# Returns a list of all exposed (enabled) actions associated withcurrent user (associated with the set api_key). Change your exposed actions here: https://nla.zapier.com/demo/start/ The return list can be empty if no actions exposed. Else will contain a list of action objects: [{β€œid”: str, β€œdescription”: str, β€œparams”: Dict[str, str] }] params will always contain an instructions key, the only required param. All others optional and if provided will override any AI guesses (see β€œunderstanding the AI guessing flow” here: https://nla.zapier.com/api/v1/docs) Parameters None – field api_wrapper: langchain.utilities.zapier.ZapierNLAWrapper [Optional]# pydantic model langchain.tools.ZapierNLARunAction[source]# Executes an action that is identified by action_id, must be exposed(enabled) by the current user (associated with the set api_key). Change your exposed actions here: https://nla.zapier.com/demo/start/ The return JSON is guaranteed to be less than ~500 words (350 tokens) making it safe to inject into the prompt of another LLM call. Parameters action_id – a specific action ID (from list actions) of the action to execute
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-25
Parameters action_id – a specific action ID (from list actions) of the action to execute (the set api_key must be associated with the action owner) instructions – a natural language instruction string for using the action (eg. β€œget the latest email from Mike Knoop” for β€œGmail: find email” action) params – a dict, optional. Any params provided will override AI guesses from instructions (see β€œunderstanding the AI guessing flow” here: https://nla.zapier.com/api/v1/docs) field action_id: str [Required]# field api_wrapper: langchain.utilities.zapier.ZapierNLAWrapper [Optional]# field base_prompt: str = 'A wrapper around Zapier NLA actions. The input to this tool is a natural language instruction, for example "get the latest email from my bank" or "send a slack message to the #general channel". Each tool will have params associated with it that are specified as a list. You MUST take into account the params when creating the instruction. For example, if the params are [\'Message_Text\', \'Channel\'], your instruction should be something like \'send a slack message to the #general channel with the text hello world\'. Another example: if the params are [\'Calendar\', \'Search_Term\'], your instruction should be something like \'find the meeting in my personal calendar at 3pm\'. Do not make up params, they will be explicitly specified in the tool description. If you do not have enough information to fill in the params, just say \'not enough information provided in the instruction, missing <param>\'. If you get a none or null response, STOP EXECUTION, do not try to another tool!This tool specifically used for: {zapier_description}, and has params: {params}'# field params: Optional[dict] = None#
https://python.langchain.com/en/latest/reference/modules/tools.html
f52ed74cb18d-26
field params: Optional[dict] = None# field params_schema: Dict[str, str] [Optional]# field zapier_description: str [Required]# langchain.tools.tool(*args: Union[str, Callable], return_direct: bool = False, args_schema: Optional[Type[pydantic.main.BaseModel]] = None, infer_schema: bool = True) β†’ Callable[source]# Make tools out of functions, can be used with or without arguments. Parameters *args – The arguments to the tool. return_direct – Whether to return directly from the tool rather than continuing the agent loop. args_schema – optional argument schema for user to specify infer_schema – Whether to infer the schema of the arguments from the function’s signature. This also makes the resultant tool accept a dictionary input to its run() function. Requires: Function must be of type (str) -> str Function must have a docstring Examples @tool def search_api(query: str) -> str: # Searches the API for the query. return @tool("search", return_direct=True) def search_api(query: str) -> str: # Searches the API for the query. return previous Agents next Agent Toolkits By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/tools.html
e9b3ff9f23e4-0
.rst .pdf SerpAPI SerpAPI# For backwards compatiblity. pydantic model langchain.serpapi.SerpAPIWrapper[source]# Wrapper around SerpAPI. To use, you should have the google-search-results python package installed, and the environment variable SERPAPI_API_KEY set with your API key, or pass serpapi_api_key as a named parameter to the constructor. Example from langchain import SerpAPIWrapper serpapi = SerpAPIWrapper() field aiosession: Optional[aiohttp.client.ClientSession] = None# field params: dict = {'engine': 'google', 'gl': 'us', 'google_domain': 'google.com', 'hl': 'en'}# field serpapi_api_key: Optional[str] = None# async aresults(query: str) β†’ dict[source]# Use aiohttp to run query through SerpAPI and return the results async. async arun(query: str, **kwargs: Any) β†’ str[source]# Run query through SerpAPI and parse result async. get_params(query: str) β†’ Dict[str, str][source]# Get parameters for SerpAPI. results(query: str) β†’ dict[source]# Run query through SerpAPI and return the raw result. run(query: str, **kwargs: Any) β†’ str[source]# Run query through SerpAPI and parse result. By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/serpapi.html
2f2363e560c4-0
.rst .pdf PromptTemplates PromptTemplates# Prompt template classes. pydantic model langchain.prompts.BaseChatPromptTemplate[source]# format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") abstract format_messages(**kwargs: Any) β†’ List[langchain.schema.BaseMessage][source]# Format kwargs into a list of messages. format_prompt(**kwargs: Any) β†’ langchain.schema.PromptValue[source]# Create Chat Messages. pydantic model langchain.prompts.BasePromptTemplate[source]# Base class for all prompt templates, returning a prompt. field input_variables: List[str] [Required]# A list of the names of the variables the prompt template expects. field output_parser: Optional[langchain.schema.BaseOutputParser] = None# How to parse the output of calling an LLM on this formatted prompt. dict(**kwargs: Any) β†’ Dict[source]# Return dictionary representation of prompt. abstract format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") abstract format_prompt(**kwargs: Any) β†’ langchain.schema.PromptValue[source]# Create Chat Messages. partial(**kwargs: Union[str, Callable[[], str]]) β†’ langchain.prompts.base.BasePromptTemplate[source]# Return a partial of the prompt template. save(file_path: Union[pathlib.Path, str]) β†’ None[source]# Save the prompt. Parameters file_path – Path to directory to save prompt to. Example: .. code-block:: python
https://python.langchain.com/en/latest/reference/modules/prompts.html
2f2363e560c4-1
file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.ChatPromptTemplate[source]# format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") format_messages(**kwargs: Any) β†’ List[langchain.schema.BaseMessage][source]# Format kwargs into a list of messages. partial(**kwargs: Union[str, Callable[[], str]]) β†’ langchain.prompts.base.BasePromptTemplate[source]# Return a partial of the prompt template. save(file_path: Union[pathlib.Path, str]) β†’ None[source]# Save the prompt. Parameters file_path – Path to directory to save prompt to. Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) pydantic model langchain.prompts.FewShotPromptTemplate[source]# Prompt template that contains few shot examples. field example_prompt: langchain.prompts.prompt.PromptTemplate [Required]# PromptTemplate used to format an individual example. field example_selector: Optional[langchain.prompts.example_selector.base.BaseExampleSelector] = None# ExampleSelector to choose the examples to format into the prompt. Either this or examples should be provided. field example_separator: str = '\n\n'# String separator used to join the prefix, the examples, and suffix. field examples: Optional[List[dict]] = None# Examples to format into the prompt. Either this or example_selector should be provided. field input_variables: List[str] [Required]# A list of the names of the variables the prompt template expects.
https://python.langchain.com/en/latest/reference/modules/prompts.html
2f2363e560c4-2
A list of the names of the variables the prompt template expects. field prefix: str = ''# A prompt template string to put before the examples. field suffix: str [Required]# A prompt template string to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: β€˜f-string’, β€˜jinja2’. field validate_template: bool = True# Whether or not to try validating the template. dict(**kwargs: Any) β†’ Dict[source]# Return a dictionary of the prompt. format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") pydantic model langchain.prompts.FewShotPromptWithTemplates[source]# Prompt template that contains few shot examples. field example_prompt: langchain.prompts.prompt.PromptTemplate [Required]# PromptTemplate used to format an individual example. field example_selector: Optional[langchain.prompts.example_selector.base.BaseExampleSelector] = None# ExampleSelector to choose the examples to format into the prompt. Either this or examples should be provided. field example_separator: str = '\n\n'# String separator used to join the prefix, the examples, and suffix. field examples: Optional[List[dict]] = None# Examples to format into the prompt. Either this or example_selector should be provided. field input_variables: List[str] [Required]# A list of the names of the variables the prompt template expects. field prefix: Optional[langchain.prompts.base.StringPromptTemplate] = None# A PromptTemplate to put before the examples. field suffix: langchain.prompts.base.StringPromptTemplate [Required]#
https://python.langchain.com/en/latest/reference/modules/prompts.html
2f2363e560c4-3
field suffix: langchain.prompts.base.StringPromptTemplate [Required]# A PromptTemplate to put after the examples. field template_format: str = 'f-string'# The format of the prompt template. Options are: β€˜f-string’, β€˜jinja2’. field validate_template: bool = True# Whether or not to try validating the template. dict(**kwargs: Any) β†’ Dict[source]# Return a dictionary of the prompt. format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") pydantic model langchain.prompts.MessagesPlaceholder[source]# Prompt template that assumes variable is already list of messages. format_messages(**kwargs: Any) β†’ List[langchain.schema.BaseMessage][source]# To a BaseMessage. property input_variables: List[str]# Input variables for this prompt template. langchain.prompts.Prompt# alias of langchain.prompts.prompt.PromptTemplate pydantic model langchain.prompts.PromptTemplate[source]# Schema to represent a prompt for an LLM. Example from langchain import PromptTemplate prompt = PromptTemplate(input_variables=["foo"], template="Say {foo}") field input_variables: List[str] [Required]# A list of the names of the variables the prompt template expects. field template: str [Required]# The prompt template. field template_format: str = 'f-string'# The format of the prompt template. Options are: β€˜f-string’, β€˜jinja2’. field validate_template: bool = True# Whether or not to try validating the template. format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters
https://python.langchain.com/en/latest/reference/modules/prompts.html
2f2363e560c4-4
Format the prompt with the inputs. Parameters kwargs – Any arguments to be passed to the prompt template. Returns A formatted string. Example: prompt.format(variable1="foo") classmethod from_examples(examples: List[str], suffix: str, input_variables: List[str], example_separator: str = '\n\n', prefix: str = '', **kwargs: Any) β†’ langchain.prompts.prompt.PromptTemplate[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 of examples to use in the prompt. suffix – String to go after the list of examples. Should generally set up the user’s input. input_variables – A list of variable names the final prompt template will expect. example_separator – The separator to use in between examples. Defaults to two new line characters. prefix – String that should go before any examples. Generally includes examples. Default to an empty string. Returns The final prompt generated. classmethod from_file(template_file: Union[str, pathlib.Path], input_variables: List[str], **kwargs: Any) β†’ langchain.prompts.prompt.PromptTemplate[source]# Load a prompt from a file. Parameters template_file – The path to the file containing the prompt template. input_variables – A list of variable names the final prompt template will expect. Returns The prompt loaded from the file. classmethod from_template(template: str, **kwargs: Any) β†’ langchain.prompts.prompt.PromptTemplate[source]# Load a prompt template from a template. pydantic model langchain.prompts.StringPromptTemplate[source]# String prompt should expose the format method, returning a prompt. format_prompt(**kwargs: Any) β†’ langchain.schema.PromptValue[source]# Create Chat Messages.
https://python.langchain.com/en/latest/reference/modules/prompts.html
2f2363e560c4-5
Create Chat Messages. langchain.prompts.load_prompt(path: Union[str, pathlib.Path]) β†’ langchain.prompts.base.BasePromptTemplate[source]# Unified method for loading a prompt from LangChainHub or local fs. previous Prompts next Example Selector By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/reference/modules/prompts.html
149d054d7bac-0
.rst .pdf Document Loaders Document Loaders# All different types of document loaders. class langchain.document_loaders.AZLyricsLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Loader that loads AZLyrics webpages. load() β†’ List[langchain.schema.Document][source]# Load webpage. class langchain.document_loaders.AirbyteJSONLoader(file_path: str)[source]# Loader that loads local airbyte json files. load() β†’ List[langchain.schema.Document][source]# Load file. pydantic model langchain.document_loaders.ApifyDatasetLoader[source]# Logic for loading documents from Apify datasets. field apify_client: Any = None# field dataset_id: str [Required]# The ID of the dataset on the Apify platform. field dataset_mapping_function: Callable[[Dict], langchain.schema.Document] [Required]# A custom function that takes a single dictionary (an Apify dataset item) and converts it to an instance of the Document class. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.ArxivLoader(query: str, load_max_docs: Optional[int] = 100, load_all_available_meta: Optional[bool] = False)[source]# Loads a query result from arxiv.org into a list of Documents. Each document represents one Document. The loader converts the original PDF format into the text. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.AzureBlobStorageContainerLoader(conn_str: str, container: str, prefix: str = '')[source]# Loading logic for loading documents from Azure Blob Storage.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-1
Loading logic for loading documents from Azure Blob Storage. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.AzureBlobStorageFileLoader(conn_str: str, container: str, blob_name: str)[source]# Loading logic for loading documents from Azure Blob Storage. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.BSHTMLLoader(file_path: str, open_encoding: Optional[str] = None, bs_kwargs: Optional[dict] = None, get_text_separator: str = '')[source]# Loader that uses beautiful soup to parse HTML files. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.BibtexLoader(file_path: str, *, parser: Optional[langchain.utilities.bibtex.BibtexparserWrapper] = None, max_docs: Optional[int] = None, max_content_chars: Optional[int] = 4000, load_extra_metadata: bool = False, file_pattern: str = '[^:]+\\.pdf')[source]# Loads a bibtex file into a list of Documents. Each document represents one entry from the bibtex file. If a PDF file is present in the file bibtex field, the original PDF is loaded into the document text. If no such file entry is present, the abstract field is used instead. lazy_load() β†’ Iterator[langchain.schema.Document][source]# Load bibtex file using bibtexparser and get the article texts plus the article metadata. See https://bibtexparser.readthedocs.io/en/master/ Returns a list of documents with the document.page_content in text format load() β†’ List[langchain.schema.Document][source]#
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-2
load() β†’ List[langchain.schema.Document][source]# Load bibtex file documents from the given bibtex file path. See https://bibtexparser.readthedocs.io/en/master/ Parameters file_path – the path to the bibtex file Returns a list of documents with the document.page_content in text format class langchain.document_loaders.BigQueryLoader(query: str, project: Optional[str] = None, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None)[source]# Loads a query result from BigQuery into a list of documents. Each document represents one row of the result. The page_content_columns are written into the page_content of the document. The metadata_columns are written into the metadata of the document. By default, all columns are written into the page_content and none into the metadata. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.BiliBiliLoader(video_urls: List[str])[source]# Loader that loads bilibili transcripts. load() β†’ List[langchain.schema.Document][source]# Load from bilibili url. class langchain.document_loaders.BlackboardLoader(blackboard_course_url: str, bbrouter: str, load_all_recursively: bool = True, basic_auth: Optional[Tuple[str, str]] = None, cookies: Optional[dict] = None)[source]# Loader that loads all documents from a Blackboard course. This loader is not compatible with all Blackboard courses. It is only compatible with courses that use the new Blackboard interface. To use this loader, you must have the BbRouter cookie. You can get this cookie by logging into the course and then copying the value of the
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-3
cookie by logging into the course and then copying the value of the BbRouter cookie from the browser’s developer tools. Example from langchain.document_loaders import BlackboardLoader loader = BlackboardLoader( blackboard_course_url="https://blackboard.example.com/webapps/blackboard/execute/announcement?method=search&context=course_entry&course_id=_123456_1", bbrouter="expires:12345...", ) documents = loader.load() base_url: str# check_bs4() β†’ None[source]# Check if BeautifulSoup4 is installed. Raises ImportError – If BeautifulSoup4 is not installed. download(path: str) β†’ None[source]# Download a file from a url. Parameters path – Path to the file. folder_path: str# load() β†’ List[langchain.schema.Document][source]# Load data into document objects. Returns List of documents. load_all_recursively: bool# parse_filename(url: str) β†’ str[source]# Parse the filename from a url. Parameters url – Url to parse the filename from. Returns The filename. class langchain.document_loaders.BlockchainDocumentLoader(contract_address: str, blockchainType: langchain.document_loaders.blockchain.BlockchainType = BlockchainType.ETH_MAINNET, api_key: str = 'docs-demo', startToken: str = '', get_all_tokens: bool = False, max_execution_time: Optional[int] = None)[source]# Loads elements from a blockchain smart contract into Langchain documents. The supported blockchains are: Ethereum mainnet, Ethereum Goerli testnet, Polygon mainnet, and Polygon Mumbai testnet. If no BlockchainType is specified, the default is Ethereum mainnet. The Loader uses the Alchemy API to interact with the blockchain.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-4
The Loader uses the Alchemy API to interact with the blockchain. ALCHEMY_API_KEY environment variable must be set to use this loader. The API returns 100 NFTs per request and can be paginated using the startToken parameter. If get_all_tokens is set to True, the loader will get all tokens on the contract. Note that for contracts with a large number of tokens, this may take a long time (e.g. 10k tokens is 100 requests). Default value is false for this reason. The max_execution_time (sec) can be set to limit the execution time of the loader. Future versions of this loader can: Support additional Alchemy APIs (e.g. getTransactions, etc.) Support additional blockain APIs (e.g. Infura, Opensea, etc.) load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.CSVLoader(file_path: str, source_column: Optional[str] = None, csv_args: Optional[Dict] = None, encoding: Optional[str] = None)[source]# Loads a CSV file into a list of documents. Each document represents one row of the CSV file. Every row is converted into a key/value pair and outputted to a new line in the document’s page_content. The source for each document loaded from csv is set to the value of the file_path argument for all doucments by default. You can override this by setting the source_column argument to the name of a column in the CSV file. The source of each document will then be set to the value of the column with the name specified in source_column. Output Example:column1: value1 column2: value2 column3: value3 load() β†’ List[langchain.schema.Document][source]#
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-5
column3: value3 load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.ChatGPTLoader(log_file: str, num_logs: int = - 1)[source]# Loader that loads conversations from exported ChatGPT data. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.CoNLLULoader(file_path: str)[source]# Load CoNLL-U files. load() β†’ List[langchain.schema.Document][source]# Load from file path. class langchain.document_loaders.CollegeConfidentialLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Loader that loads College Confidential webpages. load() β†’ List[langchain.schema.Document][source]# Load webpage. class langchain.document_loaders.ConfluenceLoader(url: str, api_key: Optional[str] = None, username: Optional[str] = None, oauth2: Optional[dict] = None, cloud: Optional[bool] = True, number_of_retries: Optional[int] = 3, min_retry_seconds: Optional[int] = 2, max_retry_seconds: Optional[int] = 10, confluence_kwargs: Optional[dict] = None)[source]# Load Confluence pages. Port of https://llamahub.ai/l/confluence This currently supports both username/api_key and Oauth2 login. Specify a list page_ids and/or space_key to load in the corresponding pages into Document objects, if both are specified the union of both sets will be returned. You can also specify a boolean include_attachments to include attachments, this is set to False by default, if set to True all attachments will be downloaded and
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-6
is set to False by default, if set to True all attachments will be downloaded and ConfluenceReader will extract the text from the attachments and add it to the Document object. Currently supported attachment types are: PDF, PNG, JPEG/JPG, SVG, Word and Excel. Hint: space_key and page_id can both be found in the URL of a page in Confluence - https://yoursite.atlassian.com/wiki/spaces/<space_key>/pages/<page_id> Example from langchain.document_loaders import ConfluenceLoader loader = ConfluenceLoader( url="https://yoursite.atlassian.com/wiki", username="me", api_key="12345" ) documents = loader.load(space_key="SPACE",limit=50) Parameters url (str) – _description_ api_key (str, optional) – _description_, defaults to None username (str, optional) – _description_, defaults to None oauth2 (dict, optional) – _description_, defaults to {} cloud (bool, optional) – _description_, defaults to True number_of_retries (Optional[int], optional) – How many times to retry, defaults to 3 min_retry_seconds (Optional[int], optional) – defaults to 2 max_retry_seconds (Optional[int], optional) – defaults to 10 confluence_kwargs (dict, optional) – additional kwargs to initialize confluence with Raises ValueError – Errors while validating input ImportError – Required dependencies not installed. is_public_page(page: dict) β†’ bool[source]# Check if a page is publicly accessible.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-7
Check if a page is publicly accessible. load(space_key: Optional[str] = None, page_ids: Optional[List[str]] = None, label: Optional[str] = None, cql: Optional[str] = None, include_restricted_content: bool = False, include_archived_content: bool = False, include_attachments: bool = False, include_comments: bool = False, limit: Optional[int] = 50, max_pages: Optional[int] = 1000) β†’ List[langchain.schema.Document][source]# Parameters space_key (Optional[str], optional) – Space key retrieved from a confluence URL, defaults to None page_ids (Optional[List[str]], optional) – List of specific page IDs to load, defaults to None label (Optional[str], optional) – Get all pages with this label, defaults to None cql (Optional[str], optional) – CQL Expression, defaults to None include_restricted_content (bool, optional) – defaults to False include_archived_content (bool, optional) – Whether to include archived content, defaults to False include_attachments (bool, optional) – defaults to False include_comments (bool, optional) – defaults to False limit (int, optional) – Maximum number of pages to retrieve per request, defaults to 50 max_pages (int, optional) – Maximum number of pages to retrieve in total, defaults 1000 Raises ValueError – _description_ ImportError – _description_ Returns _description_ Return type List[Document] paginate_request(retrieval_method: Callable, **kwargs: Any) β†’ List[source]# Paginate the various methods to retrieve groups of pages. Unfortunately, due to page size, sometimes the Confluence API doesn’t match the limit value. If limit is >100 confluence
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-8
doesn’t match the limit value. If limit is >100 confluence seems to cap the response to 100. Also, due to the Atlassian Python package, we don’t get the β€œnext” values from the β€œ_links” key because they only return the value from the results key. So here, the pagination starts from 0 and goes until the max_pages, getting the limit number of pages with each request. We have to manually check if there are more docs based on the length of the returned list of pages, rather than just checking for the presence of a next key in the response like this page would have you do: https://developer.atlassian.com/server/confluence/pagination-in-the-rest-api/ Parameters retrieval_method (callable) – Function used to retrieve docs Returns List of documents Return type List process_attachment(page_id: str) β†’ List[str][source]# process_doc(link: str) β†’ str[source]# process_image(link: str) β†’ str[source]# process_page(page: dict, include_attachments: bool, include_comments: bool) β†’ langchain.schema.Document[source]# process_pages(pages: List[dict], include_restricted_content: bool, include_attachments: bool, include_comments: bool) β†’ List[langchain.schema.Document][source]# Process a list of pages into a list of documents. process_pdf(link: str) β†’ str[source]# process_svg(link: str) β†’ str[source]# process_xls(link: str) β†’ str[source]# static validate_init_args(url: Optional[str] = None, api_key: Optional[str] = None, username: Optional[str] = None, oauth2: Optional[dict] = None) β†’ Optional[List][source]# Validates proper combinations of init arguments
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-9
Validates proper combinations of init arguments class langchain.document_loaders.DataFrameLoader(data_frame: Any, page_content_column: str = 'text')[source]# Load Pandas DataFrames. load() β†’ List[langchain.schema.Document][source]# Load from the dataframe. class langchain.document_loaders.DiffbotLoader(api_token: str, urls: List[str], continue_on_failure: bool = True)[source]# Loader that loads Diffbot file json. load() β†’ List[langchain.schema.Document][source]# Extract text from Diffbot on all the URLs and return Document instances class langchain.document_loaders.DirectoryLoader(path: str, glob: str = '**/[!.]*', silent_errors: bool = False, load_hidden: bool = False, loader_cls: typing.Union[typing.Type[langchain.document_loaders.unstructured.UnstructuredFileLoader], typing.Type[langchain.document_loaders.text.TextLoader], typing.Type[langchain.document_loaders.html_bs.BSHTMLLoader]] = <class 'langchain.document_loaders.unstructured.UnstructuredFileLoader'>, loader_kwargs: typing.Optional[dict] = None, recursive: bool = False, show_progress: bool = False, use_multithreading: bool = False, max_concurrency: int = 4)[source]# Loading logic for loading documents from a directory. load() β†’ List[langchain.schema.Document][source]# Load documents. load_file(item: pathlib.Path, path: pathlib.Path, docs: List[langchain.schema.Document], pbar: Optional[Any]) β†’ None[source]# class langchain.document_loaders.DiscordChatLoader(chat_log: pd.DataFrame, user_id_col: str = 'ID')[source]# Load Discord chat logs. load() β†’ List[langchain.schema.Document][source]# Load all chat messages.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-10
load() β†’ List[langchain.schema.Document][source]# Load all chat messages. pydantic model langchain.document_loaders.DocugamiLoader[source]# Loader that loads processed docs from Docugami. To use, you should have the lxml python package installed. field access_token: Optional[str] = None# field api: str = 'https://api.docugami.com/v1preview1'# field docset_id: Optional[str] = None# field document_ids: Optional[Sequence[str]] = None# field file_paths: Optional[Sequence[Union[pathlib.Path, str]]] = None# field min_chunk_size: int = 32# load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.Docx2txtLoader(file_path: str)[source]# Loads a DOCX with docx2txt and chunks at character level. Defaults to check for local file, but if the file is a web path, it will download it to a temporary file, and use that, then clean up the temporary file after completion load() β†’ List[langchain.schema.Document][source]# Load given path as single page. class langchain.document_loaders.DuckDBLoader(query: str, database: str = ':memory:', read_only: bool = False, config: Optional[Dict[str, str]] = None, page_content_columns: Optional[List[str]] = None, metadata_columns: Optional[List[str]] = None)[source]# Loads a query result from DuckDB into a list of documents. Each document represents one row of the result. The page_content_columns are written into the page_content of the document. The metadata_columns are written into the metadata of the document. By default, all columns are written into the page_content and none into the metadata.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-11
are written into the page_content and none into the metadata. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.EverNoteLoader(file_path: str, load_single_document: bool = True)[source]# EverNote Loader. Loads an EverNote notebook export file e.g. my_notebook.enex into Documents. Instructions on producing this file can be found at https://help.evernote.com/hc/en-us/articles/209005557-Export-notes-and-notebooks-as-ENEX-or-HTML Currently only the plain text in the note is extracted and stored as the contents of the Document, any non content metadata (e.g. β€˜author’, β€˜created’, β€˜updated’ etc. but not β€˜content-raw’ or β€˜resource’) tags on the note will be extracted and stored as metadata on the Document. Parameters file_path (str) – The path to the notebook export with a .enex extension load_single_document (bool) – Whether or not to concatenate the content of all notes into a single long Document. True (If this is set to) – the β€˜source’ which contains the file name of the export. load() β†’ List[langchain.schema.Document][source]# Load documents from EverNote export file. class langchain.document_loaders.FacebookChatLoader(path: str)[source]# Loader that loads Facebook messages json directory dump. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.GCSDirectoryLoader(project_name: str, bucket: str, prefix: str = '')[source]# Loading logic for loading documents from GCS. load() β†’ List[langchain.schema.Document][source]# Load documents.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-12
load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.GCSFileLoader(project_name: str, bucket: str, blob: str)[source]# Loading logic for loading documents from GCS. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.GitLoader(repo_path: str, clone_url: Optional[str] = None, branch: Optional[str] = 'main', file_filter: Optional[Callable[[str], bool]] = None)[source]# Loads files from a Git repository into a list of documents. Repository can be local on disk available at repo_path, or remote at clone_url that will be cloned to repo_path. Currently supports only text files. Each document represents one file in the repository. The path points to the local Git repository, and the branch specifies the branch to load files from. By default, it loads from the main branch. load() β†’ List[langchain.schema.Document][source]# Load data into document objects. class langchain.document_loaders.GitbookLoader(web_page: str, load_all_paths: bool = False, base_url: Optional[str] = None, content_selector: str = 'main')[source]# Load GitBook data. load from either a single page, or load all (relative) paths in the navbar. load() β†’ List[langchain.schema.Document][source]# Fetch text from one single GitBook page. class langchain.document_loaders.GoogleApiClient(credentials_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json'), service_account_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json'), token_path: pathlib.Path = PosixPath('/home/docs/.credentials/token.json'))[source]# A Generic Google Api Client.
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-13
A Generic Google Api Client. To use, you should have the google_auth_oauthlib,youtube_transcript_api,google python package installed. As the google api expects credentials you need to set up a google account and register your Service. β€œhttps://developers.google.com/docs/api/quickstart/python” Example from langchain.document_loaders import GoogleApiClient google_api_client = GoogleApiClient( service_account_path=Path("path_to_your_sec_file.json") ) credentials_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json')# service_account_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json')# token_path: pathlib.Path = PosixPath('/home/docs/.credentials/token.json')# classmethod validate_channel_or_videoIds_is_set(values: Dict[str, Any]) β†’ Dict[str, Any][source]# Validate that either folder_id or document_ids is set, but not both. class langchain.document_loaders.GoogleApiYoutubeLoader(google_api_client: langchain.document_loaders.youtube.GoogleApiClient, channel_name: Optional[str] = None, video_ids: Optional[List[str]] = None, add_video_info: bool = True, captions_language: str = 'en', continue_on_failure: bool = False)[source]# Loader that loads all Videos from a Channel To use, you should have the googleapiclient,youtube_transcript_api python package installed. As the service needs a google_api_client, you first have to initialize the GoogleApiClient. Additionally you have to either provide a channel name or a list of videoids β€œhttps://developers.google.com/docs/api/quickstart/python” Example from langchain.document_loaders import GoogleApiClient from langchain.document_loaders import GoogleApiYoutubeLoader google_api_client = GoogleApiClient(
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-14
from langchain.document_loaders import GoogleApiYoutubeLoader google_api_client = GoogleApiClient( service_account_path=Path("path_to_your_sec_file.json") ) loader = GoogleApiYoutubeLoader( google_api_client=google_api_client, channel_name = "CodeAesthetic" ) load.load() add_video_info: bool = True# captions_language: str = 'en'# channel_name: Optional[str] = None# continue_on_failure: bool = False# google_api_client: langchain.document_loaders.youtube.GoogleApiClient# load() β†’ List[langchain.schema.Document][source]# Load documents. classmethod validate_channel_or_videoIds_is_set(values: Dict[str, Any]) β†’ Dict[str, Any][source]# Validate that either folder_id or document_ids is set, but not both. video_ids: Optional[List[str]] = None# pydantic model langchain.document_loaders.GoogleDriveLoader[source]# Loader that loads Google Docs from Google Drive. Validators validate_credentials_path Β» credentials_path validate_inputs Β» all fields field credentials_path: pathlib.Path = PosixPath('/home/docs/.credentials/credentials.json')# field document_ids: Optional[List[str]] = None# field file_ids: Optional[List[str]] = None# field file_types: Optional[Sequence[str]] = None# field folder_id: Optional[str] = None# field load_trashed_files: bool = False# field recursive: bool = False# field service_account_key: pathlib.Path = PosixPath('/home/docs/.credentials/keys.json')# field token_path: pathlib.Path = PosixPath('/home/docs/.credentials/token.json')# load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.GutenbergLoader(file_path: str)[source]#
https://python.langchain.com/en/latest/reference/modules/document_loaders.html
149d054d7bac-15
class langchain.document_loaders.GutenbergLoader(file_path: str)[source]# Loader that uses urllib to load .txt web files. load() β†’ List[langchain.schema.Document][source]# Load file. class langchain.document_loaders.HNLoader(web_path: Union[str, List[str]], header_template: Optional[dict] = None)[source]# Load Hacker News data from either main page results or the comments page. load() β†’ List[langchain.schema.Document][source]# Get important HN webpage information. Components are: title content source url, time of post author of the post number of comments rank of the post load_comments(soup_info: Any) β†’ List[langchain.schema.Document][source]# Load comments from a HN post. load_results(soup: Any) β†’ List[langchain.schema.Document][source]# Load items from an HN page. class langchain.document_loaders.HuggingFaceDatasetLoader(path: str, page_content_column: str = 'text', name: Optional[str] = None, data_dir: Optional[str] = None, data_files: Optional[Union[str, Sequence[str], Mapping[str, Union[str, Sequence[str]]]]] = None, cache_dir: Optional[str] = None, keep_in_memory: Optional[bool] = None, save_infos: bool = False, use_auth_token: Optional[Union[bool, str]] = None, num_proc: Optional[int] = None)[source]# Loading logic for loading documents from the Hugging Face Hub. lazy_load() β†’ Iterator[langchain.schema.Document][source]# Load documents lazily. load() β†’ List[langchain.schema.Document][source]# Load documents. class langchain.document_loaders.IFixitLoader(web_path: str)[source]#
https://python.langchain.com/en/latest/reference/modules/document_loaders.html