id
stringlengths
14
16
source
stringlengths
49
117
text
stringlengths
16
2.73k
d8498d9d3d8e-4
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
agent = create_spark_dataframe_agent(llm=OpenAI(temperature=0), df=df, verbose=True) agent.run("how many rows are there?") > Entering new AgentExecutor chain... Thought: I need to find out how many rows are in the dataframe Action: python_repl_ast Action Input: df.count() Observation: 891 Thought: I now know the final ...
d8498d9d3d8e-5
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
Action Input: math.sqrt(29.69911764705882) Observation: 5.449689683556195 Thought: I now know the final answer Final Answer: 5.449689683556195 > Finished chain. '5.449689683556195' spark.stop() Spark Connect Example# # in apache-spark root directory. (tested here with "spark-3.4.0-bin-hadoop3 and later") # To launch Sp...
d8498d9d3d8e-6
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
|PassengerId|Survived|Pclass| Name| Sex| Age|SibSp|Parch| Ticket| Fare|Cabin|Embarked| +-----------+--------+------+--------------------+------+----+-----+-----+----------------+-------+-----+--------+ | 1| 0| 3|Braund, Mr. Owen ...| male|22.0| 1| 0| A/5 21171...
d8498d9d3d8e-7
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
| 7| 0| 1|McCarthy, Mr. Tim...| male|54.0| 0| 0| 17463|51.8625| E46| S| | 8| 0| 3|Palsson, Master. ...| male| 2.0| 3| 1| 349909| 21.075| null| S| | 9| 1| 3|Johnson, Mrs. Osc...|female|27.0| 0| 2| 347742...
d8498d9d3d8e-8
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
| 14| 0| 3|Andersson, Mr. An...| male|39.0| 1| 5| 347082| 31.275| null| S| | 15| 0| 3|Vestrom, Miss. Hu...|female|14.0| 0| 0| 350406| 7.8542| null| S| | 16| 1| 2|Hewlett, Mrs. (Ma...|female|55.0| 0| 0| 248706...
d8498d9d3d8e-9
https://python.langchain.com/en/latest/modules/agents/toolkits/examples/spark.html
from langchain.agents import create_spark_dataframe_agent from langchain.llms import OpenAI import os os.environ["OPENAI_API_KEY"] = "...input your openai api key here..." agent = create_spark_dataframe_agent(llm=OpenAI(temperature=0), df=df, verbose=True) agent.run(""" who bought the most expensive ticket? You can fin...
1ebfc4732922-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
.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...
1ebfc4732922-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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. You have access to the following tools:""" suffix = """Begin!" {chat_hi...
1ebfc4732922-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 on top of OpenAI's GPT-3 family of larg...
1ebfc4732922-3
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 capable of sending and receiving images dur...
1ebfc4732922-4
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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. The organization is headquartered in S...
1ebfc4732922-5
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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...
1ebfc4732922-6
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 also capable of sending and receiving images during chatti...
1ebfc4732922-7
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
) ] prefix = """Have a conversation with a human, answering the following questions as best you can. You have access to the following tools:""" suffix = """Begin!" {chat_history} Question: {input} {agent_scratchpad}""" prompt = ZeroShotAgent.create_prompt( tools, prefix=prefix, suffix=suffix, input_v...
1ebfc4732922-8
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 on top of OpenAI's GPT-3 family of larg...
1ebfc4732922-9
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 capable of sending and receiving images dur...
1ebfc4732922-10
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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. The organization is headquartered in S...
1ebfc4732922-11
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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...
1ebfc4732922-12
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/sharedmemory_for_tools.html
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 also capable of sending and receiv...
7128fd9978bb-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
.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...
7128fd9978bb-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 output inside one unique code block, and nothing else...
7128fd9978bb-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-3
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-4
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-5
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-6
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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-like text based on the input it receives, allowing it to engage in natural-soundin...
7128fd9978bb-7
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
$ 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) > Entering new LLMChain chain... Prompt ...
7128fd9978bb-8
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
$ 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*5+3;print('Result:' + str(x(6)))" > run.py && python3 run.py AI: ``` $ echo -e "x=lambda y:y*5+3;print('Resul...
7128fd9978bb-9
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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-like text based on the input it receives, allowing it to engage in natural-soundin...
7128fd9978bb-10
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
[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","entrypoint.sh"]">Dockerfile && docker build . -t my_docker_image && docker run -t my_docker_image Assistant: > Finished LLMChain chain. ...
7128fd9978bb-11
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-12
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
$ 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 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 460.32.03 Driver Version: 460...
7128fd9978bb-13
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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-like text based on the input it receives, allowing it to engage in natural-soundin...
7128fd9978bb-14
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-15
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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\.\-]*//g'""") print(output) > Entering new LLMChain chain... Prompt after formatting: Assistant is ...
7128fd9978bb-16
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
|-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| ...
7128fd9978bb-17
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
> 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_chain.predict(human_input="lynx https://www.deepmind.com/careers") print(output) > Entering new LLMChain chain... Prompt after formatting: As...
7128fd9978bb-18
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 transmitted, 3 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 14.945/14.945/14.945/0.000 ms ``` Human: curl -fsSL "https://api.github....
7128fd9978bb-19
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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-like text based on the inpu...
7128fd9978bb-20
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
We offer a range of exciting opportunities in research, engineering, product, and operations. Our mission is to solve intelligence and make it useful, and we are looking for people who share our passion for pushing the boundaries of AI. Explore our current openings and apply today. We look forward to hearing from you. ...
7128fd9978bb-21
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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 ...
7128fd9978bb-22
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
</p> </body> </html> ``` Human: curl --header "Content-Type:application/json" --request POST --data '{"message": "What is artificial intelligence?"}' https://chat.openai.com/chat Assistant: > Finished LLMChain chain. ``` $ curl --header "Content-Type:application/json" --request POST --data '{"message": "What is artif...
7128fd9978bb-23
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
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-like text based on the input it receives, allowing it to engage in natural-soundin...
7128fd9978bb-24
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
$ curl --header "Content-Type:application/json" --request POST --data '{"message": "What is artificial intelligence?"}' https://chat.openai.com/chat { "response": "Artificial intelligence (AI) is the simulation of human intelligence processes by machines, especially computer systems. These processes include learning ...
7128fd9978bb-25
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/chatgpt_clone.html
How to use the async API for Agents next Handle Parsing Errors By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
e5c101b78238-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
.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...
e5c101b78238-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_time_limit.html
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_prompt) > Entering new AgentExecutor chain......
31631b61d86b-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
.ipynb .pdf Handle Parsing Errors Contents Setup Error Default error handling Custom Error Message Custom Error Function Handle Parsing Errors# Occasionally the LLM cannot determine what step to take because it outputs format in incorrect form to be handled by the output parser. In this case, by default the agent err...
31631b61d86b-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
During handling of the above exception, another exception occurred: OutputParserException Traceback (most recent call last) Cell In[4], line 1 ----> 1 mrkl.run("Who is Leo DiCaprio's girlfriend? No need to add Action") File ~/workplace/langchain/langchain/chains/base.py:236, in Chain.run(self, callb...
31631b61d86b-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
139 run_manager.on_chain_error(e) File ~/workplace/langchain/langchain/agents/agent.py:947, in AgentExecutor._call(self, inputs, run_manager) 945 # We now enter the agent loop (until it returns something). 946 while self._should_continue(iterations, time_elapsed): --> 947 next_step_output = self._take_n...
31631b61d86b-3
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
763 intermediate_steps, 764 callbacks=run_manager.get_child() if run_manager else None, 765 **inputs, 766 ) 767 except OutputParserException as e: 768 if isinstance(self.handle_parsing_errors, bool): File ~/workplace/langchain/langchain/agents/agent.py:444, in Agent.p...
31631b61d86b-4
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
"action_input": "Leo DiCaprio current girlfriend" } ``` Observation: Just Jared on Instagram: “Leonardo DiCaprio & girlfriend Camila Morrone couple up for a lunch date! Thought:Camila Morrone is currently Leo DiCaprio's girlfriend Final Answer: Camila Morrone > Finished chain. 'Camila Morrone' Custom Error Message# You...
31631b61d86b-5
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/handle_parsing_errors.html
You can also customize the error to be a function that takes the error in and outputs a string. def _handle_error(error) -> str: return str(error)[:50] mrkl = initialize_agent( tools, ChatOpenAI(temperature=0), agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True, handle_parsing_err...
dc1526adc8df-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
.ipynb .pdf How to use the async API for Agents Contents Serial vs. Concurrent Execution 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: GoogleSerperAPIWrapper, SerpAPIWrapper and LLMMath...
dc1526adc8df-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
tools = load_tools(["google-serper", "llm-math"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) s = time.perf_counter() for q in questions: agent.run(q) elapsed = time.perf_counter() - s print(f"Serial executed in {elapsed:0.2f} seconds.") > Entering ...
dc1526adc8df-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
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 ... Draw: 128 (16 Q / 8 WC). Champion: Rafael Nadal. Runner-up: Daniil Medvedev. Score: 7–5, 6–3, 5–7, 4–6, 6–4. Bianca Andreescu won the women's singl...
dc1526adc8df-3
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Rafael ... Duration: 4:47:32. Posted: Mar 20, 2020. US Open 2019: Rafael Nadal beats Daniil Medvedev · Updated: Sep. 08, 2019, 11:11 p.m. |; Published: Sep · Published: Sep. 08, 2019, 10:06 p.m.. 26. US Open ...
dc1526adc8df-4
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Thought: I now know that Rafael Nadal won the US Open men's final in 2019 and he is 33 years old. Action: Calculator Action Input: 33^0.334 Observation: Answer: 3.215019829667466 Thought: I now know the final answer. Final Answer: Rafael Nadal won the US Open men's final in 2019 and his age raised to the 0.334 power is...
dc1526adc8df-5
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Action: Google Serper Action Input: "who won the most recent formula 1 grand prix" Observation: Max Verstappen won his first Formula 1 world title on Sunday after the championship was decided by a last-lap overtake of his rival Lewis Hamilton in the Abu Dhabi Grand Prix. Dec 12, 2021 Thought: I need to find out Max Ver...
dc1526adc8df-6
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Thought: I now know the final answer. Final Answer: Nineteen-year-old Canadian Bianca Andreescu won the US Open women's final in 2019 and her age raised to the 0.34 power is 2.7212987634680084. > Finished chain. > Entering new AgentExecutor chain... I need to find out who Beyonce's husband is and then calculate his ag...
dc1526adc8df-7
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
> Entering new AgentExecutor chain... > Entering new AgentExecutor chain... > Entering new AgentExecutor chain... > 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: Google Serper Act...
dc1526adc8df-8
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
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 ... Draw: 128 (16 Q / 8 WC). Champion: Rafael Nadal. Runner-up: Daniil Medvedev. Score: 7–5, 6–3, 5–7, 4–6, 6–4. Bianca Andreescu won the women's singl...
dc1526adc8df-9
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Rafael ... Duration: 4:47:32. Posted: Mar 20, 2020. US Open 2019: Rafael Nadal beats Daniil Medvedev · Updated: Sep. 08, 2019, 11:11 p.m. |; Published: Sep · Published: Sep. 08, 2019, 10:06 p.m.. 26. US Open ...
dc1526adc8df-10
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Thought: Observation: WHAT HAPPENED: #SheTheNorth? She the champion. Nineteen-year-old Canadian Bianca Andreescu sealed her first Grand Slam title on Saturday, downing 23-time major champion Serena Williams in the 2019 US Open women's singles final, 6-3, 7-5. Sep 7, 2019 Thought:
dc1526adc8df-11
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Observation: Lewis Hamilton holds the record for the most race wins in Formula One history, with 103 wins to date. Michael Schumacher, the previous record holder, ... Michael Schumacher (top left) and Lewis Hamilton (top right) have each won the championship a record seven times during their careers, while Sebastian Ve...
dc1526adc8df-12
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/async_agent.html
Action: Google Serper Action Input: "How old is Jay-Z?" I now know that Rafael Nadal won the US Open men's final in 2019 and he is 33 years old. Action: Calculator Action Input: 33^0.334 I now need to calculate her age raised to the 0.34 power. Action: Calculator Action Input: 19^0.34 Observation: 29 years Thought: Obs...
e41161809ab0-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
.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...
e41161809ab0-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
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, chain_type="stuff", retriever=docsearch.as_retriever()) from langchain.document...
e41161809ab0-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
# 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 new AgentExecutor chain... I need to find out what Biden said about K...
e41161809ab0-3
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
Thought: I now know the final answer Final Answer: 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 quality tools natively, including...
e41161809ab0-4
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
description="useful for when you need to answer questions about ruff (a python linter). Input should be a fully formed question.", return_direct=True ), ] agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What did biden say about ketanji brown jackson...
e41161809ab0-5
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
' 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 quality tools natively, including isort, yesqa, eradicate, and most of the rules i...
e41161809ab0-6
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/agent_vectorstore.html
I need to find out what tool ruff uses to run over Jupyter Notebooks, and if the president mentioned it in the state of the union. Action: Ruff QA System Action Input: What tool does ruff use to run over Jupyter Notebooks? Observation: Ruff is integrated into nbQA, a tool for running linters and code formatters over J...
bbc82690d081-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
.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...
bbc82690d081-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
# 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"'), 'Camila Morrone'),...
bbc82690d081-2
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/intermediate_steps.html
"Answer: 3.991298452658078\n" ] ] previous Handle Parsing Errors next How to cap the max number of iterations By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
6aeec6a1d90d-0
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
.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...
6aeec6a1d90d-1
https://python.langchain.com/en/latest/modules/agents/agent_executors/examples/max_iterations.html
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) > Entering new AgentExecutor chain... I need to us...
1d9b9d2e8e0a-0
https://python.langchain.com/en/latest/modules/models/text_embedding.html
.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...
be41af20456d-0
https://python.langchain.com/en/latest/modules/models/getting_started.html
.ipynb .pdf Getting Started Contents Language Models text -> text interface messages -> message interface Getting Started# One of the core value props of LangChain is that it provides a standard interface to models. This allows you to swap easily between models. At a high level, there are two main types of models: La...
be41af20456d-1
https://python.langchain.com/en/latest/modules/models/getting_started.html
© Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
153a9c2a3bd5-0
https://python.langchain.com/en/latest/modules/models/llms.html
.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...
251bdf3a0566-0
https://python.langchain.com/en/latest/modules/models/chat.html
.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...
2f8b5a836733-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/bedrock.html
.ipynb .pdf Bedrock Embeddings Bedrock Embeddings# %pip install boto3 from langchain.embeddings import BedrockEmbeddings embeddings = BedrockEmbeddings(credentials_profile_name="bedrock-admin") embeddings.embed_query("This is a content of the document") embeddings.embed_documents(["This is a content of the document"]) ...
29593772006b-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/mosaicml.html
.ipynb .pdf MosaicML embeddings MosaicML embeddings# MosaicML offers a managed inference service. You can either use a variety of open source models, or deploy your own. This example goes over how to use LangChain to interact with MosaicML Inference for text embedding. # sign up for an account: https://forms.mosaicml.c...
e64da47030b0-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/sentence_transformers.html
.ipynb .pdf Sentence Transformers Embeddings Sentence Transformers Embeddings# SentenceTransformers embeddings are called using the HuggingFaceEmbeddings integration. We have also added an alias for SentenceTransformerEmbeddings for users who are more familiar with directly using that package. SentenceTransformers is a...
dad6bec7a736-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/tensorflowhub.html
.ipynb .pdf TensorflowHub TensorflowHub# Let’s load the TensorflowHub Embedding class. from langchain.embeddings import TensorflowHubEmbeddings embeddings = TensorflowHubEmbeddings() 2023-01-30 23:53:01.652176: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neu...
1ceeaea958bf-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/sagemaker-endpoint.html
.ipynb .pdf SageMaker Endpoint Embeddings SageMaker Endpoint Embeddings# Let’s load the SageMaker Endpoints Embeddings class. The class can be used if you host, e.g. your own Hugging Face model on SageMaker. For instructions on how to do this, please see here. Note: In order to handle batched requests, you will need to...
1ceeaea958bf-1
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/sagemaker-endpoint.html
doc_results previous OpenAI next Self Hosted Embeddings By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 04, 2023.
8d02d66e0a63-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/instruct_embeddings.html
.ipynb .pdf InstructEmbeddings InstructEmbeddings# Let’s load the HuggingFace instruct Embeddings class. from langchain.embeddings import HuggingFaceInstructEmbeddings embeddings = HuggingFaceInstructEmbeddings( query_instruction="Represent the query for retrieval: " ) load INSTRUCTOR_Transformer max_seq_length 51...
7409c4fb66d5-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/cohere.html
.ipynb .pdf Cohere Cohere# Let’s load the Cohere Embedding class. from langchain.embeddings import CohereEmbeddings embeddings = CohereEmbeddings(cohere_api_key=cohere_api_key) text = "This is a test document." query_result = embeddings.embed_query(text) doc_result = embeddings.embed_documents([text]) previous Bedrock ...
9b2b893f8d20-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/aleph_alpha.html
.ipynb .pdf Aleph Alpha Contents Asymmetric Symmetric Aleph Alpha# There are two possible ways to use Aleph Alpha’s semantic embeddings. If you have texts with a dissimilar structure (e.g. a Document and a Query) you would want to use asymmetric embeddings. Conversely, for texts with comparable structures, symmetric ...
3c7e6dfec7c7-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/azureopenai.html
.ipynb .pdf AzureOpenAI AzureOpenAI# Let’s load the OpenAI Embedding class with environment variables set to indicate to use Azure endpoints. # set the environment variables needed for openai package to know to reach out to azure import os os.environ["OPENAI_API_TYPE"] = "azure" os.environ["OPENAI_API_BASE"] = "https:/...
4e343ecdc5e5-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/fake.html
.ipynb .pdf Fake Embeddings Fake Embeddings# LangChain also provides a fake embedding class. You can use this to test your pipelines. from langchain.embeddings import FakeEmbeddings embeddings = FakeEmbeddings(size=1352) query_result = embeddings.embed_query("foo") doc_results = embeddings.embed_documents(["foo"]) prev...
d7ef0dfbf5b3-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/llamacpp.html
.ipynb .pdf Llama-cpp Llama-cpp# This notebook goes over how to use Llama-cpp embeddings within LangChain !pip install llama-cpp-python from langchain.embeddings import LlamaCppEmbeddings llama = LlamaCppEmbeddings(model_path="/path/to/model/ggml-model-q4_0.bin") text = "This is a test document." query_result = llama.e...
ec57593b06eb-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/self-hosted.html
.ipynb .pdf Self Hosted Embeddings Self Hosted Embeddings# Let’s load the SelfHostedEmbeddings, SelfHostedHuggingFaceEmbeddings, and SelfHostedHuggingFaceInstructEmbeddings classes. from langchain.embeddings import ( SelfHostedEmbeddings, SelfHostedHuggingFaceEmbeddings, SelfHostedHuggingFaceInstructEmbeddi...
ec57593b06eb-1
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/self-hosted.html
model = AutoModelForCausalLM.from_pretrained(model_id) return pipeline("feature-extraction", model=model, tokenizer=tokenizer) def inference_fn(pipeline, prompt): # Return last hidden state of the model if isinstance(prompt, list): return [emb[0][-1] for emb in pipeline(prompt)] return pipeline(...
787f55c58a7e-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/minimax.html
.ipynb .pdf MiniMax MiniMax# MiniMax offers an embeddings service. This example goes over how to use LangChain to interact with MiniMax Inference for text embedding. import os os.environ["MINIMAX_GROUP_ID"] = "MINIMAX_GROUP_ID" os.environ["MINIMAX_API_KEY"] = "MINIMAX_API_KEY" from langchain.embeddings import MiniMaxEm...
6f9c43f08cfe-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/huggingfacehub.html
.ipynb .pdf Hugging Face Hub Hugging Face Hub# Let’s load the Hugging Face Embedding class. from langchain.embeddings import HuggingFaceEmbeddings embeddings = HuggingFaceEmbeddings() text = "This is a test document." query_result = embeddings.embed_query(text) doc_result = embeddings.embed_documents([text]) previous G...
b8e0e8069263-0
https://python.langchain.com/en/latest/modules/models/text_embedding/examples/jina.html
.ipynb .pdf Jina Jina# Let’s load the Jina Embedding class. from langchain.embeddings import JinaEmbeddings embeddings = JinaEmbeddings(jina_auth_token=jina_auth_token, model_name="ViT-B-32::openai") text = "This is a test document." query_result = embeddings.embed_query(text) doc_result = embeddings.embed_documents([t...