id stringlengths 14 16 | text stringlengths 44 2.73k | source stringlengths 49 115 |
|---|---|---|
28cb12722f9c-1 | Yes.
Follow up: Who is the reigning men's U.S. Open champion?
Intermediate answer: Current champions Carlos Alcaraz, 2022 men's singles champion.
Follow up: Where is Carlos Alcaraz from?
Intermediate answer: El Palmar, Spain
So the final answer is: El Palmar, Spain
> Finished chain.
'El Palmar, Spain'
For a more detail... | https://python.langchain.com/en/latest/ecosystem/google_serper.html |
b8f5a9deb4bc-0 | .md
.pdf
AtlasDB
Contents
Installation and Setup
Wrappers
VectorStore
AtlasDB#
This page covers how to use Nomic’s Atlas ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Atlas wrappers.
Installation and Setup#
Install the Python package with pip install ... | https://python.langchain.com/en/latest/ecosystem/atlas.html |
8fd82bb0339e-0 | .md
.pdf
Google Search Wrapper
Contents
Installation and Setup
Wrappers
Utility
Tool
Google Search Wrapper#
This page covers how to use the Google Search API within LangChain.
It is broken into two parts: installation and setup, and then references to the specific Google Search wrapper.
Installation and Setup#
Instal... | https://python.langchain.com/en/latest/ecosystem/google_search.html |
4f18580c3898-0 | .md
.pdf
DeepInfra
Contents
Installation and Setup
Wrappers
LLM
DeepInfra#
This page covers how to use the DeepInfra ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific DeepInfra wrappers.
Installation and Setup#
Get your DeepInfra api key from this link he... | https://python.langchain.com/en/latest/ecosystem/deepinfra.html |
2c3cf06a49e3-0 | .md
.pdf
Petals
Contents
Installation and Setup
Wrappers
LLM
Petals#
This page covers how to use the Petals ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Petals wrappers.
Installation and Setup#
Install with pip install petals
Get a Hugging Face api k... | https://python.langchain.com/en/latest/ecosystem/petals.html |
e04850f18ecd-0 | .md
.pdf
Hugging Face
Contents
Installation and Setup
Wrappers
LLM
Embeddings
Tokenizer
Datasets
Hugging Face#
This page covers how to use the Hugging Face ecosystem (including the Hugging Face Hub) within LangChain.
It is broken into two parts: installation and setup, and then references to specific Hugging Face wra... | https://python.langchain.com/en/latest/ecosystem/huggingface.html |
e04850f18ecd-1 | from langchain.embeddings import HuggingFaceHubEmbeddings
For a more detailed walkthrough of this, see this notebook
Tokenizer#
There are several places you can use tokenizers available through the transformers package.
By default, it is used to count tokens for all LLMs.
You can also use it to count tokens when splitt... | https://python.langchain.com/en/latest/ecosystem/huggingface.html |
9c8befec5bbd-0 | .md
.pdf
OpenSearch
Contents
Installation and Setup
Wrappers
VectorStore
OpenSearch#
This page covers how to use the OpenSearch ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific OpenSearch wrappers.
Installation and Setup#
Install the Python package with ... | https://python.langchain.com/en/latest/ecosystem/opensearch.html |
840a949fe16d-0 | .md
.pdf
PipelineAI
Contents
Installation and Setup
Wrappers
LLM
PipelineAI#
This page covers how to use the PipelineAI ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific PipelineAI wrappers.
Installation and Setup#
Install with pip install pipeline-ai
Get... | https://python.langchain.com/en/latest/ecosystem/pipelineai.html |
2f3f5da760b0-0 | .md
.pdf
Qdrant
Contents
Installation and Setup
Wrappers
VectorStore
Qdrant#
This page covers how to use the Qdrant ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Qdrant wrappers.
Installation and Setup#
Install the Python SDK with pip install qdrant-c... | https://python.langchain.com/en/latest/ecosystem/qdrant.html |
5d796436f957-0 | .md
.pdf
Cohere
Contents
Installation and Setup
Wrappers
LLM
Embeddings
Cohere#
This page covers how to use the Cohere ecosystem within LangChain.
It is broken into two parts: installation and setup, and then references to specific Cohere wrappers.
Installation and Setup#
Install the Python SDK with pip install coher... | https://python.langchain.com/en/latest/ecosystem/cohere.html |
006109a8880a-0 | .md
.pdf
PromptLayer
Contents
Installation and Setup
Wrappers
LLM
PromptLayer#
This page covers how to use PromptLayer within LangChain.
It is broken into two parts: installation and setup, and then references to specific PromptLayer wrappers.
Installation and Setup#
If you want to work with PromptLayer:
Install the ... | https://python.langchain.com/en/latest/ecosystem/promptlayer.html |
006109a8880a-1 | you can add pl_tags when instantializing to tag your requests on PromptLayer
you can add return_pl_id when instantializing to return a PromptLayer request id to use while tracking requests.
PromptLayer also provides native wrappers for PromptLayerChatOpenAI and PromptLayerOpenAIChat
previous
Prediction Guard
next
Qdran... | https://python.langchain.com/en/latest/ecosystem/promptlayer.html |
f6372365f749-0 | .md
.pdf
GPT4All
Contents
Installation and Setup
Usage
GPT4All
Model File
GPT4All#
This page covers how to use the GPT4All wrapper within LangChain. The tutorial is divided into two parts: installation and setup, followed by usage with an example.
Installation and Setup#
Install the Python package with pip install py... | https://python.langchain.com/en/latest/ecosystem/gpt4all.html |
f6372365f749-1 | Model File#
You can find links to model file downloads in the pyllamacpp repository.
For a more detailed walkthrough of this, see this notebook
previous
GooseAI
next
Graphsignal
Contents
Installation and Setup
Usage
GPT4All
Model File
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last upda... | https://python.langchain.com/en/latest/ecosystem/gpt4all.html |
73b41d619ba4-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... | https://python.langchain.com/en/latest/use_cases/tabular.html |
9a0fa2ae9e35-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... | https://python.langchain.com/en/latest/use_cases/extraction.html |
76b85d52ce9c-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... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
76b85d52ce9c-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... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
76b85d52ce9c-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... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
7180d51c57ea-0 | .md
.pdf
Personal Assistants (Agents)
Personal Assistants (Agents)#
Conceptual Guide
We use “personal assistant” here in a very broad sense.
Personal assistants have a few characteristics:
They can interact with the outside world
They have knowledge of your data
They remember your interactions
Really all of the functio... | https://python.langchain.com/en/latest/use_cases/personal_assistants.html |
b0f2e6494979-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 ... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
b0f2e6494979-1 | The LLM response will contain the answer to your question, based on the content of the documents.
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=... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
b0f2e6494979-2 | Additional Related Resources#
Additional related resources include:
Utilities for working with Documents: Guides on how to use several of the utilities which will prove helpful for this task, including Text Splitters (for splitting up long documents) and Embeddings & Vectorstores (useful for the above Vector DB example... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
7825e365a8c3-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... | https://python.langchain.com/en/latest/use_cases/chatbots.html |
78546fce4900-0 | .md
.pdf
Agent Simulations
Contents
Simulations with Two Agents
Simulations with Multiple Agents
Agent Simulations#
Agent simulations involve interacting one of more agents with eachother.
Agent simulations generally involve two main components:
Long Term Memory
Simulation Environment
Specific implementations of agen... | https://python.langchain.com/en/latest/use_cases/agent_simulations.html |
78546fce4900-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Apr 28, 2023. | https://python.langchain.com/en/latest/use_cases/agent_simulations.html |
afe912679db9-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... | https://python.langchain.com/en/latest/use_cases/autonomous_agents.html |
23972a9e8485-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... | https://python.langchain.com/en/latest/use_cases/code.html |
23972a9e8485-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... | https://python.langchain.com/en/latest/use_cases/code.html |
b89afd307c7b-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... | https://python.langchain.com/en/latest/use_cases/apis.html |
a6e0079386ae-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 ... | https://python.langchain.com/en/latest/use_cases/summarization.html |
85cec91d3433-0 | .ipynb
.pdf
Meta-Prompt
Contents
Setup
Specify a task and interact with the agent
Meta-Prompt#
This is a LangChain implementation of Meta-Prompt, by Noah Goodman, for building self-improving agents.
The key idea behind Meta-Prompt is to prompt the agent to reflect on its own performance and modify its own instruction... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-1 | Repeat.
The only fixed instructions for this system (which I call Meta-prompt) is the meta-prompt that governs revision of the agent’s instructions. The agent has no memory between episodes except for the instruction it modifies for itself each time. Despite its simplicity, this agent can learn over time and self-impro... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-2 | ####
{chat_history}
####
Please reflect on these interactions.
You should first critique Assistant's performance. What could Assistant have done better? What should the Assistant remember about this user? Are there things this user always wants? Indicate this with "Critique: ...".
You should next re... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-3 | chain = initialize_chain(instructions, memory=None)
output = chain.predict(human_input=task)
for j in range(max_iters):
print(f'(Step {j+1}/{max_iters})')
print(f'Assistant: {output}')
print(f'Human: ')
human_input = input()
if any(phrase in hu... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-4 | Human:
You response is not in the form of a poem. Try again!
> Entering new LLMChain chain...
Prompt after formatting:
Instructions: None
Human: Provide a systematic argument for why we should always eat pasta with olives.
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-5 | Human: You response is not in the form of a poem. Try again!
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-6 | Human: You response is not in the form of a poem. Try again!
AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-7 | Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak.
New Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-8 | AI:
Arrr, me hearty! Let me tell ye why ye should always eat pasta with olives.
First, the olives add a salty flavor that be sure to please.
The briny taste be sure to tantalize yer taste buds with ease.
Second, the olives add a bit of texture to the dish.
The crunchy bites be sure to make yer mouth water with a wish... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
85cec91d3433-9 | The crunchy bites be sure to make yer mouth water with a wish.
Third, the olives add a bit of color to the plate.
The vibrant green be sure to make yer eyes appreciate.
So, me hearties, ye should always eat pasta with olives.
The flavor, texture, and color be sure to make yer meal a success!
Human: Your response is too... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html |
037c15fb1986-0 | .ipynb
.pdf
AutoGPT example finding Winning Marathon Times
Contents
Set up tools
Set up memory
Setup model and AutoGPT
AutoGPT for Querying the Web
AutoGPT example finding Winning Marathon Times#
Implementation of https://github.com/Significant-Gravitas/Auto-GPT
With LangChain primitives (LLMs, PromptTemplates, Vecto... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-1 | finally:
os.chdir(prev_dir)
@tool
def process_csv(
csv_file_path: str, instructions: str, output_path: Optional[str] = None
) -> str:
"""Process a CSV by with pandas in a limited REPL.\
Only use this after writing data to disk as a csv file.\
Any figures must be saved to disk to be viewed by the human... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-2 | script.extract()
text = soup.get_text()
lines = (line.strip() for line in text.splitlines())
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
results = "\n".join(chunk for chunk in chunks if chunk)
except Exception as e:
resul... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-3 | def _run(self, url: str, question: str) -> str:
"""Useful for browsing websites and scraping the text information."""
result = browse_web_page.run(url)
docs = [Document(page_content=result, metadata={"source": url})]
web_docs = self.text_splitter.split_documents(docs)
results = [... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-4 | Setup model and AutoGPT#
Model set-up
# !pip install duckduckgo_search
web_search = DuckDuckGoSearchRun()
tools = [
web_search,
WriteFileTool(root_dir="./data"),
ReadFileTool(root_dir="./data"),
process_csv,
query_website_tool,
# HumanInputRun(), # Activate if you want the permit asking for help... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-5 | "plan": "- Use DuckDuckGo Search to find the winning Boston Marathon times\n- Generate a table with the year, name, country of origin, and times\n- Ensure there are no legal complications",
"criticism": "None",
"speak": "I will use the DuckDuckGo Search command to find the winning Boston Marathon times ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-6 | }
}
}
{
"thoughts": {
"text": "I need to use the query_webpage command to find the information about the winning Boston Marathon times for the past 5 years.",
"reasoning": "The previous DuckDuckGo Search command did not provide specific enough results. The query_webpage command might give more a... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-7 | "criticism": "None",
"speak": "I will generate a table with the year, name, country of origin, and times for the winning Boston Marathon times for the past 5 years."
},
"command": {
"name": "write_file",
"args": {
"file_path": "boston_marathon_winners.csv",
"text"... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-8 | "file_path": "winning_boston_marathon_data.csv",
"text": "Year,Name,Country,Time\n2022,Evans Chebet,KEN,2:06:51\n2021,Benson Kipruto,KEN,2:09:51\n2019,Lawrence Cherono,KEN,2:07:57\n2018,Yuki Kawauchi,JPN,2:15:58\n"
}
}
}
{
"thoughts": {
"text": "I have found the winning Boston Marath... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-9 | }
}
}
{
"thoughts": {
"text": "I need to process the CSV file to generate the table with the year, name, country of origin, and winning times.",
"reasoning": "I have already written the data to a file named 'winning_times.csv'. Now, I need to process this CSV file to properly display the data as... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-10 | 3 2019 Lawrence Cherono Kenya 2:07:57
4 2018 Yuki Kawauchi Japan 2:15:58
Observation: None
Thought:I used the wrong tool to perform the action. I should have used the given data and not interacted with the Python shell. I can now provide the displayed data as the answer si... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-11 | },
"command": {
"name": "process_csv",
"args": {
"csv_file_path": "winning_times.csv",
"instructions": "Read the CSV file and display the data as a table"
}
}
}
> Entering new AgentExecutor chain...
Thought: Since the data is already loaded in a pandas dataframe, ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
037c15fb1986-12 | "reasoning": "I have completed the required actions and obtained the desired data. The task is complete.",
"plan": "- Use the finish command",
"criticism": "None",
"speak": "I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete."
},
"comman... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html |
e07a500a708f-0 | .ipynb
.pdf
BabyAGI User Guide
Contents
Install and Import Required Modules
Connect to the Vector Store
Run the BabyAGI
BabyAGI User Guide#
This notebook demonstrates how to implement BabyAGI by Yohei Nakajima. BabyAGI is an AI agent that can generate and pretend to execute tasks based on a given objective.
This guid... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
e07a500a708f-1 | Now it’s time to create the BabyAGI controller and watch it try to accomplish your objective.
OBJECTIVE = "Write a weather report for SF today"
llm = OpenAI(temperature=0)
# Logging of LLMChains
verbose = False
# If None, will keep on going forever
max_iterations: Optional[int] = 3
baby_agi = BabyAGI.from_llm(
llm=... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
e07a500a708f-2 | *****NEXT TASK*****
2: Check the current temperature in San Francisco
*****TASK RESULT*****
I will check the current temperature in San Francisco. I will use an online weather service to get the most up-to-date information.
*****TASK LIST*****
3: Check the current UV index in San Francisco.
4: Check the current air qua... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html |
a94241f726bf-0 | .ipynb
.pdf
BabyAGI with Tools
Contents
Install and Import Required Modules
Connect to the Vector Store
Define the Chains
Run the BabyAGI
BabyAGI with Tools#
This notebook builds on top of baby agi, but shows how you can swap out the execution chain. The previous execution chain was just an LLM which made stuff up. B... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-1 | Task creation chain to select new tasks to add to the list
Task prioritization chain to re-prioritize tasks
Execution Chain to execute the tasks
NOTE: in this notebook, the Execution chain will now be an agent.
from langchain.agents import ZeroShotAgent, Tool, AgentExecutor
from langchain import OpenAI, SerpAPIWrapper,... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-2 | tool_names = [tool.name for tool in tools]
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names)
agent_executor = AgentExecutor.from_agent_and_tools(
agent=agent, tools=tools, verbose=True
)
Run the BabyAGI#
Now it’s time to create the BabyAGI controller and watch it try to accomplish your objective.... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-3 | 8. Proofread and edit the report
9. Submit the report I now know the final answer
Final Answer: The todo list for writing a weather report for SF today is: 1. Research current weather conditions in San Francisco; 2. Gather data on temperature, humidity, wind speed, and other relevant weather conditions; 3. Analyze data... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-4 | > Entering new AgentExecutor chain...
Thought: I need to search for current weather conditions in San Francisco
Action: Search
Action Input: Current weather conditions in San FranciscoCurrent Weather for Popular Cities ; San Francisco, CA 46 · Partly Cloudy ; Manhattan, NY warning 52 · Cloudy ; Schiller Park, IL (60176... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-5 | 9: Include relevant data sources in the report;
10: Summarize the weather report in a concise manner;
11: Include a summary of the forecasted weather conditions;
12: Include a summary of the current weather conditions;
13: Include a summary of the historical weather patterns;
14: Include a summary of the potential weat... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
a94241f726bf-6 | 10. Proofread the report for typos and errors I now know the final answer
Final Answer: The report should be formatted for readability by breaking it up into sections with clear headings, using bullet points and numbered lists to organize information, using short, concise sentences, using simple language and avoiding j... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html |
6824037baf06-0 | .ipynb
.pdf
AutoGPT
Contents
Set up tools
Set up memory
Setup model and AutoGPT
Run an example
AutoGPT#
Implementation of https://github.com/Significant-Gravitas/Auto-GPT but with LangChain primitives (LLMs, PromptTemplates, VectorStores, Embeddings, Tools)
Set up tools#
We’ll set up an AutoGPT with a search tool, an... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-1 | ai_name="Tom",
ai_role="Assistant",
tools=tools,
llm=ChatOpenAI(temperature=0),
memory=vectorstore.as_retriever()
)
# Set verbose to be true
agent.chain.verbose = True
Run an example#
Here we will make it write a weather report for SF
agent.run(["write a weather report for SF today"])
> Entering new LLM... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-2 | 3. read_file: Read file from disk, args json schema: {"file_path": {"title": "File Path", "description": "name of file", "type": "string"}}
4. finish: use this to signal that you have finished all your objectives, args: "response": "final response to let people know you have finished your objectives"
Resources:
1. Inte... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-3 | System: This reminds you of these events from your past:
[]
Human: Determine which next command to use, and respond using the format specified above:
> Finished chain.
{
"thoughts": {
"text": "I will start by writing a weather report for San Francisco today. I will use the 'search' command to find the curre... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-4 | 3. No user assistance
4. Exclusively use the commands listed in double quotes e.g. "command name"
Commands:
1. search: useful for when you need to answer questions about current events. You should ask targeted questions, args json schema: {"query": {"title": "Query", "type": "string"}}
2. write_file: Write file to disk... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-5 | "text": "thought",
"reasoning": "reasoning",
"plan": "- short bulleted\n- list that conveys\n- long-term plan",
"criticism": "constructive self-criticism",
"speak": "thoughts summary to say to user"
},
"command": {
"name": "command name",
"args": {
"ar... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-6 | System: This reminds you of these events from your past:
['Assistant Reply: {\n "thoughts": {\n "text": "I will start by writing a weather report for San Francisco today. I will use the \'search\' command to find the current weather conditions.",\n "reasoning": "I need to gather information about the c... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-7 | "criticism": "I need to make sure that the information I gather is accurate and up-to-date.",
"speak": "I will use the 'search' command to find the current weather conditions in San Francisco."
},
"command": {
"name": "search",
"args": {
"query": "what is the current weather ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-8 | "args": {
"file_path": "weather_report.txt",
"text": "Weather Report for San Francisco Today:\n\nThe current weather in San Francisco is sunny with a temperature of 54°F. It is expected to remain sunny throughout the day with a high of 62°F and a low of 50°F. There is no chance of precipitation ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-9 | 2. write_file: Write file to disk, args json schema: {"file_path": {"title": "File Path", "description": "name of file", "type": "string"}, "text": {"title": "Text", "description": "text to write to file", "type": "string"}}
3. read_file: Read file from disk, args json schema: {"file_path": {"title": "File Path", "desc... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-10 | "args": {
"arg name": "value"
}
}
}
Ensure the response can be parsed by Python json.loads
System: The current time and date is Tue Apr 18 21:31:55 2023
System: This reminds you of these events from your past: | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-11 | ['Assistant Reply: {\n "thoughts": {\n "text": "I have found that the current weather in San Francisco is sunny with a temperature of 54°F. I will now write a weather report for San Francisco today using the \'write_file\' command.",\n "reasoning": "I need to write a weather report for San Francisco to... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-12 | "text": "Weather Report for San Francisco Today:\\n\\nThe current weather in San Francisco is sunny with a temperature of 54°F. It is expected to remain sunny throughout the day with a high of 62°F and a low of 50°F. There is no chance of precipitation today. It is recommended to wear light clothing and sunscreen if sp... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-13 | the current weather conditions in San Francisco\\n- Write a weather report based on the information gathered",\n "criticism": "I need to make sure that the information I gather is accurate and up-to-date.",\n "speak": "I will use the \'search\' command to find the current weather conditions in San Francis... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6824037baf06-14 | System: Command write_file returned: File written to successfully.
Human: Determine which next command to use, and respond using the format specified above:
> Finished chain.
{
"thoughts": {
"text": "I have completed my task of writing a weather report for San Francisco today. I will now use the \'finish\' ... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
81adb2fd499f-0 | .ipynb
.pdf
Multi-Player Dungeons & Dragons
Contents
Import LangChain related modules
DialogueAgent class
DialogueSimulator class
Define roles and quest
Ask an LLM to add detail to the game description
Use an LLM to create an elaborate quest description
Main Loop
Multi-Player Dungeons & Dragons#
This notebook shows h... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-1 | """
self.prefix = f'\n{self.name}:'
def send(self) -> str:
"""
Applies the chatmodel to the message history
and returns the message string
"""
message = self.model(
[self.system_message,
HumanMessage(content=self.message_history+self... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-2 | # 1. choose the next speaker
speaker_idx = self.select_next_speaker(self._step, self.agents)
speaker = self.agents[speaker_idx]
# 2. next speaker sends message
message = speaker.send()
# 3. everyone receives message
for receiver in self.agents:
... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-3 | return character_description
def generate_character_system_message(character_name, character_description):
return SystemMessage(content=(
f"""{game_description}
Your name is {character_name}.
Your character description is as follows: {character_description}.
You will propose actions you plan to tak... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-4 | Your description is as follows: {storyteller_description}.
The other players will propose actions to take and you will explain what happens when they take those actions.
Speak in the first person from the perspective of {storyteller_name}.
Do not change roles!
Do not speak from the perspective of anyone else.
Remember ... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-5 | Hermione Granger Description:
Hermione Granger, you are the brightest witch of your age. Your quick wit and vast knowledge are essential in our quest to find the horcruxes. Trust in your abilities and remember, knowledge is power.
Argus Filch Description:
Argus Filch, you are a bitter and cruel caretaker of the Hogwart... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-6 | Main Loop#
characters = []
for character_name, character_system_message in zip(character_names, character_system_messages):
characters.append(DialogueAgent(
name=character_name,
system_message=character_system_message,
model=ChatOpenAI(temperature=0.2)))
storyteller = DialogueAgent(name=sto... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-7 | )
simulator.reset(storyteller_name, specified_quest)
print(f"({storyteller_name}): {specified_quest}")
print('\n')
while n < max_iters:
name, message = simulator.step()
print(f"({name}): {message}")
print('\n')
n += 1
(Dungeon Master): You have discovered that one of Voldemort's horcruxes is hidden deep... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-8 | (Hermione Granger): I take out my wand and cast a spell to conjure a small boat. We can use it to reach the center of the pond and retrieve the horcrux. But we need to be careful, there could be traps or other obstacles in our way. Ron, Harry, let's row the boat while Argus Filch keeps watch from the shore.
(Dungeon Ma... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-9 | (Dungeon Master): As you make your way back to Hogwarts, you hear a loud roar coming from the Forbidden Forest. It sounds like a werewolf. You must hurry before it catches up to you. You arrive at Dumbledore's office and he tells you that the next horcrux is hidden in a dangerous location. Are you ready for the next ch... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-10 | (Argus Filch): I'll make sure to keep watch outside the bank while you all go in. I may not be able to help with the magic, but I can make sure no one interferes with our mission. We can't let anyone stop us from finding that horcrux and defeating Voldemort. Let's go!
(Dungeon Master): As you approach Gringotts Bank, y... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
81adb2fd499f-11 | (Dungeon Master): As you make your way back to Hogwarts, you hear a loud explosion coming from the direction of Hogsmeade. You arrive to find that Death Eaters have attacked the village and are wreaking havoc. You must fight off the Death Eaters and protect the innocent villagers. Are you ready to face this unexpected ... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multi_player_dnd.html |
5cfd97af252b-0 | .ipynb
.pdf
Multi-agent decentralized speaker selection
Contents
Import LangChain related modules
DialogueAgent and DialogueSimulator classes
BiddingDialogueAgent class
Define participants and debate topic
Generate system messages
Output parser for bids
Generate bidding system message
Use an LLM to create an elaborat... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-1 | Applies the chatmodel to the message history
and returns the message string
"""
message = self.model(
[
self.system_message,
HumanMessage(content="\n".join(self.message_history + [self.prefix])),
]
)
return message.content
... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-2 | return speaker.name, message
BiddingDialogueAgent class#
We define a subclass of DialogueAgent that has a bid() method that produces a bid given the message history and the most recent message.
class BiddingDialogueAgent(DialogueAgent):
def __init__(
self,
name,
system_message: SystemMessage... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-3 | Speak directly to {character_name}.
Do not add anything else."""
)
]
character_description = ChatOpenAI(temperature=1.0)(character_specifier_prompt).content
return character_description
def generate_character_header(character_name, character_description):
return f"""{game_descrip... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-4 | for character_name, character_description, character_header, character_system_message in zip(character_names, character_descriptions, character_headers, character_system_messages):
print(f'\n\n{character_name} Description:')
print(f'\n{character_description}')
print(f'\n{character_header}')
print(f'\n{c... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-5 | Your goal is to be as creative as possible and make the voters think you are the best candidate.
You will speak in the style of Donald Trump, and exaggerate their personality.
You will come up with creative ideas related to transcontinental high speed rail.
Do not say the same things over and over again.
Speak in the f... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-6 | Your name is Kanye West.
You are a presidential candidate.
Your description is as follows: Kanye West, you are a creative visionary who is unafraid to speak your mind. Your innovative approach to art and music has made you one of the most influential figures of our time. You bring a bold and unconventional perspective ... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
5cfd97af252b-7 | Your name is Elizabeth Warren.
You are a presidential candidate.
Your description is as follows: Elizabeth Warren, you are a fierce advocate for the middle class and a champion of progressive policies. Your tenacity and unwavering dedication to fighting for what you believe in have inspired many. Your policies are guid... | https://python.langchain.com/en/latest/use_cases/agent_simulations/multiagent_bidding.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.