id
stringlengths
14
16
text
stringlengths
44
2.73k
source
stringlengths
49
115
8c9a3f326c95-1
toolkit = PowerBIToolkit( powerbi=PowerBIDataset(dataset_id="<dataset_id>", table_names=['table1', 'table2'], credential=DefaultAzureCredential()), llm=smart_llm ) agent_executor = create_pbi_agent( llm=fast_llm, toolkit=toolkit, verbose=True, ) Example: describing a table# agent_executor.run("Desc...
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html
8c9a3f326c95-2
examples=few_shots, ) agent_executor = create_pbi_agent( llm=fast_llm, toolkit=toolkit, verbose=True, ) agent_executor.run("What was the maximum of value in revenue in dollars in 2022?") previous Pandas Dataframe Agent next Python Agent Contents Some notes Initialization Example: describing a table Exam...
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/powerbi.html
28d6c1430b7e-0
.ipynb .pdf Jira Jira# This notebook goes over how to use the Jira tool. The Jira tool allows agents to interact with a given Jira instance, performing actions such as searching for issues and creating issues, the tool wraps the atlassian-python-api library, for more see: https://atlassian-python-api.readthedocs.io/jir...
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/jira.html
28d6c1430b7e-1
Observation: None Thought: I now know the final answer Final Answer: A new issue has been created in project PW with the summary "Make more fried rice" and description "Reminder to make more fried rice". > Finished chain. 'A new issue has been created in project PW with the summary "Make more fried rice" and descriptio...
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/jira.html
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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
38e8fc1cd9dd-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 28, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
166fcd4fc304-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
166fcd4fc304-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
07bd751f6138-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
07bd751f6138-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
07bd751f6138-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 28, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
f746923a32c0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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
539a71bc3ac0-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 28, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
e2e8ac27abf9-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
e2e8ac27abf9-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
e2e8ac27abf9-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 28, 2023.
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
b8fd92acc541-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
aea3450e6400-0
.rst .pdf How-To Guides Contents Types Usage How-To Guides# Types# The first set of examples all highlight different types of memory. ConversationBufferMemory ConversationBufferWindowMemory Entity Memory Conversation Knowledge Graph Memory ConversationSummaryMemory ConversationSummaryBufferMemory ConversationTokenBuf...
https://python.langchain.com/en/latest/modules/memory/how_to_guides.html
c9afcfaa2b4e-0
.ipynb .pdf Getting Started Contents ChatMessageHistory ConversationBufferMemory Using in a chain Saving Message History Getting Started# This notebook walks through how LangChain thinks about memory. Memory involves keeping a concept of state around throughout a user’s interactions with an language model. A user’s i...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
c9afcfaa2b4e-1
history.messages [HumanMessage(content='hi!', additional_kwargs={}), AIMessage(content='whats up?', additional_kwargs={})] ConversationBufferMemory# We now show how to use this simple concept in a chain. We first showcase ConversationBufferMemory which is just a wrapper around ChatMessageHistory that extracts the mess...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
c9afcfaa2b4e-2
Current conversation: Human: Hi there! AI: > Finished chain. " Hi there! It's nice to meet you. How can I help you today?" conversation.predict(input="I'm doing well! Just having a conversation with an AI.") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation betw...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
c9afcfaa2b4e-3
Human: Tell me about yourself. AI: > Finished chain. " Sure! I'm an AI created to help people with their everyday tasks. I'm programmed to understand natural language and provide helpful information. I'm also constantly learning and updating my knowledge base so I can provide more accurate and helpful answers." Saving ...
https://python.langchain.com/en/latest/modules/memory/getting_started.html
76e560005a67-0
.ipynb .pdf Adding Message Memory backed by a database to an Agent Adding Message Memory backed by a database to an Agent# This notebook goes over adding memory to an Agent where the memory uses an external message store. Before going through this notebook, please walkthrough the following notebooks, as this will build...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-1
{chat_history} Question: {input} {agent_scratchpad}""" prompt = ZeroShotAgent.create_prompt( tools, prefix=prefix, suffix=suffix, input_variables=["input", "chat_history", "agent_scratchpad"] ) Now we can create the ChatMessageHistory backed by the database. message_history = RedisChatMessageHistory(...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-2
Action: Search Action Input: Population of Canada Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. · Canada ... Additional information related to Canadian population trends can be found on Statistics Canada...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-3
> Finished AgentExecutor chain. 'The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data.' To test the memory of this agent, we can ask a followup question that relies on information in the previous exchange to be answered corr...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-4
Action: Search Action Input: National Anthem of Canada Observation: Jun 7, 2010 ... https://twitter.com/CanadaImmigrantCanadian National Anthem O Canada in HQ - complete with lyrics, captions, vocals & music.LYRICS:O Canada! Nov 23, 2022 ... After 100 years of tradition, O Canada was proclaimed Canada's national anthem...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-5
Thought: I now know the final answer. Final Answer: The national anthem of Canada is called "O Canada". > Finished AgentExecutor chain. 'The national anthem of Canada is called "O Canada".' We can see that the agent remembered that the previous question was about Canada, and properly asked Google Search what the name o...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-6
Action: Search Action Input: Population of Canada Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. · Canada ... Additional information related to Canadian population trends can be found on Statistics Canada...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-7
> Finished AgentExecutor chain. 'The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data.' agent_without_memory.run("what is their national anthem called?") > Entering new AgentExecutor chain... Thought: I should look up the an...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-8
Action: Search Action Input: national anthem of [country] Observation: Most nation states have an anthem, defined as "a song, as of praise, devotion, or patriotism"; most anthems are either marches or hymns in style. List of all countries around the world with its national anthem. ... Title and lyrics in the language o...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
76e560005a67-9
Thought: I now know the final answer Final Answer: The national anthem of [country] is [name of anthem]. > Finished AgentExecutor chain. 'The national anthem of [country] is [name of anthem].' previous How to add Memory to an Agent next How to customize conversational memory By Harrison Chase © Copyright 202...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory_in_db.html
f7b588663baa-0
.ipynb .pdf How to add memory to a Multi-Input Chain How to add memory to a Multi-Input Chain# Most memory objects assume a single output. In this notebook, we go over how to add memory to a chain that has multiple outputs. As an example of such a chain, we will add memory to a question/answering chain. This chain take...
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory_chain_multiple_inputs.html
f7b588663baa-1
{context} {chat_history} Human: {human_input} Chatbot:""" prompt = PromptTemplate( input_variables=["chat_history", "human_input", "context"], template=template ) memory = ConversationBufferMemory(memory_key="chat_history", input_key="human_input") chain = load_qa_chain(OpenAI(temperature=0), chain_type="stuff...
https://python.langchain.com/en/latest/modules/memory/examples/adding_memory_chain_multiple_inputs.html
bb37ea2b83ee-0
.ipynb .pdf How to use multiple memory classes in the same chain How to use multiple memory classes in the same chain# It is also possible to use multiple memory classes in the same chain. To combine multiple memory classes, we can initialize the CombinedMemory class, and then use that. from langchain.llms import OpenA...
https://python.langchain.com/en/latest/modules/memory/examples/multiple_memory.html
bb37ea2b83ee-1
Summary of conversation: Current conversation: Human: Hi! AI: > Finished chain. ' Hi there! How can I help you?' conversation.run("Can you tell me a joke?") > Entering new ConversationChain chain... Prompt after formatting: The following is a friendly conversation between a human and an AI. The AI is talkative and prov...
https://python.langchain.com/en/latest/modules/memory/examples/multiple_memory.html
ee8655453ce8-0
.ipynb .pdf Postgres Chat Message History Postgres Chat Message History# This notebook goes over how to use Postgres to store chat message history. from langchain.memory import PostgresChatMessageHistory history = PostgresChatMessageHistory(connection_string="postgresql://postgres:mypassword@localhost/chat_history", se...
https://python.langchain.com/en/latest/modules/memory/examples/postgres_chat_message_history.html
be086683a48d-0
.ipynb .pdf Redis Chat Message History Redis Chat Message History# This notebook goes over how to use Redis to store chat message history. from langchain.memory import RedisChatMessageHistory history = RedisChatMessageHistory("foo") history.add_user_message("hi!") history.add_ai_message("whats up?") history.messages [A...
https://python.langchain.com/en/latest/modules/memory/examples/redis_chat_message_history.html
2b3128458c7c-0
.ipynb .pdf How to create a custom Memory class How to create a custom Memory class# Although there are a few predefined types of memory in LangChain, it is highly possible you will want to add your own type of memory that is optimal for your application. This notebook covers how to do that. For this notebook, we will ...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
2b3128458c7c-1
"""Define the variables we are providing to the prompt.""" return [self.memory_key] def load_memory_variables(self, inputs: Dict[str, Any]) -> Dict[str, str]: """Load the memory variables, in this case the entity key.""" # Get the input text and run through spacy doc = nlp(inputs[lis...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
2b3128458c7c-2
{entities} Conversation: Human: {input} AI:""" prompt = PromptTemplate( input_variables=["entities", "input"], template=template ) And now we put it all together! llm = OpenAI(temperature=0) conversation = ConversationChain(llm=llm, prompt=prompt, verbose=True, memory=SpacyEntityMemory()) In the first example, with...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
2b3128458c7c-3
Relevant entity information: Harrison likes machine learning Conversation: Human: What do you think Harrison's favorite subject in college was? AI: > Finished ConversationChain chain. ' From what I know about Harrison, I believe his favorite subject in college was machine learning. He has expressed a strong interest in...
https://python.langchain.com/en/latest/modules/memory/examples/custom_memory.html
6717b8584a7a-0
.ipynb .pdf How to add Memory to an Agent How to add Memory to an Agent# This notebook goes over adding memory to an Agent. Before going through this notebook, please walkthrough the following notebooks, as this will build on top of both of them: Adding memory to an LLM Chain Custom Agents In order to add a memory to a...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html
6717b8584a7a-1
) memory = ConversationBufferMemory(memory_key="chat_history") We can now construct the LLMChain, with the Memory object, and then create the agent. llm_chain = LLMChain(llm=OpenAI(temperature=0), prompt=prompt) agent = ZeroShotAgent(llm_chain=llm_chain, tools=tools, verbose=True) agent_chain = AgentExecutor.from_agent...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html
6717b8584a7a-2
Action: Search Action Input: Population of Canada Observation: The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data. · Canada ... Additional information related to Canadian population trends can be found on Statistics Canada...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html
6717b8584a7a-3
> Finished AgentExecutor chain. 'The current population of Canada is 38,566,192 as of Saturday, December 31, 2022, based on Worldometer elaboration of the latest United Nations data.' To test the memory of this agent, we can ask a followup question that relies on information in the previous exchange to be answered corr...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html
6717b8584a7a-4
Action: Search Action Input: National Anthem of Canada Observation: Jun 7, 2010 ... https://twitter.com/CanadaImmigrantCanadian National Anthem O Canada in HQ - complete with lyrics, captions, vocals & music.LYRICS:O Canada! Nov 23, 2022 ... After 100 years of tradition, O Canada was proclaimed Canada's national anthem...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html
6717b8584a7a-5
Thought: I now know the final answer. Final Answer: The national anthem of Canada is called "O Canada". > Finished AgentExecutor chain. 'The national anthem of Canada is called "O Canada".' We can see that the agent remembered that the previous question was about Canada, and properly asked Google Search what the name o...
https://python.langchain.com/en/latest/modules/memory/examples/agent_with_memory.html