id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
b3c82e200d2e-0
.ipynb .pdf Data Augmented Question Answering Contents Setup Examples Evaluate Evaluate with Other Metrics Data Augmented Question Answering# This notebook uses some generic prompts/language models to evaluate an question answering system that uses other sources of data besides what is in the model. For example, this...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-1
"answer": "Nothing" } ] # Generated examples from langchain.evaluation.qa import QAGenerateChain example_gen_chain = QAGenerateChain.from_llm(OpenAI()) new_examples = example_gen_chain.apply_and_parse([{"doc": t} for t in texts[:5]]) new_examples [{'query': 'According to the document, what did Vladimir Putin miscal...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-2
eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(examples, predictions) for i, eg in enumerate(examples): print(f"Example {i}:") print("Question: " + predictions[i]['query']) print("Real Answer: " + predictions[i]['answer']) print("Predicted Answer: " + predictions[i]['result'...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-3
Real Answer: The Ukrainian Ambassador to the United States is here tonight. Predicted Answer: I don't know. Predicted Grade: INCORRECT Example 4: Question: How many countries were part of the coalition formed to confront Putin? Real Answer: 27 members of the European Union, France, Germany, Italy, the United Kingdom,...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-4
Predicted Grade: CORRECT Evaluate with Other Metrics# In addition to predicting whether the answer is correct or incorrect using a language model, we can also use other metrics to get a more nuanced view on the quality of the answers. To do so, we can use the Critique library, which allows for simple calculation of va...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-5
for k, v in metrics.items() } Finally, we can print out the results. We can see that overall the scores are higher when the output is semantically correct, and also when the output closely matches with the gold-standard answer. for i, eg in enumerate(examples): score_string = ", ".join([f"{k}={v['examples'][i]['val...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-6
Example 2: Question: According to the document, what did Vladimir Putin miscalculate? Real Answer: He miscalculated that he could roll into Ukraine and the world would roll over. Predicted Answer: Putin miscalculated that the world would roll over when he rolled into Ukraine. Predicted Scores: rouge=0.5185, chrf=0.695...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
b3c82e200d2e-7
Question: What action is the U.S. Department of Justice taking to target Russian oligarchs? Real Answer: The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs and joining with European allies to find and seize their yachts, luxury apartments, and private jets. P...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
22f772b5269b-0
.ipynb .pdf SQL Question Answering Benchmarking: Chinook Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance SQL Question Answering Benchmarking: Chinook# Here we go over how to benchmark performance on a question answering task over a SQL database. It is highly r...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
22f772b5269b-1
{'question': 'How many employees are there?', 'answer': '8'} Setting up a chain# This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository. Note that here we load a simple c...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
22f772b5269b-2
llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(predicted_dataset, predictions, question_key="question", prediction_key="result") We can add in the graded output to the predictions dict and then get a count of the grades. for i, prediction in enumerate(predictions...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
d80cdb2309f3-0
.ipynb .pdf Benchmarking Template Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Benchmarking Template# This is an example notebook that can be used to create a benchmarking notebook for a task of your choice. Evaluation is really hard, and so we greatly welc...
https://python.langchain.com/en/latest/use_cases/evaluation/benchmarking_template.html
d80cdb2309f3-1
Evaluate performance# Any guide to evaluating performance in a more systematic manner goes here. previous Agent VectorDB Question Answering Benchmarking next Data Augmented Question Answering Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance By Harrison Chase ...
https://python.langchain.com/en/latest/use_cases/evaluation/benchmarking_template.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
67d5b89e089b-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
a51d56fca490-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
a51d56fca490-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
a51d56fca490-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
a51d56fca490-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
a51d56fca490-4
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 from the human ] agent =...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-5
"criticism": "None", "speak": "I will use the DuckDuckGo Search command to find the winning Boston Marathon times for the past 5 years." }, "command": { "name": "DuckDuckGo Search", "args": { "query": "winning Boston Marathon times for the past 5 years ending in 2022" ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-6
"reasoning": "The previous DuckDuckGo Search command did not provide specific enough results. The query_webpage command might give more accurate and comprehensive results.", "plan": "- Use query_webpage command to find the winning Boston Marathon times\\n- Generate a table with the year, name, country of origin...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-7
"file_path": "boston_marathon_winners.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" } } } { "thoughts": { "text": "I have retrieved the winning Boston Marathon ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-8
} } } { "thoughts": { "text": "I have found the winning Boston Marathon times for the past five years ending in 2022. Next, I need to create a table with the year, name, country of origin, and times.", "reasoning": "Generating a table will help organize the information in a structured format.", ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-9
"criticism": "None", "speak": "I will process the 'winning_times.csv' file to display the table with the winning Boston Marathon times for the past 5 years." }, "command": { "name": "process_csv", "args": { "csv_file_path": "winning_times.csv", "instructions": "Re...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-10
0 2022 Evans Chebet Kenya 2:06:51 1 2021 Benson Kipruto Kenya 2:09:51 2 2020 Canceled due to COVID-19 pandemic NaN NaN 3 2019 Lawrence Cherono Kenya 2:07:57 4 2018 Yuki Kawauchi Japan 2:15:58 > Finished chain. { ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-11
Action Input: df.head() Observation: Year Name Country Time 0 2022 Evans Chebet Kenya 2:06:51 1 2021 Benson Kipruto Kenya 2:09:51 2 2020 Canceled due to COVID-19 pandemic NaN NaN 3 2019 Lawrence Cherono ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
a51d56fca490-12
"command": { "name": "finish", "args": { "response": "I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete." } } } 'I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete.' Contents ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/marathon_times.html
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-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
4fd1ca192702-8
Human: Provide a systematic argument for why we should always eat pasta with olives. 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 ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html
4fd1ca192702-9
Second, the olives add a bit of texture to the dish. 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...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/meta_prompt.html
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-7
"plan": "- Use the 'search' command to find the current weather conditions in San Francisco\n- Write a weather report based on the information gathered", "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 cu...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html
35aa43d5e8df-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
35aa43d5e8df-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
35aa43d5e8df-10
"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
35aa43d5e8df-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
35aa43d5e8df-12
\nResult: Command write_file returned: File written to successfully. ', '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 informati...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html
35aa43d5e8df-13
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
0f851b8eba18-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
0f851b8eba18-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
0f851b8eba18-2
llm_chain = LLMChain(llm=llm, prompt=prompt) 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 a...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html
0f851b8eba18-3
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 to determine current weather tre...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html
0f851b8eba18-4
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) 40 · Sunny ; Boston, MA 54 ... I nee...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html
0f851b8eba18-5
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 weather-related hazards; 15: Include a summary of th...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi_with_agent.html
0f851b8eba18-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
c443d8c8f77e-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
c443d8c8f77e-1
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=llm, vectorstore=vectorstore, verbose=verbose, max_iterations=max_iterations ) baby_agi({"obje...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html
c443d8c8f77e-2
*****TASK LIST***** 3: Check the current UV index in San Francisco. 4: Check the current air quality in San Francisco. 5: Check the current precipitation levels in San Francisco. 6: Check the current cloud cover in San Francisco. 7: Check the current barometric pressure in San Francisco. 8: Check the current dew point ...
https://python.langchain.com/en/latest/use_cases/autonomous_agents/baby_agi.html
e1bdd4c18f0d-0
.ipynb .pdf Generative Agents in LangChain Contents Generative Agent Memory Components Memory Lifecycle Create a Generative Character Pre-Interview with Character Step through the day’s observations. Interview after the day Adding Multiple Characters Pre-conversation interviews Dialogue between Generative Agents Let’...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-1
Memories are retrieved using a weighted sum of salience, recency, and importance. You can review the definitions of the GenerativeAgent and GenerativeAgentMemory in the reference documentation for the following imports, focusing on add_memory and summarize_related_memories methods. from langchain.experimental.generativ...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-2
def create_new_memory_retriever(): """Create a new vector store retriever unique to the agent.""" # Define your embedding model embeddings_model = OpenAIEmbeddings() # Initialize the vectorstore as empty embedding_size = 1536 index = faiss.IndexFlatL2(embedding_size) vectorstore = FAISS(embe...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-3
# We can add memories directly to the memory object tommie_observations = [ "Tommie remembers his dog, Bruno, from when he was a kid", "Tommie feels tired from driving so far", "Tommie sees the new home", "The new neighbors have a cat", "The road is noisy at night", "Tommie is hungry", "Tomm...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-4
interview_agent(tommie, "What are you looking forward to doing today?") 'Tommie said "Well, I\'m actually looking for a job right now, so hopefully I can find some job postings online and start applying. How about you, Person A? What\'s on your schedule for today?"' interview_agent(tommie, "What are you most worried ab...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-5
"Tommie leaves the job fair feeling disappointed.", "Tommie stops by a local diner to grab some lunch.", "The service is slow, and Tommie has to wait for 30 minutes to get his food.", "Tommie overhears a conversation at the next table about a job opening.", "Tommie asks the diners about the job opening ...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-6
print(colored(observation, "green"), reaction) if ((i+1) % 20) == 0: print('*'*40) print(colored(f"After {i+1} observations, Tommie's summary is:\n{tommie.get_summary(force_refresh=True)}", "blue")) print('*'*40) Tommie wakes up to the sound of a noisy construction site outside his window. T...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-7
Tommie meets several potential employers at the job fair but doesn't receive any offers. Tommie feels disappointed and discouraged, but he remains determined to keep searching for job opportunities. Tommie leaves the job fair feeling disappointed. Tommie feels disappointed and discouraged, but he remains determined to ...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-8
Innate traits: anxious, likes design, talkative Tommie is determined and hopeful in his search for job opportunities, despite encountering setbacks and disappointments. He is also able to take breaks and care for his physical needs, such as getting rest and satisfying his hunger. Tommie is nostalgic towards his past, a...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-9
interview_agent(tommie, "Tell me about how your day has been going") 'Tommie said "It\'s been a bit of a rollercoaster, to be honest. I\'ve had some setbacks in my job search, but I also had some good moments today, like sending out a few resumes and meeting some potential employers at a job fair. How about you?"' inte...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-10
eve_observations = [ "Eve wakes up and hear's the alarm", "Eve eats a boal of porridge", "Eve helps a coworker on a task", "Eve plays tennis with her friend Xu before going to work", "Eve overhears her colleague say something about Tommie being hard to work with", ] for observation in eve_observatio...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-11
interview_agent(eve, "You'll have to ask him. He may be a bit anxious, so I'd appreciate it if you keep the conversation going and ask as many questions as possible.") 'Eve said "Sure, I can keep the conversation going and ask plenty of questions. I want to make sure Tommie feels comfortable and supported. Thanks for l...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-12
Eve said "Sure, I'd be happy to share my previous work experience with you. I've worked in a few different industries, including marketing and event planning. What specific questions do you have for me?" Tommie said "That's great to hear. Can you tell me more about your experience in event planning? I've always been in...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-13
Eve said "Of course, Tommie. One example of an unexpected issue I faced was when one of the vendors didn't show up on time. To handle this, I quickly contacted a backup vendor and was able to get everything back on track. It's always important to have a backup plan in case things don't go as planned. Do you have any ot...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-14
Innate traits: anxious, likes design, talkative Tommie is determined and hopeful in his job search, but can also feel discouraged and frustrated at times. He has a strong connection to his childhood dog, Bruno. Tommie seeks support from his friends when feeling overwhelmed and is grateful for their help. He also enjoys...
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
e1bdd4c18f0d-15
Step through the day’s observations. Interview after the day Adding Multiple Characters Pre-conversation interviews Dialogue between Generative Agents Let’s interview our agents after their conversation By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 11, 2023.
https://python.langchain.com/en/latest/use_cases/agent_simulations/characters.html
f26d71e83123-0
.ipynb .pdf Multi-Agent Simulated Environment: Petting Zoo Contents Install pettingzoo and other dependencies Import modules GymnasiumAgent Main loop PettingZooAgent Rock, Paper, Scissors ActionMaskAgent Tic-Tac-Toe Texas Hold’em No Limit Multi-Agent Simulated Environment: Petting Zoo# In this example, we show how to...
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
f26d71e83123-1
Observation: <observation> Reward: <reward> Termination: <termination> Truncation: <truncation> Return: <sum_of_rewards> You will respond with an action, formatted as: Action: <action> where you replace <action> with your actual action. Do nothing else but return the action. """ self.action_parser = RegexParser...
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html
f26d71e83123-2
retry=tenacity.retry_if_exception_type(ValueError), before_sleep=lambda retry_state: print(f"ValueError occurred: {retry_state.outcome.exception()}, retrying..."), ): with attempt: action = self._act() except tenacit...
https://python.langchain.com/en/latest/use_cases/agent_simulations/petting_zoo.html