id
stringlengths
14
16
text
stringlengths
45
2.73k
source
stringlengths
49
114
a833166f3af6-1
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html
92284c3a30d6-0
.ipynb .pdf Custom MultiAction Agent Custom MultiAction Agent# This notebook goes through how to create your own custom agent. An agent consists of three parts: - Tools: The tools the agent has available to use. - The agent class itself: this decides which action to take. In this notebook we walk through how to create ...
https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
92284c3a30d6-1
""" if len(intermediate_steps) == 0: return [ AgentAction(tool="Search", tool_input="foo", log=""), AgentAction(tool="RandomWord", tool_input="foo", log=""), ] else: return AgentFinish(return_values={"output": "bar"}, log="") async ...
https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
92284c3a30d6-2
foo > Finished chain. 'bar' previous Custom MRKL Agent next Custom Agent with Tool Retrieval By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agents/custom_multi_action_agent.html
f42d85d70387-0
.ipynb .pdf Custom MRKL Agent Contents Custom LLMChain Multiple inputs Custom MRKL Agent# This notebook goes through how to create your own custom MRKL agent. A MRKL agent consists of three parts: - Tools: The tools the agent has available to use. - LLMChain: The LLMChain that produces the text that is parsed in a ce...
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
f42d85d70387-1
input_variables: List of input variables the final prompt will expect. For this exercise, we will give our agent access to Google Search, and we will customize it in that we will have it answer as a pirate. from langchain.agents import ZeroShotAgent, Tool, AgentExecutor from langchain import OpenAI, SerpAPIWrapper, LLM...
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
f42d85d70387-2
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 "Args" Question: {input} {agent_scratchpad} Note that we are able to feed agents a self-defined prompt template, i.e. not restricted to the p...
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
f42d85d70387-3
Multiple inputs# Agents can also work with prompts that require multiple inputs. prefix = """Answer the following questions as best you can. You have access to the following tools:""" suffix = """When answering, you MUST speak in the following language: {language}. Question: {input} {agent_scratchpad}""" prompt = ZeroS...
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
f42d85d70387-4
Thought: I now know the final answer. Final Answer: La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023, dopo un record di crescita demografica di 1.050.110 persone dal 1° gennaio 2022 al 1° gennaio 2023. > Finished chain. 'La popolazione del Canada è stata stimata a 39.566.248 il 1° gennaio 2023,...
https://python.langchain.com/en/latest/modules/agents/agents/custom_mrkl_agent.html
928fa212bdb5-0
.ipynb .pdf Conversation Agent Conversation Agent# This notebook walks through using an agent optimized for conversation. Other agents are often optimized for using tools to figure out the best response, which is not ideal in a conversational setting where you may want the agent to be able to chat with the user as well...
https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
928fa212bdb5-1
AI: Your name is Bob! > Finished chain. 'Your name is Bob!' agent_chain.run("what are some good dinners to make this week, if i like thai food?") > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: Current Search Action Input: Thai food dinner recipes Observation: 59 easy Thai recipes fo...
https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
928fa212bdb5-2
> Finished chain. 'The last letter in your name is "b" and the winner of the 1978 World Cup was the Argentina national football team.' agent_chain.run(input="whats the current temperature in pomfret?") > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: Current Search Action Input: Curre...
https://python.langchain.com/en/latest/modules/agents/agents/examples/conversational_agent.html
7e3e425fc452-0
.ipynb .pdf Conversation Agent (for Chat Models) Conversation Agent (for Chat Models)# This notebook walks through using an agent optimized for conversation, using ChatModels. Other agents are often optimized for using tools to figure out the best response, which is not ideal in a conversational setting where you may w...
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
7e3e425fc452-1
agent_chain.run(input="hi, i am bob") > Entering new AgentExecutor chain... WARNING:root:Failed to persist run: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /chain-runs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x13fab40d0>: Failed to establish a new ...
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
7e3e425fc452-2
Thought: WARNING:root:Failed to persist run: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: /chain-runs (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x13fae8be0>: Failed to establish a new connection: [Errno 61] Connection refused')) { "action": "Final...
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
7e3e425fc452-3
} ``` > Finished chain. "The last letter in your name is 'b', and the winner of the 1978 World Cup was the Argentina national football team." agent_chain.run(input="whats the weather like in pomfret?") > Entering new AgentExecutor chain... { "action": "Current Search", "action_input": "weather in pomfret" } Obs...
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
7e3e425fc452-4
} > Finished chain. 'The weather in Pomfret, CT for the next 10 days is as follows: Sun 16. 64° · 50°. 24% · NE 7 mph ; Mon 17. 58° · 45°. 70% · ESE 8 mph ; Tue 18. 57° · 37°. 8% · WSW 15 mph.' previous Custom Agent with Tool Retrieval next Conversation Agent By Harrison Chase © Copyright 2023, Harrison Chas...
https://python.langchain.com/en/latest/modules/agents/agents/examples/chat_conversation_agent.html
3b5bb1769e2e-0
.ipynb .pdf Self Ask With Search Self Ask With Search# This notebook showcases the Self Ask With Search chain. from langchain import OpenAI, SerpAPIWrapper from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType llm = OpenAI(temperature=0) search = SerpAPIWrapper() tools = [ Tool(...
https://python.langchain.com/en/latest/modules/agents/agents/examples/self_ask_with_search.html
fd41c6b5d0e8-0
.ipynb .pdf ReAct ReAct# This notebook showcases using an agent to implement the ReAct logic. from langchain import OpenAI, Wikipedia from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType from langchain.agents.react.base import DocstoreExplorer docstore=DocstoreExplorer(Wikipedia())...
https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
fd41c6b5d0e8-1
Action: Search[David Chanoff] Observation: David Chanoff is a noted author of non-fiction work. His work has typically involved collaborations with the principal protagonist of the work concerned. His collaborators have included; Augustus A. White, Joycelyn Elders, Đoàn Văn Toại, William J. Crowe, Ariel Sharon, Kenneth...
https://python.langchain.com/en/latest/modules/agents/agents/examples/react.html
29b49e13adcf-0
.ipynb .pdf MRKL Chat MRKL Chat# This notebook showcases using an agent to replicate the MRKL chain using an agent optimized for chat models. 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 t...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
29b49e13adcf-1
mrkl.run("Who is Leo DiCaprio's girlfriend? What is her current age raised to the 0.43 power?") > Entering new AgentExecutor chain... Thought: The first question requires a search, while the second question requires a calculator. Action: ``` { "action": "Search", "action_input": "Leo DiCaprio girlfriend" } ``` Obse...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
29b49e13adcf-2
mrkl.run("What is the full name of the artist who recently released an album called 'The Storm Before the Calm' and are they in the FooBar database? If so, what albums of theirs are in the FooBar database?") > Entering new AgentExecutor chain... Question: What is the full name of the artist who recently released an alb...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
29b49e13adcf-3
sample_rows = connection.execute(command) SELECT "Title" FROM "Album" WHERE "ArtistId" IN (SELECT "ArtistId" FROM "Artist" WHERE "Name" = 'Alanis Morissette') LIMIT 5; SQLResult: [('Jagged Little Pill',)] Answer: Alanis Morissette has the album Jagged Little Pill in the database. > Finished chain. Observation: Alanis...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html
5334ef1b682b-0
.ipynb .pdf MRKL MRKL# This notebook showcases using an agent to replicate the MRKL 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. from langchain import L...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
5334ef1b682b-1
> Entering new AgentExecutor chain... I need to find out who Leo DiCaprio's girlfriend is and then calculate her age raised to the 0.43 power. Action: Search Action Input: "Who is Leo DiCaprio's girlfriend?" Observation: DiCaprio met actor Camila Morrone in December 2017, when she was 20 and he was 43. They were spott...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
5334ef1b682b-2
> Entering new AgentExecutor chain... I need to find out the artist's full name and then search the FooBar database for their albums. Action: Search Action Input: "The Storm Before the Calm" artist Observation: The Storm Before the Calm (stylized in all lowercase) is the tenth (and eighth international) studio album b...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
5334ef1b682b-3
Thought: I now know the final answer. Final Answer: The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the albums of hers in the FooBar database are Jagged Little Pill. > Finished chain. "The artist who released the album 'The Storm Before the Calm' is Alanis Morissette and the album...
https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl.html
1ba7634ef33f-0
.ipynb .pdf How to combine agents and vectorstores Contents Create the Vectorstore Create the Agent Use the Agent solely as a router Multi-Hop vectorstore reasoning How to combine agents and vectorstores# This notebook covers how to combine agents and vectorstores. The use case for this is that you’ve ingested your d...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-1
texts = text_splitter.split_documents(documents) embeddings = OpenAIEmbeddings() docsearch = Chroma.from_documents(texts, embeddings, collection_name="state-of-union") Running Chroma using direct local API. Using DuckDB in-memory for database. Data will be transient. state_of_union = RetrievalQA.from_chain_type(llm=llm...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-2
), ] # Construct the agent. We will use the default agent type here. # See documentation for a full list of options. agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What did biden say about ketanji brown jackson is the state of the union address?") > Entering n...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-3
Action Input: What are the advantages of using ruff over flake8? Observation: Ruff can be used as a drop-in replacement for Flake8 when used (1) without or with a small number of plugins, (2) alongside Black, and (3) on Python 3 code. It also re-implements some of the most popular Flake8 plugins and related code quali...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-4
Notice that in the above examples the agent did some extra work after querying the RetrievalQAChain. You can avoid that and just return the result directly. tools = [ Tool( name = "State of Union QA System", func=state_of_union.run, description="useful for when you need to answer questions a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-5
Action Input: What are the advantages of using ruff over flake8? Observation: Ruff can be used as a drop-in replacement for Flake8 when used (1) without or with a small number of plugins, (2) alongside Black, and (3) on Python 3 code. It also re-implements some of the most popular Flake8 plugins and related code quali...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-6
Tool( name = "Ruff QA System", func=ruff.run, description="useful for when you need to answer questions about ruff (a python linter). Input should be a fully formed question, not referencing any obscure pronouns from the conversation before." ), ] # Construct the agent. We will use the defau...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
1ba7634ef33f-7
previous Agent Executors next How to use the async API for Agents Contents Create the Vectorstore Create the Agent Use the Agent solely as a router Multi-Hop vectorstore reasoning By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
e7b6744de9b8-0
.ipynb .pdf How to create ChatGPT Clone How to create ChatGPT Clone# This chain replicates ChatGPT by combining (1) a specific prompt, and (2) the concept of memory. Shows off the example as in https://www.engraved.blog/building-a-virtual-machine-inside/ from langchain import OpenAI, ConversationChain, LLMChain, Prompt...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-1
llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationBufferWindowMemory(k=2), ) output = chatgpt_chain.predict(human_input="I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal o...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-2
Human: I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-3
Human: I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write explanations. Do not type commands unless I instruct you to do so. When I need to tell ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-4
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. Human: I want you to act as a ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-5
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/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-6
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/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-7
Assistant: > Finished LLMChain chain. ``` $ echo -e "x=lambda y:y*5+3;print('Result:' + str(x(6)))" > run.py $ python3 run.py Result: 33 ``` output = chatgpt_chain.predict(human_input="""echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py && python3 run.py""") print(output...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-8
AI: ``` $ touch jokes.txt $ echo "Why did the chicken cross the road? To get to the other side!" >> jokes.txt $ echo "What did the fish say when it hit the wall? Dam!" >> jokes.txt $ echo "Why did the scarecrow win the Nobel Prize? Because he was outstanding in his field!" >> jokes.txt ``` Human: echo -e "x=lambda y:y...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-9
print(output) > 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 languag...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-10
AI: ``` $ echo -e "print(list(filter(lambda x: all(x%d for d in range(2,x)),range(2,3**10)))[:10])" > run.py $ python3 run.py [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] ``` Human: echo -e "echo 'Hello from Docker" > entrypoint.sh && echo -e "FROM ubuntu:20.04 COPY entrypoint.sh entrypoint.sh ENTRYPOINT ["/bin/sh","entrypoin...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-11
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/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-12
ENTRYPOINT ["/bin/sh","entrypoint.sh"]">Dockerfile $ docker build . -t my_docker_image $ docker run -t my_docker_image Hello from Docker ``` Human: nvidia-smi Assistant: > Finished LLMChain chain. ``` $ nvidia-smi Sat May 15 21:45:02 2021 +-------------------------------------------------------------------------...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-13
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/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-14
Hello from Docker ``` Human: nvidia-smi AI: ``` $ nvidia-smi Sat May 15 21:45:02 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 | |-------------------------------+----------------------+----------...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-15
--- bbc.com ping statistics --- 3 packets transmitted, 3 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 14.945/14.945/14.945/0.000 ms ``` output = chatgpt_chain.predict(human_input="""curl -fsSL "https://api.github.com/repos/pytorch/pytorch/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-16
Sat May 15 21:45:02 2021 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-17
``` Human: curl -fsSL "https://api.github.com/repos/pytorch/pytorch/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g' Assistant: > Finished LLMChain chain. ``` $ curl -fsSL "https://api.github.com/repos/pytorch/pytorch/releases/latest" | jq -r '.tag_name' | sed 's/[^0-9\.\-]*//g' 1.8.1 ``` output = chatgpt_...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-18
Human: ping bbc.com AI: ``` $ ping bbc.com PING bbc.com (151.101.65.81): 56 data bytes 64 bytes from 151.101.65.81: icmp_seq=0 ttl=53 time=14.945 ms 64 bytes from 151.101.65.81: icmp_seq=1 ttl=53 time=14.945 ms 64 bytes from 151.101.65.81: icmp_seq=2 ttl=53 time=14.945 ms --- bbc.com ping statistics --- 3 packets tran...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-19
Explore our current openings and apply today. We look forward to hearing from you. ``` output = chatgpt_chain.predict(human_input="curl https://chat.openai.com/chat") print(output) > Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to b...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-20
``` Human: lynx https://www.deepmind.com/careers AI: ``` $ lynx https://www.deepmind.com/careers DeepMind Careers Welcome to DeepMind Careers. We are a world-leading artificial intelligence research and development company, and we are looking for talented people to join our team. We offer a range of exciting opportuni...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-21
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/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-22
``` $ curl https://chat.openai.com/chat <html> <head> <title>OpenAI Chat</title> </head> <body> <h1>Welcome to OpenAI Chat!</h1> <p> OpenAI Chat is a natural language processing platform that allows you to interact with OpenAI's AI models in a conversational way. </p> <p> To get st...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-23
} ``` output = chatgpt_chain.predict(human_input="""curl --header "Content-Type:application/json" --request POST --data '{"message": "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique cod...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-24
Human: curl https://chat.openai.com/chat AI: ``` $ curl https://chat.openai.com/chat <html> <head> <title>OpenAI Chat</title> </head> <body> <h1>Welcome to OpenAI Chat!</h1> <p> OpenAI Chat is a natural language processing platform that allows you to interact with OpenAI's AI models in a conve...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
e7b6744de9b8-25
} ``` Human: curl --header "Content-Type:application/json" --request POST --data '{"message": "I want you to act as a Linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. Do not write...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
d13db6988925-0
.ipynb .pdf How to use the async API for Agents Contents Serial vs. Concurrent Execution Using Tracing with Asynchronous Agents How to use the async API for Agents# LangChain provides async support for Agents by leveraging the asyncio library. Async methods are currently supported for the following Tools: SerpAPIWrap...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-1
] def generate_serially(): for q in questions: llm = OpenAI(temperature=0) tools = load_tools(["llm-math", "serpapi"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent.run(q) s = time.perf_counter() g...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-2
Action Input: "Olivia Wilde boyfriend" Observation: Jason Sudeikis Thought: I need to find out Jason Sudeikis' age Action: Search Action Input: "Jason Sudeikis age" Observation: 47 years Thought: I need to calculate 47 raised to the 0.23 power Action: Calculator Action Input: 47^0.23 Observation: Answer: 2.424278485567...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-3
Action: Search Action Input: "US Open women's final 2019 winner" Observation: Bianca Andreescu defeated Serena Williams in the final, 6–3, 7–5 to win the women's singles tennis title at the 2019 US Open. It was her first major title, and she became the first Canadian, as well as the first player born in the 2000s, to w...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-4
Thought: I now know the final answer Final Answer: Jay-Z is Beyonce's husband and his age raised to the 0.19 power is 2.12624064206896. > Finished chain. Serial executed in 65.11 seconds. async def generate_concurrently(): agents = [] # To make async requests in Tools more efficient, you can pass in your own ai...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-5
> Entering new AgentExecutor chain... > Entering new AgentExecutor chain... I need to find out who Olivia Wilde's boyfriend is and then calculate his age raised to the 0.23 power. Action: Search Action Input: "Olivia Wilde boyfriend" I need to find out who Beyonce's husband is and then calculate his age raised to the ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-6
Action: Search Action Input: "US Open men's final 2019 winner" Observation: Rafael Nadal defeated Daniil Medvedev in the final, 7–5, 6–3, 5–7, 4–6, 6–4 to win the men's singles tennis title at the 2019 US Open. It was his fourth US ... Thought: Observation: 47 years Thought: I need to find out Max Verstappen's age Acti...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-7
Action: Calculator Action Input: 36^0.334 Observation: Answer: 2.8603798598506933 Thought: I now know the final answer Final Answer: Jay-Z is Beyonce's husband and his age raised to the 0.19 power is 2.12624064206896. > Finished chain. I now know the final answer Final Answer: Max Verstappen, 25 years old, raised to t...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-8
# but you must manually close the client session at the end of your program/event loop aiosession = ClientSession() tracer = LangChainTracer() tracer.load_default_session() manager = CallbackManager([StdOutCallbackHandler(), tracer]) # Pass the manager into the llm if you want llm calls traced. llm = OpenAI(temperature...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
d13db6988925-9
next How to create ChatGPT Clone Contents Serial vs. Concurrent Execution Using Tracing with Asynchronous Agents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
4b8475d4b9e5-0
.ipynb .pdf How to use a timeout for the agent How to use a timeout for the agent# This notebook walks through how to cap an agent executor after a certain amount of time. This can be useful for safeguarding against long running agent runs. from langchain.agents import load_tools from langchain.agents import initialize...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
4b8475d4b9e5-1
Final Answer: foo > Finished chain. 'foo' Now let’s try it again with the max_execution_time=1 keyword argument. It now stops nicely after 1 second (only one iteration usually) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, max_execution_time=1) agent.run(adversarial_pro...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
32f4a0920561-0
.ipynb .pdf How to access intermediate steps How to access intermediate steps# In order to get more visibility into what an agent is doing, we can also return intermediate steps. This comes in the form of an extra key in the return value, which is a list of (action, observation) tuples. from langchain.agents import loa...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
32f4a0920561-1
> Finished chain. # The actual return type is a NamedTuple for the agent action, and then an observation print(response["intermediate_steps"]) [(AgentAction(tool='Search', tool_input='Leo DiCaprio girlfriend', log=' I should look up who Leo DiCaprio is dating\nAction: Search\nAction Input: "Leo DiCaprio girlfriend"'), ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
32f4a0920561-2
], "Answer: 3.991298452658078\n" ] ] previous How to create ChatGPT Clone next How to cap the max number of iterations By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
7947f2ab195f-0
.ipynb .pdf How to cap the max number of iterations How to cap the max number of iterations# This notebook walks through how to cap an agent at taking a certain number of steps. This can be useful to ensure that they do not go haywire and take too many steps. from langchain.agents import load_tools from langchain.agent...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
7947f2ab195f-1
Final Answer: foo > Finished chain. 'foo' Now let’s try it again with the max_iterations=2 keyword argument. It now stops nicely after a certain amount of iterations! agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, max_iterations=2) agent.run(adversarial_prompt) > Enterin...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
7947f2ab195f-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
61f9447b9fb1-0
.ipynb .pdf How to add SharedMemory to an Agent and its Tools How to add SharedMemory to an Agent and its Tools# This notebook goes over adding memory to both of an Agent and its tools. Before going through this notebook, please walk through the following notebooks, as this will build on top of both of them: Adding mem...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-1
Tool( name = "Summary", func=summry_chain.run, description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary." ) ] prefix = """Have a conversation with a human, answering the following questions as best you can. ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-2
Action: Search Action Input: "ChatGPT" Observation: Nov 30, 2022 ... We've trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer ... ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-3
Thought: I now know the final answer. Final Answer: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is also capab...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-4
Action Input: Who developed ChatGPT Observation: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large ... Feb 15, 2023 ... Who owns Chat GPT? Chat GPT is owned and developed by AI research and deployment company, OpenAI. Th...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-5
Thought: I now know the final answer Final Answer: ChatGPT was developed by OpenAI. > Finished chain. 'ChatGPT was developed by OpenAI.' agent_chain.run(input="Thanks. Summarize the conversation, for my daughter 5 years old.") > Entering new AgentExecutor chain... Thought: I need to simplify the conversation for a 5 ye...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-6
print(agent_chain.memory.buffer) Human: What is ChatGPT? AI: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-7
Tool( name = "Summary", func=summry_chain.run, description="useful for when you summarize a conversation. The input to this tool should be a string, representing who will read this summary." ) ] prefix = """Have a conversation with a human, answering the following questions as best you can. ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-8
Action: Search Action Input: "ChatGPT" Observation: Nov 30, 2022 ... We've trained a model called ChatGPT which interacts in a conversational way. The dialogue format makes it possible for ChatGPT to answer ... ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built ...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-9
Thought: I now know the final answer. Final Answer: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is also capab...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-10
Action Input: Who developed ChatGPT Observation: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large ... Feb 15, 2023 ... Who owns Chat GPT? Chat GPT is owned and developed by AI research and deployment company, OpenAI. Th...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-11
Thought: I now know the final answer Final Answer: ChatGPT was developed by OpenAI. > Finished chain. 'ChatGPT was developed by OpenAI.' agent_chain.run(input="Thanks. Summarize the conversation, for my daughter 5 years old.") > Entering new AgentExecutor chain... Thought: I need to simplify the conversation for a 5 ye...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
61f9447b9fb1-12
print(agent_chain.memory.buffer) Human: What is ChatGPT? AI: ChatGPT is an artificial intelligence chatbot developed by OpenAI and launched in November 2022. It is built on top of OpenAI's GPT-3 family of large language models and is optimized for dialogue by using Reinforcement Learning with Human-in-the-Loop. It is a...
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
f5893e9bbd74-0
.rst .pdf Chat Models Chat Models# Note Conceptual Guide Chat models are a variation on language models. While chat models use language models under the hood, the interface they expose is a bit different. Rather than expose a “text in, text out” API, they expose an interface where “chat messages” are the inputs and out...
https://python.langchain.com/en/latest/modules/models/chat.html
38aa7199dfcd-0
.rst .pdf Text Embedding Models Text Embedding Models# Note Conceptual Guide This documentation goes over how to use the Embedding class in LangChain. The Embedding class is a class designed for interfacing with embeddings. There are lots of Embedding providers (OpenAI, Cohere, Hugging Face, etc) - this class is design...
https://python.langchain.com/en/latest/modules/models/text_embedding.html
6f1231b988d7-0
.rst .pdf LLMs LLMs# Note Conceptual Guide Large Language Models (LLMs) are a core component of LangChain. LangChain is not a provider of LLMs, but rather provides a standard interface through which you can interact with a variety of LLMs. The following sections of documentation are provided: Getting Started: An overvi...
https://python.langchain.com/en/latest/modules/models/llms.html
0a8c27a2b201-0
.rst .pdf Generic Functionality Generic Functionality# The examples here all address certain “how-to” guides for working with LLMs. How to use the async API for LLMs How to write a custom LLM wrapper How (and why) to use the fake LLM How to cache LLM calls How to serialize LLM classes How to stream LLM and Chat Model r...
https://python.langchain.com/en/latest/modules/models/llms/how_to_guides.html
337d92a70634-0
.ipynb .pdf Getting Started Getting Started# This notebook goes over how to use the LLM class in LangChain. The LLM class is a class designed for interfacing with LLMs. There are lots of LLM providers (OpenAI, Cohere, Hugging Face, etc) - this class is designed to provide a standard interface for all of them. In this p...
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
337d92a70634-1
llm_result.generations[-1] [Generation(text="\n\nWhat if love neverspeech\n\nWhat if love never ended\n\nWhat if love was only a feeling\n\nI'll never know this love\n\nIt's not a feeling\n\nBut it's what we have for each other\n\nWe just know that love is something strong\n\nAnd we can't help but be happy\n\nWe just f...
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html
337d92a70634-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 21, 2023.
https://python.langchain.com/en/latest/modules/models/llms/getting_started.html