id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
4092f5c0fde6-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 l...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-7
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 ext...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-8
field human_prefix: str = 'Human'# field k: int = 2# field kg: langchain.graphs.networkx_graph.NetworkxEntityGraph [Optional]#
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-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 integrati...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-10
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 bak...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-11
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) β†’ Lis...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-12
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], ...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-13
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_stri...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-14
add_message(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: s...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-15
See https://gomomento.com/ add_message(message: langchain.schema.BaseMessage) β†’ None[source]# Store a message in the cache. Parameters message (BaseMessage) – The message object to store. Raises SdkException – Momento service or network error. Exception – Unexpected response. clear() β†’ None[source]# Remove the session’...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-16
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_message(message: langchain.sche...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-17
Retrieve the messages from Redis pydantic model langchain.memory.RedisEntityStore[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. field key_prefix: str = 'memory_store'# field recall_ttl: Optional[int] = 259200# field red...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-18
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 te...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
4092f5c0fde6-19
previous Document Transformers next Agents By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/memory.html
9607edd1bc6f-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....
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
9607edd1bc6f-1
Example: .. code-block:: python prompt.save(file_path=”path/prompt.yaml”) property lc_serializable: bool# Return whether or not the class is serializable. pydantic model langchain.prompts.ChatPromptTemplate[source]# format(**kwargs: Any) β†’ str[source]# Format the prompt with the inputs. Parameters kwargs – Any argument...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
9607edd1bc6f-2
field input_variables: List[str] [Required]# 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 forma...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
9607edd1bc6f-3
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]# A PromptTemplate to put after the examples. field template_form...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
9607edd1bc6f-4
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 kwargs – Any argumen...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
9607edd1bc6f-5
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. property lc_attributes: Dict[str, Any]# Return a list of attribute names that should be included in the serialized kwar...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/prompts.html
28d346c00700-0
.rst .pdf Output Parsers Output Parsers# pydantic model langchain.output_parsers.CommaSeparatedListOutputParser[source]# Parse out comma separated lists. get_format_instructions() β†’ str[source]# Instructions on how the LLM output should be formatted. parse(text: str) β†’ List[str][source]# Parse the output of an LLM call...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
28d346c00700-1
Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.ListOutputParser[source]# Class to parse the output of an LLM call to a list. abstract parse(text: str) β†’ List[str][source]# Parse the output of an LLM call. pydantic model langchain.output_parsers.OutputFixingP...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
28d346c00700-2
Parameters text – output of language model Returns structured output pydantic model langchain.output_parsers.PydanticOutputParser[source]# field pydantic_object: Type[langchain.output_parsers.pydantic.T] [Required]# get_format_instructions() β†’ str[source]# Instructions on how the LLM output should be formatted. parse(t...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
28d346c00700-3
Wraps a parser and tries to fix parsing errors. Does this by passing the original prompt and the completion to another LLM, and telling it the completion did not satisfy criteria in the prompt. field parser: BaseOutputParser[T] [Required]# field retry_chain: LLMChain [Required]# classmethod from_llm(llm: langchain.base...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
28d346c00700-4
Parameters completion – output of language model prompt – prompt value Returns structured output pydantic model langchain.output_parsers.RetryWithErrorOutputParser[source]# Wraps a parser and tries to fix parsing errors. Does this by passing the original prompt, the completion, AND the error that was raised to another ...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
28d346c00700-5
Parameters text – output of language model Returns structured output parse_with_prompt(completion: str, prompt_value: langchain.schema.PromptValue) β†’ langchain.output_parsers.retry.T[source]# Optional method to parse the output of an LLM call with a prompt. The prompt is largely provided in the event the OutputParser w...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/output_parsers.html
940630d84aef-0
.rst .pdf SearxNG Search Contents Quick Start Searching Engine Parameters Search Tips SearxNG Search# Utility for using SearxNG meta search API. SearxNG is a privacy-friendly free metasearch engine that aggregates results from multiple search engines and databases and supports the OpenSearch specification. More detai...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/searx_search.html
940630d84aef-1
# assuming the searx host is set as above or exported as an env variable s = SearxSearchWrapper(engines=['google', 'bing'], language='es') Search Tips# Searx offers a special search syntax that can also be used instead of passing engine parameters. For example the following query: s = SearxSearchWra...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/searx_search.html
940630d84aef-2
use a self hosted instance and disable the rate limiter. If you are self-hosting an instance you can customize the rate limiter for your own network as described here. For a list of public SearxNG instances see https://searx.space/ class langchain.utilities.searx_search.SearxResults(data: str)[source]# Dict like wrappe...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/searx_search.html
940630d84aef-3
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...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/searx_search.html
940630d84aef-4
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 param...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/searx_search.html
b81cb3fdf556-0
.rst .pdf Text Splitter Text Splitter# Functionality for splitting text. class langchain.text_splitter.CharacterTextSplitter(separator: str = '\n\n', **kwargs: Any)[source]# Implementation of splitting text that looks at characters. split_text(text: str) β†’ List[str][source]# Split incoming text and return chunks. class...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/text_splitter.html
b81cb3fdf556-1
Combine lines with common metadata into chunks :param lines: Line of text / associated header metadata split_text(text: str) β†’ List[langchain.text_splitter.LineType][source]# Split markdown file :param text: Markdown file class langchain.text_splitter.MarkdownTextSplitter(**kwargs: Any)[source]# Attempts to split the t...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/text_splitter.html
b81cb3fdf556-2
Implementation of splitting text that looks at tokens. count_tokens(*, text: str) β†’ int[source]# split_text(text: str) β†’ List[str][source]# Split text into multiple components. class langchain.text_splitter.SpacyTextSplitter(separator: str = '\n\n', pipeline: str = 'en_core_web_sm', **kwargs: Any)[source]# Implementati...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/text_splitter.html
b81cb3fdf556-3
Text splitter that uses tiktoken encoder to count length. split_documents(documents: Iterable[langchain.schema.Document]) β†’ List[langchain.schema.Document][source]# Split documents. abstract split_text(text: str) β†’ List[str][source]# Split text into multiple components. transform_documents(documents: Sequence[langchain...
rtdocs_stable/api.python.langchain.com/en/stable/reference/modules/text_splitter.html
45e17ae25136-0
.rst .pdf Evaluation Contents The Problem The Solution The Examples Other Examples Evaluation# Note Conceptual Guide This section of documentation covers how we approach and think about evaluation in LangChain. Both evaluation of internal chains/agents, but also how we would recommend people building on top of LangCh...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation.html
45e17ae25136-1
We intend this to be a collection of open source datasets for evaluating common chains and agents. We have contributed five datasets of our own to start, but we highly intend this to be a community effort. In order to contribute a dataset, you simply need to join the community and then you will be able to upload datase...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation.html
45e17ae25136-2
SQL Question Answering (Chinook): A notebook showing evaluation of a question-answering task over a SQL database (the Chinook database). Agent Vectorstore: A notebook showing evaluation of an agent doing question answering while routing between two different vector databases. Agent Search + Calculator: A notebook showi...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation.html
b70626dcc23b-0
.md .pdf Agents Contents Create Your Own Agent Step 1: Create Tools (Optional) Step 2: Modify Agent (Optional) Step 3: Modify Agent Executor Examples Agents# Conceptual Guide Agents can be used for a variety of tasks. Agents combine the decision making ability of a language model with tools in order to create a syste...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/personal_assistants.html
b70626dcc23b-1
(Optional) Step 3: Modify Agent Executor# This step is usually not necessary, as this is pretty general logic. Possible reasons you would want to modify this include adding different stopping conditions, or handling errors Examples# Specific examples of agents include: AI Plugins: an implementation of an agent that is ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/personal_assistants.html
94766fb5596e-0
.md .pdf Code Understanding Contents Conversational Retriever Chain Code Understanding# Overview LangChain is a useful tool designed to parse GitHub code repositories. By leveraging VectorStores, Conversational RetrieverChain, and GPT-4, it can answer questions in the context of an entire GitHub repository or generat...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/code.html
94766fb5596e-1
The full tutorial is available below. Twitter the-algorithm codebase analysis with Deep Lake: A notebook walking through how to parse github source code and run queries conversation. LangChain codebase analysis with Deep Lake: A notebook walking through how to analyze and do question answering over THIS code base. prev...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/code.html
4985cbf22034-0
.md .pdf Extraction Extraction# Conceptual Guide Most APIs and databases still deal with structured information. Therefore, in order to better work with those, it can be useful to extract structured information from text. Examples of this include: Extracting a structured row to insert into a database from a sentence Ex...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/extraction.html
01cf582a2333-0
.md .pdf Summarization Summarization# Conceptual Guide Summarization involves creating a smaller summary of multiple longer documents. This can be useful for distilling long documents into the core pieces of information. The recommended way to get started using a summarization chain is: from langchain.chains.summarize ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/summarization.html
f4d66bc8ca8c-0
.md .pdf Autonomous Agents Contents Baby AGI (Original Repo) AutoGPT (Original Repo) MetaPrompt (Original Repo) Autonomous Agents# Autonomous Agents are agents that designed to be more long running. You give them one or multiple long term goals, and they independently execute towards those goals. The applications com...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents.html
6947af9fac1b-0
.md .pdf Querying Tabular Data Contents Document Loading Querying Chains Agents Querying Tabular Data# Conceptual Guide Lots of data and information is stored in tabular data, whether it be csvs, excel sheets, or SQL tables. This page covers all resources available in LangChain for working with data in this format. D...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/tabular.html
7b3caeb6452e-0
.md .pdf Chatbots Chatbots# Conceptual Guide Since language models are good at producing text, that makes them ideal for creating chatbots. Aside from the base prompts/LLMs, an important concept to know for Chatbots is memory. Most chat based applications rely on remembering what happened in previous interactions, whic...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots.html
5f35a20de745-0
.md .pdf Interacting with APIs Contents Chains Agents Interacting with APIs# Conceptual Guide Lots of data and information is stored behind APIs. This page covers all resources available in LangChain for working with APIs. Chains# If you are just getting started, and you have relatively simple apis, you should get st...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/apis.html
0822cfe33a1f-0
.md .pdf Agent Simulations Contents Simulations with One Agent Simulations with Two Agents Simulations with Multiple Agents Agent Simulations# Agent simulations involve interacting one of more agents with each other. Agent simulations generally involve two main components: Long Term Memory Simulation Environment Spec...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agent_simulations.html
0822cfe33a1f-1
Simulated Environment: PettingZoo: an example of how to create a agent-environment interaction loop for multiple agents with PettingZoo (a multi-agent version of Gymnasium). Generative Agents: This notebook implements a generative agent based on the paper Generative Agents: Interactive Simulacra of Human Behavior by Pa...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agent_simulations.html
3b3fb709d9c8-0
.md .pdf Question Answering over Docs Contents Document Question Answering Adding in sources Additional Related Resources End-to-end examples Question Answering over Docs# Conceptual Guide Question answering in this context refers to question answering over your document data. For question answering over other types ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/question_answering.html
3b3fb709d9c8-1
The recommended way to get started using a question answering chain is: from langchain.chains.question_answering import load_qa_chain chain = load_qa_chain(llm, chain_type="stuff") chain.run(input_documents=docs, question=query) The following resources exist: Question Answering Notebook: A notebook walking through how ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/question_answering.html
3b3fb709d9c8-2
CombineDocuments Chains: A conceptual overview of specific types of chains by which you can accomplish this task. End-to-end examples# For examples to this done in an end-to-end manner, please see the following resources: Semantic search over a group chat with Sources Notebook: A notebook that semantically searches ove...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/question_answering.html
41eba453ab7e-0
.ipynb .pdf Voice Assistant Voice Assistant# This chain creates a clone of ChatGPT with a few modifications to make it a voice assistant. It uses the pyttsx3 and speech_recognition libraries to convert text to speech and speech to text respectively. The prompt template is also changed to make it more suitable for voice...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-1
{history} Human: {human_input} Assistant:""" prompt = PromptTemplate( input_variables=["history", "human_input"], template=template ) chatgpt_chain = LLMChain( llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationBufferWindowMemory(k=2), ) import speech_recognition as s...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-2
engine.runAndWait() listen(None) Calibrating... Okay, go! listening now... Recognizing... C:\Users\jaden\AppData\Roaming\Python\Python310\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .auton...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-3
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-4
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-5
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-6
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-7
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-8
Human: I'd like to learn more about neural networks. AI: Sure! Neural networks are a type of artificial intelligence that use a network of interconnected nodes to process data and make decisions. They are used in a variety of applications, from image recognition to natural language processing. Neural networks are oft...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-9
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-10
> Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assis...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-11
Human: Tell me about a brand new discovered bird species. AI: A new species of bird was recently discovered in the Amazon rainforest. The species, called the Spix's Macaw, is a small, blue parrot that is believed to be extinct in the wild. It is the first new species of bird to be discovered in the Amazon in over 100...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-12
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-13
Human: Tell me a children's story about the importance of honesty and trust. AI: Once upon a time, there was a young boy named Jack who lived in a small village. Jack was always honest and trustworthy, and his friends and family knew they could always count on him. One day, Jack was walking through the forest when he...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-14
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-15
> Finished chain. You're welcome! listening now... Recognizing... Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? > Entering new LLMChain chain... Prompt ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-16
Human: Wow, Assistant, that was a really good story. Congratulations! AI: Thank you! I'm glad you enjoyed it. Human: Thank you. AI: You're welcome! Human: Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Do you know of online brands like Photoshop and Freq t...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-17
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-18
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-19
AI: Yes, there are several online brands that offer photo editing and other creative tools without the need to download any software. Adobe Photoshop Express, Pixlr, and Fotor are some of the most popular online photo editing tools. Freq is an online music production platform that allows users to create and share musi...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
41eba453ab7e-20
521 break --> 523 buffer = source.stream.read(source.CHUNK) 524 if len(buffer) == 0: break # reached end of the stream 525 frames.append(buffer) File c:\ProgramData\miniconda3\envs\lang\lib\site-packages\speech_recognition\__init__.py:199, in Microphone.MicrophoneStream.read(self, size) 198 def read(se...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/chatbots/voice_assistant.html
249f889221fa-0
.ipynb .pdf Custom Agent with PlugIn Retrieval Contents Set up environment Setup LLM Set up plugins Tool Retriever Prompt Template Output Parser Set up LLM, stop sequence, and the agent Use the Agent Custom Agent with PlugIn Retrieval# This notebook combines two concepts in order to build a custom agent that can inte...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-1
Set up plugins# Load and index plugins urls = [ "https://datasette.io/.well-known/ai-plugin.json", "https://api.speak.com/.well-known/ai-plugin.json", "https://www.wolframalpha.com/.well-known/ai-plugin.json", "https://www.zapier.com/.well-known/ai-plugin.json", "https://www.klarna.com/.well-known/a...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-2
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3....
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-3
# Get the tools: a separate NLAChain for each endpoint tools = [] for tk in tool_kits: tools.extend(tk.nla_tools) return tools We can now test this retriever to see if it seems to work. tools = get_tools("What could I do today with my kiddo") [t.name for t in tools] ['Milo.askMilo', 'Zapier_Natural...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-4
'Milo.askMilo', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.search_all_actions', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.preview_a_zap', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.get_configuration_link', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Bet...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-5
Thought: I now know the final answer Final Answer: the final answer to the original input question Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Arg"s Question: {input} {agent_scratchpad}""" The custom prompt template now has the concept of a tools_getter, which we call on the input t...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-6
# This includes the `intermediate_steps` variable because that is needed input_variables=["input", "intermediate_steps"] ) Output Parser# The output parser is unchanged from the previous notebook, since we are not changing anything about the output format. class CustomOutputParser(AgentOutputParser): def p...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
249f889221fa-7
llm_chain = LLMChain(llm=llm, prompt=prompt) tool_names = [tool.name for tool in tools] agent = LLMSingleActionAgent( llm_chain=llm_chain, output_parser=output_parser, stop=["\nObservation:"], allowed_tools=tool_names ) Use the Agent# Now we can use it! agent_executor = AgentExecutor.from_agent_and_to...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval.html
778e26c5403d-0
.ipynb .pdf Multi-modal outputs: Image & Text Contents Multi-modal outputs: Image & Text Dall-E StableDiffusion Multi-modal outputs: Image & Text# This notebook shows how non-text producing tools can be used to create multi-modal agents. This example is limited to text and image outputs and uses UUIDs to transfer con...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/multi_modal_output_agent.html
778e26c5403d-1
> Finished chain. def show_output(output): """Display the multi-modal output from the agent.""" UUID_PATTERN = re.compile( r"([0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12})" ) outputs = UUID_PATTERN.split(output) outputs = [re.sub(r"^\W+", "", el) for el in outp...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/multi_modal_output_agent.html
778e26c5403d-2
> Finished chain. show_output(output) The UUID of the generated image is Contents Multi-modal outputs: Image & Text Dall-E StableDiffusion By Harrison Chase Β© Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/multi_modal_output_agent.html
6e1030dd3571-0
.ipynb .pdf Wikibase Agent Contents Wikibase Agent Preliminaries API keys and other secrats OpenAI API Key Wikidata user-agent header Enable tracing if desired Tools Item and Property lookup Sparql runner Agent Wrap the tools Prompts Output parser Specify the LLM model Agent and agent executor Run it! Wikibase Agent#...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-1
Enable tracing if desired# #import os #os.environ["LANGCHAIN_HANDLER"] = "langchain" #os.environ["LANGCHAIN_SESSION"] = "default" # Make sure this session actually exists. Tools# Three tools are provided for this simple agent: ItemLookup: for finding the q-number of an item PropertyLookup: for finding the p-number of ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-2
else: raise ValueError("entity_type must be either 'property' or 'item'") params = { "action": "query", "list": "search", "srsearch": search, "srnamespace": srnamespace, "srlimit": 1, "srqiprofile": srqiprofile, "srwhat": 'text', ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-3
headers = { 'Accept': 'application/json' } if wikidata_user_agent_header is not None: headers['User-Agent'] = wikidata_user_agent_header response = requests.get(url, headers=headers, params={'query': query, 'format': 'json'}) if response.status_code != 200: return "That query fai...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-4
name = "SparqlQueryRunner", func=run_sparql, description="useful for getting results from a wikibase" ) ] Prompts# # Set up the base template template = """ Answer the following questions by running a sparql query against a wikibase where the p and q items are completely unknown to you. You wil...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-5
Question: {input} {agent_scratchpad}""" # Set up a prompt template class CustomPromptTemplate(StringPromptTemplate): # The template to use template: str # The list of tools available tools: List[Tool] def format(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observat...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-6
if "Final Answer:" in llm_output: return AgentFinish( # Return values is generally always a dictionary with a single `output` key # It is not recommended to try anything else at the moment :) return_values={"output": llm_output.split("Final Answer:")[-1].strip...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-7
Run it!# # If you prefer in-line tracing, uncomment this line # agent_executor.agent.llm_chain.verbose = True agent_executor.run("How many children did J.S. Bach have?") > Entering new AgentExecutor chain... Thought: I need to find the Q number for J.S. Bach. Action: ItemLookup Action Input: J.S. Bach Observation:Q1339...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
6e1030dd3571-8
Action: PropertyLookup Action Input: Basketball-Reference.com NBA player ID Observation:P2685Now that I have both the Q-number for Hakeem Olajuwon (Q273256) and the P-number for the Basketball-Reference.com NBA player ID property (P2685), I can run a SPARQL query to get the ID value. Action: SparqlQueryRunner Action In...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/wikibase_agent.html
2122d7ea14fc-0
.ipynb .pdf Plug-and-Plai Contents Set up environment Setup LLM Set up plugins Tool Retriever Prompt Template Output Parser Set up LLM, stop sequence, and the agent Use the Agent Plug-and-Plai# This notebook builds upon the idea of tool retrieval, but pulls all tools from plugnplai - a directory of AI Plugins. Set up...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
2122d7ea14fc-1
urls = plugnplai.get_plugins(filter = 'working') AI_PLUGINS = [AIPlugin.from_url(url + "/.well-known/ai-plugin.json") for url in urls] Tool Retriever# We will use a vectorstore to create embeddings for each tool description. Then, for an incoming query we can create embeddings for that query and do a similarity search ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
2122d7ea14fc-2
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3....
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
2122d7ea14fc-3
'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.preview_a_zap', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.get_configuration_link', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.list_exposed_actions', 'SchoolDigger_API_V2.0.Autocomplete_GetSchools', 'SchoolDigger_API_V2.0....
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
2122d7ea14fc-4
'SchoolDigger_API_V2.0.Autocomplete_GetSchools', 'SchoolDigger_API_V2.0.Districts_GetAllDistricts2', 'SchoolDigger_API_V2.0.Districts_GetDistrict2', 'SchoolDigger_API_V2.0.Rankings_GetSchoolRank2', 'SchoolDigger_API_V2.0.Rankings_GetRank_District', 'SchoolDigger_API_V2.0.Schools_GetAllSchools20', 'SchoolDigger_AP...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
2122d7ea14fc-5
# The template to use template: str ############## NEW ###################### # The list of tools available tools_getter: Callable def format(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observation tuples) # Format them in a particular way intermed...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html