id
stringlengths
14
16
text
stringlengths
29
2.73k
source
stringlengths
49
117
ada135c29afc-1
'Barack Obama, in full Barack Hussein Obama II, (born August 4, 1961, Honolulu, Hawaii, U.S.), 44th president of the United States (2009-17) and the first African American to hold the office. Before winning the presidency, Obama represented Illinois in the U.S. Senate (2005-08). Barack Hussein Obama II (/ b ə ˈ r ɑː k h uː ˈ s eɪ n oʊ ˈ b ɑː m ə / bə-RAHK hoo-SAYN oh-BAH-mə; born August 4, 1961) is an American former politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, he was the first African-American president of the United States. Obama previously served as a U.S. senator representing ... Barack Obama was the first African American president of the United States (2009-17). He oversaw the recovery of the U.S. economy (from the Great Recession of 2008-09) and the enactment of landmark health care reform (the Patient Protection and Affordable Care Act ). In 2009 he was awarded the Nobel Peace Prize. His birth certificate lists his first name as Barack: That\'s how Obama has spelled his name throughout his life. His name derives from a Hebrew name which means "lightning.". The Hebrew word has been transliterated into English in various spellings, including Barak, Buraq, Burack, and Barack. Most common names of U.S. presidents 1789-2021. Published by. Aaron O\'Neill , Jun 21, 2022. The most common first name for a U.S. president is James, followed by John and then William. Six U.S ...' previous
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html
ada135c29afc-2
previous ChatGPT Plugins next File System Tools By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/ddg.html
a0afa9b10a50-0
.ipynb .pdf SearxNG Search API Contents Custom Parameters Obtaining results with metadata SearxNG Search API# This notebook goes over how to use a self hosted SearxNG search API to search the web. You can check this link for more informations about Searx API parameters. import pprint from langchain.utilities import SearxSearchWrapper search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888") For some engines, if a direct answer is available the warpper will print the answer instead of the full list of search results. You can use the results method of the wrapper if you want to obtain all the results. search.run("What is the capital of France") 'Paris is the capital of France, the largest country of Europe with 550 000 km2 (65 millions inhabitants). Paris has 2.234 million inhabitants end 2011. She is the core of Ile de France region (12 million people).' Custom Parameters# SearxNG supports up to 139 search engines. You can also customize the Searx wrapper with arbitrary named parameters that will be passed to the Searx search API . In the below example we will making a more interesting use of custom search parameters from searx search api. In this example we will be using the engines parameters to query wikipedia search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888", k=5) # k is for max number of items search.run("large language model ", engines=['wiki'])
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-1
search.run("large language model ", engines=['wiki']) 'Large language models (LLMs) represent a major advancement in AI, with the promise of transforming domains through learned knowledge. LLM sizes have been increasing 10X every year for the last few years, and as these models grow in complexity and size, so do their capabilities.\n\nGPT-3 can translate language, write essays, generate computer code, and more — all with limited to no supervision. In July 2020, OpenAI unveiled GPT-3, a language model that was easily the largest known at the time. Put simply, GPT-3 is trained to predict the next word in a sentence, much like how a text message autocomplete feature works.\n\nA large language model, or LLM, is a deep learning algorithm that can recognize, summarize, translate, predict and generate text and other content based on knowledge gained from massive datasets. Large language models are among the most successful applications of transformer models.\n\nAll of today’s well-known language models—e.g., GPT-3 from OpenAI, PaLM or LaMDA from Google, Galactica or OPT from Meta, Megatron-Turing from Nvidia/Microsoft, Jurassic-1 from AI21 Labs—are...\n\nLarge language models (LLMs) such as GPT-3are increasingly being used to generate text. These tools should be used with care, since they can generate content that is biased, non-verifiable, constitutes original research, or violates copyrights.' Passing other Searx parameters for searx like language search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888", k=1) search.run("deep learning", language='es', engines=['wiki'])
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-2
search.run("deep learning", language='es', engines=['wiki']) 'Aprendizaje profundo (en inglés, deep learning) es un conjunto de algoritmos de aprendizaje automático (en inglés, machine learning) que intenta modelar abstracciones de alto nivel en datos usando arquitecturas computacionales que admiten transformaciones no lineales múltiples e iterativas de datos expresados en forma matricial o tensorial. 1' Obtaining results with metadata# In this example we will be looking for scientific paper using the categories parameter and limiting the results to a time_range (not all engines support the time range option). We also would like to obtain the results in a structured way including metadata. For this we will be using the results method of the wrapper. search = SearxSearchWrapper(searx_host="http://127.0.0.1:8888") results = search.results("Large Language Model prompt", num_results=5, categories='science', time_range='year') pprint.pp(results) [{'snippet': '… on natural language instructions, large language models (… the ' 'prompt used to steer the model, and most effective prompts … to ' 'prompt engineering, we propose Automatic Prompt …', 'title': 'Large language models are human-level prompt engineers', 'link': 'https://arxiv.org/abs/2211.01910', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… Large language models (LLMs) have introduced new possibilities ' 'for prototyping with AI [18]. Pre-trained on a large amount of ' 'text data, models … language instructions called prompts. …', 'title': 'Promptchainer: Chaining large language model prompts through '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-3
'title': 'Promptchainer: Chaining large language model prompts through ' 'visual programming', 'link': 'https://dl.acm.org/doi/abs/10.1145/3491101.3519729', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… can introspect the large prompt model. We derive the view ' 'ϕ0(X) and the model h0 from T01. However, instead of fully ' 'fine-tuning T0 during co-training, we focus on soft prompt ' 'tuning, …', 'title': 'Co-training improves prompt-based learning for large language ' 'models', 'link': 'https://proceedings.mlr.press/v162/lang22a.html', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… With the success of large language models (LLMs) of code and ' 'their use as … prompt design process become important. In this ' 'work, we propose a framework called Repo-Level Prompt …', 'title': 'Repository-level prompt generation for large language models of ' 'code', 'link': 'https://arxiv.org/abs/2206.12839', 'engines': ['google scholar'], 'category': 'science'}, {'snippet': '… Figure 2 | The benefits of different components of a prompt ' 'for the largest language model (Gopher), as estimated from ' 'hierarchical logistic regression. Each point estimates the ' 'unique …', 'title': 'Can language models learn from explanations in context?', 'link': 'https://arxiv.org/abs/2204.02329',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-4
'link': 'https://arxiv.org/abs/2204.02329', 'engines': ['google scholar'], 'category': 'science'}] Get papers from arxiv results = search.results("Large Language Model prompt", num_results=5, engines=['arxiv']) pprint.pp(results) [{'snippet': 'Thanks to the advanced improvement of large pre-trained language ' 'models, prompt-based fine-tuning is shown to be effective on a ' 'variety of downstream tasks. Though many prompting methods have ' 'been investigated, it remains unknown which type of prompts are ' 'the most effective among three types of prompts (i.e., ' 'human-designed prompts, schema prompts and null prompts). In ' 'this work, we empirically compare the three types of prompts ' 'under both few-shot and fully-supervised settings. Our ' 'experimental results show that schema prompts are the most ' 'effective in general. Besides, the performance gaps tend to ' 'diminish when the scale of training data grows large.', 'title': 'Do Prompts Solve NLP Tasks Using Natural Language?', 'link': 'http://arxiv.org/abs/2203.00902v1', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Cross-prompt automated essay scoring (AES) requires the system ' 'to use non target-prompt essays to award scores to a ' 'target-prompt essay. Since obtaining a large quantity of ' 'pre-graded essays to a particular prompt is often difficult and ' 'unrealistic, the task of cross-prompt AES is vital for the ' 'development of real-world AES systems, yet it remains an '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-5
'development of real-world AES systems, yet it remains an ' 'under-explored area of research. Models designed for ' 'prompt-specific AES rely heavily on prompt-specific knowledge ' 'and perform poorly in the cross-prompt setting, whereas current ' 'approaches to cross-prompt AES either require a certain quantity ' 'of labelled target-prompt essays or require a large quantity of ' 'unlabelled target-prompt essays to perform transfer learning in ' 'a multi-step manner. To address these issues, we introduce ' 'Prompt Agnostic Essay Scorer (PAES) for cross-prompt AES. Our ' 'method requires no access to labelled or unlabelled ' 'target-prompt data during training and is a single-stage ' 'approach. PAES is easy to apply in practice and achieves ' 'state-of-the-art performance on the Automated Student Assessment ' 'Prize (ASAP) dataset.', 'title': 'Prompt Agnostic Essay Scorer: A Domain Generalization Approach to ' 'Cross-prompt Automated Essay Scoring', 'link': 'http://arxiv.org/abs/2008.01441v1', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Research on prompting has shown excellent performance with ' 'little or even no supervised training across many tasks. ' 'However, prompting for machine translation is still ' 'under-explored in the literature. We fill this gap by offering a ' 'systematic study on prompting strategies for translation, ' 'examining various factors for prompt template and demonstration ' 'example selection. We further explore the use of monolingual '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-6
'example selection. We further explore the use of monolingual ' 'data and the feasibility of cross-lingual, cross-domain, and ' 'sentence-to-document transfer learning in prompting. Extensive ' 'experiments with GLM-130B (Zeng et al., 2022) as the testbed ' 'show that 1) the number and the quality of prompt examples ' 'matter, where using suboptimal examples degenerates translation; ' '2) several features of prompt examples, such as semantic ' 'similarity, show significant Spearman correlation with their ' 'prompting performance; yet, none of the correlations are strong ' 'enough; 3) using pseudo parallel prompt examples constructed ' 'from monolingual data via zero-shot prompting could improve ' 'translation; and 4) improved performance is achievable by ' 'transferring knowledge from prompt examples selected in other ' 'settings. We finally provide an analysis on the model outputs ' 'and discuss several problems that prompting still suffers from.', 'title': 'Prompting Large Language Model for Machine Translation: A Case ' 'Study', 'link': 'http://arxiv.org/abs/2301.07069v2', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Large language models can perform new tasks in a zero-shot ' 'fashion, given natural language prompts that specify the desired ' 'behavior. Such prompts are typically hand engineered, but can ' 'also be learned with gradient-based methods from labeled data. ' 'However, it is underexplored what factors make the prompts ' 'effective, especially when the prompts are natural language. In '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-7
'effective, especially when the prompts are natural language. In ' 'this paper, we investigate common attributes shared by effective ' 'prompts. We first propose a human readable prompt tuning method ' '(F LUENT P ROMPT) based on Langevin dynamics that incorporates a ' 'fluency constraint to find a diverse distribution of effective ' 'and fluent prompts. Our analysis reveals that effective prompts ' 'are topically related to the task domain and calibrate the prior ' 'probability of label words. Based on these findings, we also ' 'propose a method for generating prompts using only unlabeled ' 'data, outperforming strong baselines by an average of 7.0% ' 'accuracy across three tasks.', 'title': "Toward Human Readable Prompt Tuning: Kubrick's The Shining is a " 'good movie, and a good prompt too?', 'link': 'http://arxiv.org/abs/2212.10539v1', 'engines': ['arxiv'], 'category': 'science'}, {'snippet': 'Prevailing methods for mapping large generative language models ' "to supervised tasks may fail to sufficiently probe models' novel " 'capabilities. Using GPT-3 as a case study, we show that 0-shot ' 'prompts can significantly outperform few-shot prompts. We ' 'suggest that the function of few-shot examples in these cases is ' 'better described as locating an already learned task rather than ' 'meta-learning. This analysis motivates rethinking the role of ' 'prompts in controlling and evaluating powerful language models. ' 'In this work, we discuss methods of prompt programming, '
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-8
'In this work, we discuss methods of prompt programming, ' 'emphasizing the usefulness of considering prompts through the ' 'lens of natural language. We explore techniques for exploiting ' 'the capacity of narratives and cultural anchors to encode ' 'nuanced intentions and techniques for encouraging deconstruction ' 'of a problem into components before producing a verdict. ' 'Informed by this more encompassing theory of prompt programming, ' 'we also introduce the idea of a metaprompt that seeds the model ' 'to generate its own natural language prompts for a range of ' 'tasks. Finally, we discuss how these more general methods of ' 'interacting with language models can be incorporated into ' 'existing and future benchmarks and practical applications.', 'title': 'Prompt Programming for Large Language Models: Beyond the Few-Shot ' 'Paradigm', 'link': 'http://arxiv.org/abs/2102.07350v1', 'engines': ['arxiv'], 'category': 'science'}] In this example we query for large language models under the it category. We then filter the results that come from github. results = search.results("large language model", num_results = 20, categories='it') pprint.pp(list(filter(lambda r: r['engines'][0] == 'github', results))) [{'snippet': 'Guide to using pre-trained large language models of source code', 'title': 'Code-LMs', 'link': 'https://github.com/VHellendoorn/Code-LMs', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Dramatron uses large language models to generate coherent ' 'scripts and screenplays.',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-9
'scripts and screenplays.', 'title': 'dramatron', 'link': 'https://github.com/deepmind/dramatron', 'engines': ['github'], 'category': 'it'}] We could also directly query for results from github and other source forges. results = search.results("large language model", num_results = 20, engines=['github', 'gitlab']) pprint.pp(results) [{'snippet': "Implementation of 'A Watermark for Large Language Models' paper " 'by Kirchenbauer & Geiping et. al.', 'title': 'Peutlefaire / LMWatermark', 'link': 'https://gitlab.com/BrianPulfer/LMWatermark', 'engines': ['gitlab'], 'category': 'it'}, {'snippet': 'Guide to using pre-trained large language models of source code', 'title': 'Code-LMs', 'link': 'https://github.com/VHellendoorn/Code-LMs', 'engines': ['github'], 'category': 'it'}, {'snippet': '', 'title': 'Simen Burud / Large-scale Language Models for Conversational ' 'Speech Recognition', 'link': 'https://gitlab.com/BrianPulfer', 'engines': ['gitlab'], 'category': 'it'}, {'snippet': 'Dramatron uses large language models to generate coherent ' 'scripts and screenplays.', 'title': 'dramatron', 'link': 'https://github.com/deepmind/dramatron', 'engines': ['github'], 'category': 'it'},
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-10
'engines': ['github'], 'category': 'it'}, {'snippet': 'Code for loralib, an implementation of "LoRA: Low-Rank ' 'Adaptation of Large Language Models"', 'title': 'LoRA', 'link': 'https://github.com/microsoft/LoRA', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Code for the paper "Evaluating Large Language Models Trained on ' 'Code"', 'title': 'human-eval', 'link': 'https://github.com/openai/human-eval', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A trend starts from "Chain of Thought Prompting Elicits ' 'Reasoning in Large Language Models".', 'title': 'Chain-of-ThoughtsPapers', 'link': 'https://github.com/Timothyxxx/Chain-of-ThoughtsPapers', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Mistral: A strong, northwesterly wind: Framework for transparent ' 'and accessible large-scale language model training, built with ' 'Hugging Face 🤗 Transformers.', 'title': 'mistral', 'link': 'https://github.com/stanford-crfm/mistral', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A prize for finding tasks that cause large language models to ' 'show inverse scaling', 'title': 'prize', 'link': 'https://github.com/inverse-scaling/prize', 'engines': ['github'],
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-11
'engines': ['github'], 'category': 'it'}, {'snippet': 'Optimus: the first large-scale pre-trained VAE language model', 'title': 'Optimus', 'link': 'https://github.com/ChunyuanLI/Optimus', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Seminar on Large Language Models (COMP790-101 at UNC Chapel ' 'Hill, Fall 2022)', 'title': 'llm-seminar', 'link': 'https://github.com/craffel/llm-seminar', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A central, open resource for data and tools related to ' 'chain-of-thought reasoning in large language models. Developed @ ' 'Samwald research group: https://samwald.info/', 'title': 'ThoughtSource', 'link': 'https://github.com/OpenBioLink/ThoughtSource', 'engines': ['github'], 'category': 'it'}, {'snippet': 'A comprehensive list of papers using large language/multi-modal ' 'models for Robotics/RL, including papers, codes, and related ' 'websites', 'title': 'Awesome-LLM-Robotics', 'link': 'https://github.com/GT-RIPL/Awesome-LLM-Robotics', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Tools for curating biomedical training data for large-scale ' 'language modeling', 'title': 'biomedical', 'link': 'https://github.com/bigscience-workshop/biomedical',
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-12
'link': 'https://github.com/bigscience-workshop/biomedical', 'engines': ['github'], 'category': 'it'}, {'snippet': 'ChatGPT @ Home: Large Language Model (LLM) chatbot application, ' 'written by ChatGPT', 'title': 'ChatGPT-at-Home', 'link': 'https://github.com/Sentdex/ChatGPT-at-Home', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Design and Deploy Large Language Model Apps', 'title': 'dust', 'link': 'https://github.com/dust-tt/dust', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Polyglot: Large Language Models of Well-balanced Competence in ' 'Multi-languages', 'title': 'polyglot', 'link': 'https://github.com/EleutherAI/polyglot', 'engines': ['github'], 'category': 'it'}, {'snippet': 'Code release for "Learning Video Representations from Large ' 'Language Models"', 'title': 'LaViLa', 'link': 'https://github.com/facebookresearch/LaViLa', 'engines': ['github'], 'category': 'it'}, {'snippet': 'SmoothQuant: Accurate and Efficient Post-Training Quantization ' 'for Large Language Models', 'title': 'smoothquant', 'link': 'https://github.com/mit-han-lab/smoothquant', 'engines': ['github'], 'category': 'it'},
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
a0afa9b10a50-13
'engines': ['github'], 'category': 'it'}, {'snippet': 'This repository contains the code, data, and models of the paper ' 'titled "XL-Sum: Large-Scale Multilingual Abstractive ' 'Summarization for 44 Languages" published in Findings of the ' 'Association for Computational Linguistics: ACL-IJCNLP 2021.', 'title': 'xl-sum', 'link': 'https://github.com/csebuetnlp/xl-sum', 'engines': ['github'], 'category': 'it'}] previous Search Tools next SerpAPI Contents Custom Parameters Obtaining results with metadata By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/searx_search.html
d7e0f0a922f6-0
.ipynb .pdf SerpAPI Contents Custom Parameters SerpAPI# This notebook goes over how to use the SerpAPI component to search the web. from langchain.utilities import SerpAPIWrapper search = SerpAPIWrapper() search.run("Obama's first name?") 'Barack Hussein Obama II' Custom Parameters# You can also customize the SerpAPI wrapper with arbitrary parameters. For example, in the below example we will use bing instead of google. params = { "engine": "bing", "gl": "us", "hl": "en", } search = SerpAPIWrapper(params=params) search.run("Obama's first name?") 'Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American presi…New content will be added above the current area of focus upon selectionBarack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and as an Illinois state senator from 1997 to 2004, and previously worked as a civil rights lawyer before entering politics.Wikipediabarackobama.com' from langchain.agents import Tool # You can create the tool to pass to an agent repl_tool = Tool( name="python_repl",
https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html
d7e0f0a922f6-1
repl_tool = Tool( name="python_repl", description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.", func=search.run, ) previous SearxNG Search API next Twilio Contents Custom Parameters By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/serpapi.html
eb9fcbdfef27-0
.ipynb .pdf ChatGPT Plugins ChatGPT Plugins# This example shows how to use ChatGPT Plugins within LangChain abstractions. Note 1: This currently only works for plugins with no auth. Note 2: There are almost certainly other ways to do this, this is just a first pass. If you have better ideas, please open a PR! from langchain.chat_models import ChatOpenAI from langchain.agents import load_tools, initialize_agent from langchain.agents import AgentType from langchain.tools import AIPluginTool tool = AIPluginTool.from_plugin_url("https://www.klarna.com/.well-known/ai-plugin.json") llm = ChatOpenAI(temperature=0) tools = load_tools(["requests_all"] ) tools += [tool] agent_chain = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent_chain.run("what t shirts are available in klarna?") > Entering new AgentExecutor chain... I need to check the Klarna Shopping API to see if it has information on available t shirts. Action: KlarnaProducts Action Input: None Observation: Usage Guide: Use the Klarna plugin to get relevant product suggestions for any shopping or researching purpose. The query to be sent should not include stopwords like articles, prepositions and determinants. The api works best when searching for words that are related to products, like their name, brand, model or category. Links will always be returned and should be shown to the user.
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-1
OpenAPI Spec: {'openapi': '3.0.1', 'info': {'version': 'v0', 'title': 'Open AI Klarna product Api'}, 'servers': [{'url': 'https://www.klarna.com/us/shopping'}], 'tags': [{'name': 'open-ai-product-endpoint', 'description': 'Open AI Product Endpoint. Query for products.'}], 'paths': {'/public/openai/v0/products': {'get': {'tags': ['open-ai-product-endpoint'], 'summary': 'API for fetching Klarna product information', 'operationId': 'productsUsingGET', 'parameters': [{'name': 'q', 'in': 'query', 'description': 'query, must be between 2 and 100 characters', 'required': True, 'schema': {'type': 'string'}}, {'name': 'size', 'in': 'query', 'description': 'number of products returned', 'required': False, 'schema': {'type': 'integer'}}, {'name': 'budget', 'in': 'query', 'description': 'maximum price of the matching product in local currency, filters results', 'required': False, 'schema': {'type': 'integer'}}], 'responses': {'200': {'description': 'Products found', 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/ProductResponse'}}}}, '503': {'description': 'one or more services are unavailable'}}, 'deprecated': False}}}, 'components': {'schemas': {'Product': {'type': 'object', 'properties': {'attributes': {'type': 'array', 'items': {'type': 'string'}}, 'name': {'type': 'string'}, 'price': {'type': 'string'}, 'url': {'type': 'string'}}, 'title': 'Product'}, 'ProductResponse': {'type': 'object', 'properties':
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-2
'title': 'Product'}, 'ProductResponse': {'type': 'object', 'properties': {'products': {'type': 'array', 'items': {'$ref': '#/components/schemas/Product'}}}, 'title': 'ProductResponse'}}}}
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-3
Thought:I need to use the Klarna Shopping API to search for t shirts. Action: requests_get Action Input: https://www.klarna.com/us/shopping/public/openai/v0/products?q=t%20shirts
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-4
Observation: {"products":[{"name":"Lacoste Men's Pack of Plain T-Shirts","url":"https://www.klarna.com/us/shopping/pl/cl10001/3202043025/Clothing/Lacoste-Men-s-Pack-of-Plain-T-Shirts/?utm_source=openai","price":"$26.60","attributes":["Material:Cotton","Target Group:Man","Color:White,Black"]},{"name":"Hanes Men's Ultimate 6pk. Crewneck T-Shirts","url":"https://www.klarna.com/us/shopping/pl/cl10001/3201808270/Clothing/Hanes-Men-s-Ultimate-6pk.-Crewneck-T-Shirts/?utm_source=openai","price":"$13.82","attributes":["Material:Cotton","Target Group:Man","Color:White"]},{"name":"Nike Boy's Jordan Stretch T-shirts","url":"https://www.klarna.com/us/shopping/pl/cl359/3201863202/Children-s-Clothing/Nike-Boy-s-Jordan-Stretch-T-shirts/?utm_source=openai","price":"$14.99","attributes":["Material:Cotton","Color:White,Green","Model:Boy","Size (Small-Large):S,XL,L,M"]},{"name":"Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack","url":"https://www.klarna.com/us/shopping/pl/cl10001/3203028500/Clothing/Polo-Classic-Fit-Cotton-V-Neck-T-Shirts-3-Pack/?utm_source=openai","price":"$29.95","attributes":["Material:Cotton","Target Group:Man","Color:White,Blue,Black"]},{"name":"adidas Comfort T-shirts Men's
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-5
Comfort T-shirts Men's 3-pack","url":"https://www.klarna.com/us/shopping/pl/cl10001/3202640533/Clothing/adidas-Comfort-T-shirts-Men-s-3-pack/?utm_source=openai","price":"$14.99","attributes":["Material:Cotton","Target Group:Man","Color:White,Black","Neckline:Round"]}]}
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
eb9fcbdfef27-6
Thought:The available t shirts in Klarna are Lacoste Men's Pack of Plain T-Shirts, Hanes Men's Ultimate 6pk. Crewneck T-Shirts, Nike Boy's Jordan Stretch T-shirts, Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack, and adidas Comfort T-shirts Men's 3-pack. Final Answer: The available t shirts in Klarna are Lacoste Men's Pack of Plain T-Shirts, Hanes Men's Ultimate 6pk. Crewneck T-Shirts, Nike Boy's Jordan Stretch T-shirts, Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack, and adidas Comfort T-shirts Men's 3-pack. > Finished chain. "The available t shirts in Klarna are Lacoste Men's Pack of Plain T-Shirts, Hanes Men's Ultimate 6pk. Crewneck T-Shirts, Nike Boy's Jordan Stretch T-shirts, Polo Classic Fit Cotton V-Neck T-Shirts 3-Pack, and adidas Comfort T-shirts Men's 3-pack." previous Brave Search next DuckDuckGo Search By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/chatgpt_plugins.html
0ec6dfed857b-0
.ipynb .pdf Brave Search Brave Search# This notebook goes over how to use the Brave Search tool. from langchain.tools import BraveSearch api_key = "..." tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={"count": 3}) tool.run("obama middle name")
https://python.langchain.com/en/latest/modules/agents/tools/examples/brave_search.html
0ec6dfed857b-1
'[{"title": "Barack Obama - Wikipedia", "link": "https://en.wikipedia.org/wiki/Barack_Obama", "snippet": "Outside of politics, <strong>Obama</strong> has published three bestselling books: Dreams from My Father (1995), The Audacity of Hope (2006) and A Promised Land (2020). Rankings by scholars and historians, in which he has been featured since 2010, place him in the <strong>middle</strong> to upper tier of American presidents."}, {"title": "Obama\'s Middle Name -- My Last Name -- is \'Hussein.\' So?", "link": "https://www.cair.com/cair_in_the_news/obamas-middle-name-my-last-name-is-hussein-so/", "snippet": "Many Americans understand that common names don\\u2019t only come in the form of a \\u201cSmith\\u201d or a \\u201cJohnson.\\u201d Perhaps, they have a neighbor, mechanic or teacher named Hussein. Or maybe they\\u2019ve seen fashion designer Hussein Chalayan in the pages of Vogue or recall <strong>King Hussein</strong>, our ally in the Middle East."}, {"title": "What\'s up with Obama\'s middle name? - Quora", "link": "https://www.quora.com/Whats-up-with-Obamas-middle-name", "snippet": "Answer (1 of 15): A better question would be, \\u201cWhat\\u2019s up with Obama\\u2019s first name?\\u201d President <strong>Barack Hussein Obama</strong>\\u2019s father\\u2019s name was <strong>Barack Hussein Obama</strong>. He was named after his father. Hussein, Obama\\u2019s middle name, is a very common Arabic name, meaning
https://python.langchain.com/en/latest/modules/agents/tools/examples/brave_search.html
0ec6dfed857b-2
Hussein, Obama\\u2019s middle name, is a very common Arabic name, meaning &quot;good,&quot; &quot;handsome,&quot; or &quot;beautiful.&quot;"}]'
https://python.langchain.com/en/latest/modules/agents/tools/examples/brave_search.html
0ec6dfed857b-3
previous Bing Search next ChatGPT Plugins By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/brave_search.html
2ae97cb9c0c8-0
.ipynb .pdf ArXiv API Tool Contents The ArXiv API Wrapper ArXiv API Tool# This notebook goes over how to use the arxiv component. First, you need to install arxiv python package. !pip install arxiv from langchain.chat_models import ChatOpenAI from langchain.agents import load_tools, initialize_agent, AgentType llm = ChatOpenAI(temperature=0.0) tools = load_tools( ["arxiv"], ) agent_chain = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True, ) agent_chain.run( "What's the paper 1605.08386 about?", ) > Entering new AgentExecutor chain... I need to use Arxiv to search for the paper. Action: Arxiv Action Input: "1605.08386" Observation: Published: 2016-05-26 Title: Heat-bath random walks with Markov bases Authors: Caprice Stanley, Tobias Windisch Summary: Graphs on lattice points are studied whose edges come from a finite set of allowed moves of arbitrary length. We show that the diameter of these graphs on fibers of a fixed integer matrix can be bounded from above by a constant. We then study the mixing behaviour of heat-bath random walks on these graphs. We also state explicit conditions on the set of moves so that the heat-bath random walk, a generalization of the Glauber dynamics, is an expander in fixed dimension. Thought:The paper is about heat-bath random walks with Markov bases on graphs of lattice points.
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
2ae97cb9c0c8-1
Final Answer: The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points. > Finished chain. 'The paper 1605.08386 is about heat-bath random walks with Markov bases on graphs of lattice points.' The ArXiv API Wrapper# The tool wraps the API Wrapper. Below, we can explore some of the features it provides. from langchain.utilities import ArxivAPIWrapper Run a query to get information about some scientific article/articles. The query text is limited to 300 characters. It returns these article fields: Publishing date Title Authors Summary Next query returns information about one article with arxiv Id equal “1605.08386”. arxiv = ArxivAPIWrapper() docs = arxiv.run("1605.08386") docs 'Published: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.' Now, we want to get information about one author, Caprice Stanley. This query returns information about three articles. By default, the query returns information only about three top articles. docs = arxiv.run("Caprice Stanley") docs
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
2ae97cb9c0c8-2
docs = arxiv.run("Caprice Stanley") docs 'Published: 2017-10-10\nTitle: On Mixing Behavior of a Family of Random Walks Determined by a Linear Recurrence\nAuthors: Caprice Stanley, Seth Sullivant\nSummary: We study random walks on the integers mod $G_n$ that are determined by an\ninteger sequence $\\{ G_n \\}_{n \\geq 1}$ generated by a linear recurrence\nrelation. Fourier analysis provides explicit formulas to compute the\neigenvalues of the transition matrices and we use this to bound the mixing time\nof the random walks.\n\nPublished: 2016-05-26\nTitle: Heat-bath random walks with Markov bases\nAuthors: Caprice Stanley, Tobias Windisch\nSummary: Graphs on lattice points are studied whose edges come from a finite set of\nallowed moves of arbitrary length. We show that the diameter of these graphs on\nfibers of a fixed integer matrix can be bounded from above by a constant. We\nthen study the mixing behaviour of heat-bath random walks on these graphs. We\nalso state explicit conditions on the set of moves so that the heat-bath random\nwalk, a generalization of the Glauber dynamics, is an expander in fixed\ndimension.\n\nPublished: 2003-03-18\nTitle: Calculation of fluxes of charged particles and neutrinos from atmospheric showers\nAuthors: V. Plyaskin\nSummary: The results on the fluxes of charged particles and neutrinos from a\n3-dimensional (3D) simulation of atmospheric showers are presented. An\nagreement of calculated fluxes with data on charged particles from the AMS and\nCAPRICE detectors is demonstrated. Predictions on neutrino fluxes at different\nexperimental sites are compared with results from other calculations.'
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
2ae97cb9c0c8-3
Now, we are trying to find information about non-existing article. In this case, the response is “No good Arxiv Result was found” docs = arxiv.run("1605.08386WWW") docs 'No good Arxiv Result was found' previous Apify next AWS Lambda API Contents The ArXiv API Wrapper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/arxiv.html
4a958f7d2b5a-0
.ipynb .pdf Python REPL Python REPL# Sometimes, for complex calculations, rather than have an LLM generate the answer directly, it can be better to have the LLM generate code to calculate the answer, and then run that code to get the answer. In order to easily do that, we provide a simple Python REPL to execute commands in. This interface will only return things that are printed - therefore, if you want to use it to calculate an answer, make sure to have it print out the answer. from langchain.agents import Tool from langchain.utilities import PythonREPL python_repl = PythonREPL() python_repl.run("print(1+1)") '2\n' # You can create the tool to pass to an agent repl_tool = Tool( name="python_repl", description="A Python shell. Use this to execute python commands. Input should be a valid python command. If you want to see the output of a value, you should print it out with `print(...)`.", func=python_repl.run ) previous OpenWeatherMap API next Requests By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/python.html
35020e7a7e77-0
.ipynb .pdf Wolfram Alpha Wolfram Alpha# This notebook goes over how to use the wolfram alpha component. First, you need to set up your Wolfram Alpha developer account and get your APP ID: Go to wolfram alpha and sign up for a developer account here Create an app and get your APP ID pip install wolframalpha Then we will need to set some environment variables: Save your APP ID into WOLFRAM_ALPHA_APPID env variable pip install wolframalpha import os os.environ["WOLFRAM_ALPHA_APPID"] = "" from langchain.utilities.wolfram_alpha import WolframAlphaAPIWrapper wolfram = WolframAlphaAPIWrapper() wolfram.run("What is 2x+5 = -3x + 7?") 'x = 2/5' previous Wikipedia next YouTubeSearchTool By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/wolfram_alpha.html
94312ba89cfe-0
.ipynb .pdf Apify Apify# This notebook shows how to use the Apify integration for LangChain. Apify is a cloud platform for web scraping and data extraction, which provides an ecosystem of more than a thousand ready-made apps called Actors for various web scraping, crawling, and data extraction use cases. For example, you can use it to extract Google Search results, Instagram and Facebook profiles, products from Amazon or Shopify, Google Maps reviews, etc. etc. In this example, we’ll use the Website Content Crawler Actor, which can deeply crawl websites such as documentation, knowledge bases, help centers, or blogs, and extract text content from the web pages. Then we feed the documents into a vector index and answer questions from it. #!pip install apify-client First, import ApifyWrapper into your source code: from langchain.document_loaders.base import Document from langchain.indexes import VectorstoreIndexCreator from langchain.utilities import ApifyWrapper Initialize it using your Apify API token and for the purpose of this example, also with your OpenAI API key: import os os.environ["OPENAI_API_KEY"] = "Your OpenAI API key" os.environ["APIFY_API_TOKEN"] = "Your Apify API token" apify = ApifyWrapper() Then run the Actor, wait for it to finish, and fetch its results from the Apify dataset into a LangChain document loader. Note that if you already have some results in an Apify dataset, you can load them directly using ApifyDatasetLoader, as shown in this notebook. In that notebook, you’ll also find the explanation of the dataset_mapping_function, which is used to map fields from the Apify dataset records to LangChain Document fields. loader = apify.call_actor( actor_id="apify/website-content-crawler",
https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html
94312ba89cfe-1
actor_id="apify/website-content-crawler", run_input={"startUrls": [{"url": "https://python.langchain.com/en/latest/"}]}, dataset_mapping_function=lambda item: Document( page_content=item["text"] or "", metadata={"source": item["url"]} ), ) Initialize the vector index from the crawled documents: index = VectorstoreIndexCreator().from_loaders([loader]) And finally, query the vector index: query = "What is LangChain?" result = index.query_with_sources(query) print(result["answer"]) print(result["sources"]) LangChain is a standard interface through which you can interact with a variety of large language models (LLMs). It provides modules that can be used to build language model applications, and it also provides chains and agents with memory capabilities. https://python.langchain.com/en/latest/modules/models/llms.html, https://python.langchain.com/en/latest/getting_started/getting_started.html previous Tool Input Schema next ArXiv API Tool By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/apify.html
5234c0ac6b96-0
.ipynb .pdf Zapier Natural Language Actions API Contents Zapier Natural Language Actions API Example with Agent Example with SimpleSequentialChain Zapier Natural Language Actions API# Full docs here: https://nla.zapier.com/api/v1/docs Zapier Natural Language Actions gives you access to the 5k+ apps, 20k+ actions on Zapier’s platform through a natural language API interface. NLA supports apps like Gmail, Salesforce, Trello, Slack, Asana, HubSpot, Google Sheets, Microsoft Teams, and thousands more apps: https://zapier.com/apps Zapier NLA handles ALL the underlying API auth and translation from natural language –> underlying API call –> return simplified output for LLMs. The key idea is you, or your users, expose a set of actions via an oauth-like setup window, which you can then query and execute via a REST API. NLA offers both API Key and OAuth for signing NLA API requests. Server-side (API Key): for quickly getting started, testing, and production scenarios where LangChain will only use actions exposed in the developer’s Zapier account (and will use the developer’s connected accounts on Zapier.com) User-facing (Oauth): for production scenarios where you are deploying an end-user facing application and LangChain needs access to end-user’s exposed actions and connected accounts on Zapier.com This quick start will focus on the server-side use case for brevity. Review full docs or reach out to nla@zapier.com for user-facing oauth developer support. This example goes over how to use the Zapier integration with a SimpleSequentialChain, then an Agent. In code, below: import os # get from https://platform.openai.com/ os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "")
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-1
os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY", "") # get from https://nla.zapier.com/demo/provider/debug (under User Information, after logging in): os.environ["ZAPIER_NLA_API_KEY"] = os.environ.get("ZAPIER_NLA_API_KEY", "") Example with Agent# Zapier tools can be used with an agent. See the example below. from langchain.llms import OpenAI from langchain.agents import initialize_agent from langchain.agents.agent_toolkits import ZapierToolkit from langchain.agents import AgentType from langchain.utilities.zapier import ZapierNLAWrapper ## step 0. expose gmail 'find email' and slack 'send channel message' actions # first go here, log in, expose (enable) the two actions: https://nla.zapier.com/demo/start -- for this example, can leave all fields "Have AI guess" # in an oauth scenario, you'd get your own <provider> id (instead of 'demo') which you route your users through first llm = OpenAI(temperature=0) zapier = ZapierNLAWrapper() toolkit = ZapierToolkit.from_zapier_nla_wrapper(zapier) agent = initialize_agent(toolkit.get_tools(), llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("Summarize the last email I received regarding Silicon Valley Bank. Send the summary to the #test-zapier channel in slack.") > Entering new AgentExecutor chain... I need to find the email and summarize it. Action: Gmail: Find Email Action Input: Find the latest email from Silicon Valley Bank
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-2
Action: Gmail: Find Email Action Input: Find the latest email from Silicon Valley Bank Observation: {"from__name": "Silicon Valley Bridge Bank, N.A.", "from__email": "sreply@svb.com", "body_plain": "Dear Clients, After chaotic, tumultuous & stressful days, we have clarity on path for SVB, FDIC is fully insuring all deposits & have an ask for clients & partners as we rebuild. Tim Mayopoulos <https://eml.svb.com/NjEwLUtBSy0yNjYAAAGKgoxUeBCLAyF_NxON97X4rKEaNBLG", "reply_to__email": "sreply@svb.com", "subject": "Meet the new CEO Tim Mayopoulos", "date": "Tue, 14 Mar 2023 23:42:29 -0500 (CDT)", "message_url": "https://mail.google.com/mail/u/0/#inbox/186e393b13cfdf0a", "attachment_count": "0", "to__emails": "ankush@langchain.dev", "message_id": "186e393b13cfdf0a", "labels": "IMPORTANT, CATEGORY_UPDATES, INBOX"} Thought: I need to summarize the email and send it to the #test-zapier channel in Slack. Action: Slack: Send Channel Message Action Input: Send a slack message to the #test-zapier channel with the text "Silicon Valley Bank has announced that Tim Mayopoulos is the new CEO. FDIC is fully insuring all deposits and they have an ask for clients and partners as they rebuild."
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-3
Observation: {"message__text": "Silicon Valley Bank has announced that Tim Mayopoulos is the new CEO. FDIC is fully insuring all deposits and they have an ask for clients and partners as they rebuild.", "message__permalink": "https://langchain.slack.com/archives/C04TSGU0RA7/p1678859932375259", "channel": "C04TSGU0RA7", "message__bot_profile__name": "Zapier", "message__team": "T04F8K3FZB5", "message__bot_id": "B04TRV4R74K", "message__bot_profile__deleted": "false", "message__bot_profile__app_id": "A024R9PQM", "ts_time": "2023-03-15T05:58:52Z", "message__bot_profile__icons__image_36": "https://avatars.slack-edge.com/2022-08-02/3888649620612_f864dc1bb794cf7d82b0_36.png", "message__blocks[]block_id": "kdZZ", "message__blocks[]elements[]type": "['rich_text_section']"} Thought: I now know the final answer. Final Answer: I have sent a summary of the last email from Silicon Valley Bank to the #test-zapier channel in Slack. > Finished chain. 'I have sent a summary of the last email from Silicon Valley Bank to the #test-zapier channel in Slack.' Example with SimpleSequentialChain# If you need more explicit control, use a chain, like below. from langchain.llms import OpenAI from langchain.chains import LLMChain, TransformChain, SimpleSequentialChain from langchain.prompts import PromptTemplate
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-4
from langchain.prompts import PromptTemplate from langchain.tools.zapier.tool import ZapierNLARunAction from langchain.utilities.zapier import ZapierNLAWrapper ## step 0. expose gmail 'find email' and slack 'send direct message' actions # first go here, log in, expose (enable) the two actions: https://nla.zapier.com/demo/start -- for this example, can leave all fields "Have AI guess" # in an oauth scenario, you'd get your own <provider> id (instead of 'demo') which you route your users through first actions = ZapierNLAWrapper().list() ## step 1. gmail find email GMAIL_SEARCH_INSTRUCTIONS = "Grab the latest email from Silicon Valley Bank" def nla_gmail(inputs): action = next((a for a in actions if a["description"].startswith("Gmail: Find Email")), None) return {"email_data": ZapierNLARunAction(action_id=action["id"], zapier_description=action["description"], params_schema=action["params"]).run(inputs["instructions"])} gmail_chain = TransformChain(input_variables=["instructions"], output_variables=["email_data"], transform=nla_gmail) ## step 2. generate draft reply template = """You are an assisstant who drafts replies to an incoming email. Output draft reply in plain text (not JSON). Incoming email: {email_data} Draft email reply:""" prompt_template = PromptTemplate(input_variables=["email_data"], template=template) reply_chain = LLMChain(llm=OpenAI(temperature=.7), prompt=prompt_template) ## step 3. send draft reply via a slack direct message SLACK_HANDLE = "@Ankush Gola" def nla_slack(inputs):
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-5
SLACK_HANDLE = "@Ankush Gola" def nla_slack(inputs): action = next((a for a in actions if a["description"].startswith("Slack: Send Direct Message")), None) instructions = f'Send this to {SLACK_HANDLE} in Slack: {inputs["draft_reply"]}' return {"slack_data": ZapierNLARunAction(action_id=action["id"], zapier_description=action["description"], params_schema=action["params"]).run(instructions)} slack_chain = TransformChain(input_variables=["draft_reply"], output_variables=["slack_data"], transform=nla_slack) ## finally, execute overall_chain = SimpleSequentialChain(chains=[gmail_chain, reply_chain, slack_chain], verbose=True) overall_chain.run(GMAIL_SEARCH_INSTRUCTIONS) > Entering new SimpleSequentialChain chain...
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-6
overall_chain.run(GMAIL_SEARCH_INSTRUCTIONS) > Entering new SimpleSequentialChain chain... {"from__name": "Silicon Valley Bridge Bank, N.A.", "from__email": "sreply@svb.com", "body_plain": "Dear Clients, After chaotic, tumultuous & stressful days, we have clarity on path for SVB, FDIC is fully insuring all deposits & have an ask for clients & partners as we rebuild. Tim Mayopoulos <https://eml.svb.com/NjEwLUtBSy0yNjYAAAGKgoxUeBCLAyF_NxON97X4rKEaNBLG", "reply_to__email": "sreply@svb.com", "subject": "Meet the new CEO Tim Mayopoulos", "date": "Tue, 14 Mar 2023 23:42:29 -0500 (CDT)", "message_url": "https://mail.google.com/mail/u/0/#inbox/186e393b13cfdf0a", "attachment_count": "0", "to__emails": "ankush@langchain.dev", "message_id": "186e393b13cfdf0a", "labels": "IMPORTANT, CATEGORY_UPDATES, INBOX"} Dear Silicon Valley Bridge Bank, Thank you for your email and the update regarding your new CEO Tim Mayopoulos. We appreciate your dedication to keeping your clients and partners informed and we look forward to continuing our relationship with you. Best regards, [Your Name]
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-7
Best regards, [Your Name] {"message__text": "Dear Silicon Valley Bridge Bank, \n\nThank you for your email and the update regarding your new CEO Tim Mayopoulos. We appreciate your dedication to keeping your clients and partners informed and we look forward to continuing our relationship with you. \n\nBest regards, \n[Your Name]", "message__permalink": "https://langchain.slack.com/archives/D04TKF5BBHU/p1678859968241629", "channel": "D04TKF5BBHU", "message__bot_profile__name": "Zapier", "message__team": "T04F8K3FZB5", "message__bot_id": "B04TRV4R74K", "message__bot_profile__deleted": "false", "message__bot_profile__app_id": "A024R9PQM", "ts_time": "2023-03-15T05:59:28Z", "message__blocks[]block_id": "p7i", "message__blocks[]elements[]elements[]type": "[['text']]", "message__blocks[]elements[]type": "['rich_text_section']"} > Finished chain.
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
5234c0ac6b96-8
> Finished chain. '{"message__text": "Dear Silicon Valley Bridge Bank, \\n\\nThank you for your email and the update regarding your new CEO Tim Mayopoulos. We appreciate your dedication to keeping your clients and partners informed and we look forward to continuing our relationship with you. \\n\\nBest regards, \\n[Your Name]", "message__permalink": "https://langchain.slack.com/archives/D04TKF5BBHU/p1678859968241629", "channel": "D04TKF5BBHU", "message__bot_profile__name": "Zapier", "message__team": "T04F8K3FZB5", "message__bot_id": "B04TRV4R74K", "message__bot_profile__deleted": "false", "message__bot_profile__app_id": "A024R9PQM", "ts_time": "2023-03-15T05:59:28Z", "message__blocks[]block_id": "p7i", "message__blocks[]elements[]elements[]type": "[[\'text\']]", "message__blocks[]elements[]type": "[\'rich_text_section\']"}' previous YouTubeSearchTool next Agents Contents Zapier Natural Language Actions API Example with Agent Example with SimpleSequentialChain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/zapier.html
4b2eb3561dc5-0
.ipynb .pdf Requests Contents Inside the tool Requests# The web contains a lot of information that LLMs do not have access to. In order to easily let LLMs interact with that information, we provide a wrapper around the Python Requests module that takes in a URL and fetches data from that URL. from langchain.agents import load_tools requests_tools = load_tools(["requests_all"]) requests_tools [RequestsGetTool(name='requests_get', description='A portal to the internet. Use this when you need to get specific content from a website. Input should be a url (i.e. https://www.google.com). The output will be the text response of the GET request.', args_schema=None, return_direct=False, verbose=False, callbacks=None, callback_manager=None, requests_wrapper=TextRequestsWrapper(headers=None, aiosession=None)), RequestsPostTool(name='requests_post', description='Use this when you want to POST to a website.\n Input should be a json string with two keys: "url" and "data".\n The value of "url" should be a string, and the value of "data" should be a dictionary of \n key-value pairs you want to POST to the url.\n Be careful to always use double quotes for strings in the json string\n The output will be the text response of the POST request.\n ', args_schema=None, return_direct=False, verbose=False, callbacks=None, callback_manager=None, requests_wrapper=TextRequestsWrapper(headers=None, aiosession=None)),
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-1
RequestsPatchTool(name='requests_patch', description='Use this when you want to PATCH to a website.\n Input should be a json string with two keys: "url" and "data".\n The value of "url" should be a string, and the value of "data" should be a dictionary of \n key-value pairs you want to PATCH to the url.\n Be careful to always use double quotes for strings in the json string\n The output will be the text response of the PATCH request.\n ', args_schema=None, return_direct=False, verbose=False, callbacks=None, callback_manager=None, requests_wrapper=TextRequestsWrapper(headers=None, aiosession=None)), RequestsPutTool(name='requests_put', description='Use this when you want to PUT to a website.\n Input should be a json string with two keys: "url" and "data".\n The value of "url" should be a string, and the value of "data" should be a dictionary of \n key-value pairs you want to PUT to the url.\n Be careful to always use double quotes for strings in the json string.\n The output will be the text response of the PUT request.\n ', args_schema=None, return_direct=False, verbose=False, callbacks=None, callback_manager=None, requests_wrapper=TextRequestsWrapper(headers=None, aiosession=None)), RequestsDeleteTool(name='requests_delete', description='A portal to the internet. Use this when you need to make a DELETE request to a URL. Input should be a specific url, and the output will be the text response of the DELETE request.', args_schema=None, return_direct=False, verbose=False, callbacks=None, callback_manager=None, requests_wrapper=TextRequestsWrapper(headers=None, aiosession=None))] Inside the tool# Each requests tool contains a requests wrapper. You can work with these wrappers directly below
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-2
Each requests tool contains a requests wrapper. You can work with these wrappers directly below # Each tool wrapps a requests wrapper requests_tools[0].requests_wrapper TextRequestsWrapper(headers=None, aiosession=None) from langchain.utilities import TextRequestsWrapper requests = TextRequestsWrapper() requests.get("https://www.google.com")
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-3
'<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-4
nonce="MXrF0nnIBPkxBza4okrgPA">(function(){window.google={kEI:\'TA9QZOa5EdTakPIPuIad-Ac\',kEXPI:\'0,1359409,6059,206,4804,2316,383,246,5,1129120,1197768,626,380097,16111,28687,22431,1361,12319,17581,4997,13228,37471,7692,2891,3926,213,7615,606,50058,8228,17728,432,3,346,1244,1,16920,2648,4,1528,2304,29062,9871,3194,13658,2980,1457,16786,5803,2554,4094,7596,1,42154,2,14022,2373,342,23024,6699,3112
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-5
,342,23024,6699,31123,4568,6258,23418,1252,5835,14967,4333,4239,3245,445,2,2,1,26632,239,7916,7321,60,2,3,15965,872,7830,1796,10008,7,1922,9779,36154,6305,2007,17765,427,20136,14,82,2730,184,13600,3692,109,2412,1548,4308,3785,15175,3888,1515,3030,5628,478,4,9706,1804,7734,2738,1853,1032,9480,2995,576,1041,5648,3722,2058,3048,2130,2365,662,476,958,87,111,5807,2,975,1167,891,3580,1439,1128,7343,426,
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-6
,1439,1128,7343,426,249,517,95,1102,14,696,1270,750,400,2208,274,2776,164,89,119,204,139,129,1710,2505,320,3,631,439,2,300,1645,172,1783,784,169,642,329,401,50,479,614,238,757,535,717,102,2,739,738,44,232,22,442,961,45,214,383,567,500,487,151,120,256,253,179,673,2,102,2,10,535,123,135,1685,5206695,190,2,20,50,198,5994221,2804424,3311,141,795,19735,1,1,346,5008,7,13,10,24,31,2,39,1,5,1,16,7,2,41,24
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-7
9,1,5,1,16,7,2,41,247,4,9,7,9,15,4,4,121,24,23944834,4042142,1964,16672,2894,6250,15739,1726,647,409,837,1411438,146986,23612960,7,84,93,33,101,816,57,532,163,1,441,86,1,951,73,31,2,345,178,243,472,2,148,962,455,167,178,29,702,1856,288,292,805,93,137,68,416,177,292,399,55,95,2566\',kBL:\'hw1A\',kOPI:89978449};google.sn=\'webhp\';google.kHL=\'en\';})();(function(){\nvar
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-8
h=this||self;function l(){return void 0!==window.google&&void 0!==window.google.kOPI&&0!==window.google.kOPI?window.google.kOPI:null};var m,n=[];function p(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||m}function q(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}function r(a){/^http:/i.test(a)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:a,glmm:1}),a="");return a}\nfunction t(a,b,c,d,k){var e="";-1===b.search("&ei=")&&(e="&ei="+p(d),-1===b.search("&lei=")&&(d=q(d))&&(e+="&lei="+d));d="";var g=-1===b.search("&cshid=")&&"slh"!==a,f=[];f.push(["zx",Date.now().toString()]);h._cshid&&g&&f.push(["cshid",h._cshid]);c=c();null!=c&&f.push(["opi",c.toString()]);for(c=0;c<f.length;c++){if(0===c||0<c)d+="&";d+=f[c][0]+"="+f[c][1]}return"/"+(k||"gen_204")+"?atyp=i&ct="+String(a)+"&cad="+(b+e+d)};m=google.kEI;google.getEI=p;google.getLEI=q;google.ml=function(){return null};google.log=function(a,b,c,d,k,e){e=void
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-9
null};google.log=function(a,b,c,d,k,e){e=void 0===e?l:e;c||(c=t(a,b,e,d,k));if(c=r(c)){a=new Image;var g=n.length;n[g]=a;a.onerror=a.onload=a.onabort=function(){delete n[g]};a.src=c}};google.logUrl=function(a,b){b=void 0===b?l:b;return t("",a,b)};}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){\ndocument.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-10
!important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}\n</style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-11
a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){window.google.erd={jsr:1,bv:1785,de:true};\nvar h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-12
null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=\na.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split("\\n")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-13
nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var src=\'/images/nav_logo229.png\';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}\nif (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}\n}\n})();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>Search</b> <a class=gb1 href="https://www.google.com/imghp?hl=en&tab=wi">Images</a> <a class=gb1 href="https://maps.google.com/maps?hl=en&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=en&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">News</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.com/intl/en/about/products?tab=wh"><u>More</u> &raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.com/history/optout?hl=en" class=gb4>Web History</a>
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-14
class=gb4>Web History</a> | <a href="/preferences?hl=en" class=gb4>Settings</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%">&nbsp;</td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="en" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Google Search" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Google
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-15
class="ds"><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="I\'m Feeling Lucky" name="btnI" type="submit"><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var id=\'tsuid_1\';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}\nelse top.location=\'/doodles/\';};})();</script><input value="AOEireoAAAAAZFAdXGKCXWBK5dlWxPhh8hNPQz1s9YT6" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=en&amp;authuser=0">Advanced search</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-16
ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br><div id="prm"><style>.szppmdbYutt__middle-slot-promo{font-size:small;margin-bottom:32px}.szppmdbYutt__middle-slot-promo a.ZIeIlb{display:inline-block;text-decoration:none}.szppmdbYutt__middle-slot-promo img{border:none;margin-right:5px;vertical-align:middle}</style><div class="szppmdbYutt__middle-slot-promo" data-ved="0ahUKEwjmj7fr6dT-AhVULUQIHThDB38QnIcBCAQ"><a class="NKcBbd" href="https://www.google.com/url?q=https://blog.google/outreach-initiatives/diversity/asian-pacific-american-heritage-month-2023/%3Futm_source%3Dhpp%26utm_medium%3Downed%26utm_campaign%3Dapahm&amp;source=hpp&amp;id=19035152&amp;ct=3&amp;usg=AOvVaw1zrN82vzhoWl4hz1zZ4gLp&amp;sa=X&amp;ved=0ahUKEwjmj7fr6dT-AhVULUQIHThDB38Q8IcBCAU" rel="nofollow">Celebrate Asian Pacific American Heritage Month with Google</a></div></div></div><span
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-17
Asian Pacific American Heritage Month with Google</a></div></div></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="/intl/en/ads/">Advertising</a><a href="/services/">Business Solutions</a><a href="/intl/en/about.html">About Google</a></div></div><p style="font-size:8pt;color:#70757a">&copy; 2023 - <a href="/intl/en/policies/privacy/">Privacy</a> - <a href="/intl/en/policies/terms/">Terms</a></p></span></center><script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){google.xjs={ck:\'xjs.hp.vUsZk7fd8do.L.X.O\',cs:\'ACT90oF8ktm8JGoaZ23megDhHoJku7YaGw\',excm:[]};})();</script> <script nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-18
nonce="MXrF0nnIBPkxBza4okrgPA">(function(){var u=\'/xjs/_/js/k\\x3dxjs.hp.en.q0lHXBfs9JY.O/am\\x3dAAAA6AQAUABgAQ/d\\x3d1/ed\\x3d1/rs\\x3dACT90oE3ek6-fjkab6CsTH0wUEUUPhnExg/m\\x3dsb_he,d\';var amd=0;\nvar e=this||self,f=function(c){return c};var h;var n=function(c,g){this.g=g===l?c:""};n.prototype.toString=function(){return this.g+""};var l={};\nfunction p(){var c=u,g=function(){};google.lx=google.stvsc?g:function(){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var a=document;var b="SCRIPT";"application/xhtml+xml"===a.contentType&&(b=b.toLowerCase());b=a.createElement(b);a=null===c?"null":void 0===c?"undefined":c;if(void 0===h){var d=null;var m=e.trustedTypes;if(m&&m.createPolicy){try{d=m.createPolicy("goog#html",{createHTML:f,createScript:f,createScriptURL:f})}catch(r){e.console&&e.console.error(r.message)}h=\nd}else h=d}a=(d=h)?d.createScriptURL(a):a;a=new n(a,l);b.src=a instanceof n&&a.constructor===n?a.g:"type_error:TrustedResourceUrl";var k,q;(k=(a=null==(q=(k=(b.ownerDocument&&b.ownerDocument.defaultView||window).document).querySelector)?void
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-19
0:q.call(k,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&b.setAttribute("nonce",k);document.body.appendChild(b);google.psa=!0;google.lx=g};google.bx||google.lx()};google.xjsu=u;e._F_jsUrl=u;setTimeout(function(){0<amd?google.caft(function(){return p()},amd):p()},0);})();window._ = window._ || {};window._DumpException = _._DumpException = function(e){throw e;};window._s = window._s || {};_s._DumpException = _._DumpException;window._qs = window._qs || {};_qs._DumpException = _._DumpException;function _F_installCss(c){}\n(function(){google.jl={blt:\'none\',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:\'none\',injt:0,injth:0,injv2:false,lls:\'default\',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc=\'{\\x22d\\x22:{},\\x22sb_he\\x22:{\\x22agen\\x22:true,\\x22cgen\\x22:true,\\x22client\\x22:\\x22heirloom-hp\\x22,\\x22dh\\x22:true,\\x22ds\\x22:\\x22\\x22,\\x22fl\\x22:true,\\x22host\\x22:\\x22google.com\\x22,\\x22jsonp\\x22:true,\\x22msgs\\x22:{\\x22cibl\\x22:\\x22Clear
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-20
Search\\x22,\\x22dym\\x22:\\x22Did you mean:\\x22,\\x22lcky\\x22:\\x22I\\\\u0026#39;m Feeling Lucky\\x22,\\x22lml\\x22:\\x22Learn more\\x22,\\x22psrc\\x22:\\x22This search was removed from your \\\\u003Ca href\\x3d\\\\\\x22/history\\\\\\x22\\\\u003EWeb History\\\\u003C/a\\\\u003E\\x22,\\x22psrl\\x22:\\x22Remove\\x22,\\x22sbit\\x22:\\x22Search by image\\x22,\\x22srch\\x22:\\x22Google Search\\x22},\\x22ovr\\x22:{},\\x22pq\\x22:\\x22\\x22,\\x22rfs\\x22:[],\\x22sbas\\x22:\\x220 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)\\x22,\\x22stok\\x22:\\x22C3TIBpTor6RHJfEIn2nbidnhv50\\x22}}\';google.pmc=JSON.parse(pmc);})();</script> </body></html>'
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
4b2eb3561dc5-21
previous Python REPL next SceneXplain Contents Inside the tool By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/requests.html
84a132010cfb-0
.ipynb .pdf SceneXplain Contents Usage in an Agent SceneXplain# SceneXplain is an ImageCaptioning service accessible through the SceneXplain Tool. To use this tool, you’ll need to make an account and fetch your API Token from the website. Then you can instantiate the tool. import os os.environ["SCENEX_API_KEY"] = "<YOUR_API_KEY>" from langchain.agents import load_tools tools = load_tools(["sceneXplain"]) Or directly instantiate the tool. from langchain.tools import SceneXplainTool tool = SceneXplainTool() Usage in an Agent# The tool can be used in any LangChain agent as follows: from langchain.llms import OpenAI from langchain.agents import initialize_agent from langchain.memory import ConversationBufferMemory llm = OpenAI(temperature=0) memory = ConversationBufferMemory(memory_key="chat_history") agent = initialize_agent( tools, llm, memory=memory, agent="conversational-react-description", verbose=True ) output = agent.run( input=( "What is in this image https://storage.googleapis.com/causal-diffusion.appspot.com/imagePrompts%2F0rw369i5h9t%2Foriginal.png. " "Is it movie or a game? If it is a movie, what is the name of the movie?" ) ) print(output) > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: Image Explainer Action Input: https://storage.googleapis.com/causal-diffusion.appspot.com/imagePrompts%2F0rw369i5h9t%2Foriginal.png
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
84a132010cfb-1
Observation: In a charmingly whimsical scene, a young girl is seen braving the rain alongside her furry companion, the lovable Totoro. The two are depicted standing on a bustling street corner, where they are sheltered from the rain by a bright yellow umbrella. The girl, dressed in a cheerful yellow frock, holds onto the umbrella with both hands while gazing up at Totoro with an expression of wonder and delight. Totoro, meanwhile, stands tall and proud beside his young friend, holding his own umbrella aloft to protect them both from the downpour. His furry body is rendered in rich shades of grey and white, while his large ears and wide eyes lend him an endearing charm. In the background of the scene, a street sign can be seen jutting out from the pavement amidst a flurry of raindrops. A sign with Chinese characters adorns its surface, adding to the sense of cultural diversity and intrigue. Despite the dreary weather, there is an undeniable sense of joy and camaraderie in this heartwarming image. Thought: Do I need to use a tool? No AI: This image appears to be a still from the 1988 Japanese animated fantasy film My Neighbor Totoro. The film follows two young girls, Satsuki and Mei, as they explore the countryside and befriend the magical forest spirits, including the titular character Totoro. > Finished chain. This image appears to be a still from the 1988 Japanese animated fantasy film My Neighbor Totoro. The film follows two young girls, Satsuki and Mei, as they explore the countryside and befriend the magical forest spirits, including the titular character Totoro. previous Requests next Search Tools Contents Usage in an Agent By Harrison Chase © Copyright 2023, Harrison Chase.
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
84a132010cfb-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/sceneXplain.html
1f0b57e82a0a-0
.ipynb .pdf IFTTT WebHooks Contents Creating a webhook Configuring the “If This” Configuring the “Then That” Finishing up IFTTT WebHooks# This notebook shows how to use IFTTT Webhooks. From https://github.com/SidU/teams-langchain-js/wiki/Connecting-IFTTT-Services. Creating a webhook# Go to https://ifttt.com/create Configuring the “If This”# Click on the “If This” button in the IFTTT interface. Search for “Webhooks” in the search bar. Choose the first option for “Receive a web request with a JSON payload.” Choose an Event Name that is specific to the service you plan to connect to. This will make it easier for you to manage the webhook URL. For example, if you’re connecting to Spotify, you could use “Spotify” as your Event Name. Click the “Create Trigger” button to save your settings and create your webhook. Configuring the “Then That”# Tap on the “Then That” button in the IFTTT interface. Search for the service you want to connect, such as Spotify. Choose an action from the service, such as “Add track to a playlist”. Configure the action by specifying the necessary details, such as the playlist name, e.g., “Songs from AI”. Reference the JSON Payload received by the Webhook in your action. For the Spotify scenario, choose “{{JsonPayload}}” as your search query. Tap the “Create Action” button to save your action settings. Once you have finished configuring your action, click the “Finish” button to complete the setup. Congratulations! You have successfully connected the Webhook to the desired service, and you’re ready to start receiving data and triggering actions 🎉
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
1f0b57e82a0a-1
service, and you’re ready to start receiving data and triggering actions 🎉 Finishing up# To get your webhook URL go to https://ifttt.com/maker_webhooks/settings Copy the IFTTT key value from there. The URL is of the form https://maker.ifttt.com/use/YOUR_IFTTT_KEY. Grab the YOUR_IFTTT_KEY value. from langchain.tools.ifttt import IFTTTWebhook import os key = os.environ["IFTTTKey"] url = f"https://maker.ifttt.com/trigger/spotify/json/with/key/{key}" tool = IFTTTWebhook(name="Spotify", description="Add a song to spotify playlist", url=url) tool.run("taylor swift") "Congratulations! You've fired the spotify JSON event" previous Human as a tool next Metaphor Search Contents Creating a webhook Configuring the “If This” Configuring the “Then That” Finishing up By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/ifttt.html
c6278ab55150-0
.ipynb .pdf Twilio Contents Setup Sending a message Twilio# This notebook goes over how to use the Twilio API wrapper to send a text message. Setup# To use this tool you need to install the Python Twilio package twilio # !pip install twilio You’ll also need to set up a Twilio account and get your credentials. You’ll need your Account String Identifier (SID) and your Auth Token. You’ll also need a number to send messages from. You can either pass these in to the TwilioAPIWrapper as named parameters account_sid, auth_token, from_number, or you can set the environment variables TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_FROM_NUMBER. Sending a message# from langchain.utilities.twilio import TwilioAPIWrapper twilio = TwilioAPIWrapper( # account_sid="foo", # auth_token="bar", # from_number="baz," ) twilio.run("hello world", "+16162904619") previous SerpAPI next Wikipedia Contents Setup Sending a message By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/twilio.html
38b2d512f83e-0
.ipynb .pdf Shell Tool Contents Use with Agents Shell Tool# Giving agents access to the shell is powerful (though risky outside a sandboxed environment). The LLM can use it to execute any shell commands. A common use case for this is letting the LLM interact with your local file system. from langchain.tools import ShellTool shell_tool = ShellTool() print(shell_tool.run({"commands": ["echo 'Hello World!'", "time"]})) Hello World! real 0m0.000s user 0m0.000s sys 0m0.000s /Users/wfh/code/lc/lckg/langchain/tools/shell/tool.py:34: UserWarning: The shell tool has no safeguards by default. Use at your own risk. warnings.warn( Use with Agents# As with all tools, these can be given to an agent to accomplish more complex tasks. Let’s have the agent fetch some links from a web page. from langchain.chat_models import ChatOpenAI from langchain.agents import initialize_agent from langchain.agents import AgentType llm = ChatOpenAI(temperature=0) shell_tool.description = shell_tool.description + f"args {shell_tool.args}".replace("{", "{{").replace("}", "}}") self_ask_with_search = initialize_agent([shell_tool], llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True) self_ask_with_search.run("Download the langchain.com webpage and grep for all urls. Return only a sorted list of them. Be sure to use double quotes.") > Entering new AgentExecutor chain... Question: What is the task? Thought: We need to download the langchain.com webpage and extract all the URLs from it. Then we need to sort the URLs and return them. Action: ```
https://python.langchain.com/en/latest/modules/agents/tools/examples/bash.html
38b2d512f83e-1
Action: ``` { "action": "shell", "action_input": { "commands": [ "curl -s https://langchain.com | grep -o 'http[s]*://[^\" ]*' | sort" ] } } ``` /Users/wfh/code/lc/lckg/langchain/tools/shell/tool.py:34: UserWarning: The shell tool has no safeguards by default. Use at your own risk. warnings.warn( Observation: https://blog.langchain.dev/ https://discord.gg/6adMQxSpJS https://docs.langchain.com/docs/ https://github.com/hwchase17/chat-langchain https://github.com/hwchase17/langchain https://github.com/hwchase17/langchainjs https://github.com/sullivan-sean/chat-langchainjs https://js.langchain.com/docs/ https://python.langchain.com/en/latest/ https://twitter.com/langchainai Thought:The URLs have been successfully extracted and sorted. We can return the list of URLs as the final answer. Final Answer: ["https://blog.langchain.dev/", "https://discord.gg/6adMQxSpJS", "https://docs.langchain.com/docs/", "https://github.com/hwchase17/chat-langchain", "https://github.com/hwchase17/langchain", "https://github.com/hwchase17/langchainjs", "https://github.com/sullivan-sean/chat-langchainjs", "https://js.langchain.com/docs/", "https://python.langchain.com/en/latest/", "https://twitter.com/langchainai"] > Finished chain.
https://python.langchain.com/en/latest/modules/agents/tools/examples/bash.html
38b2d512f83e-2
> Finished chain. '["https://blog.langchain.dev/", "https://discord.gg/6adMQxSpJS", "https://docs.langchain.com/docs/", "https://github.com/hwchase17/chat-langchain", "https://github.com/hwchase17/langchain", "https://github.com/hwchase17/langchainjs", "https://github.com/sullivan-sean/chat-langchainjs", "https://js.langchain.com/docs/", "https://python.langchain.com/en/latest/", "https://twitter.com/langchainai"]' previous AWS Lambda API next Bing Search Contents Use with Agents By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/bash.html
0db0cb2ffdd5-0
.ipynb .pdf Wikipedia Wikipedia# Wikipedia is a multilingual free online encyclopedia written and maintained by a community of volunteers, known as Wikipedians, through open collaboration and using a wiki-based editing system called MediaWiki. Wikipedia is the largest and most-read reference work in history. First, you need to install wikipedia python package. !pip install wikipedia from langchain.utilities import WikipediaAPIWrapper wikipedia = WikipediaAPIWrapper() wikipedia.run('HUNTER X HUNTER')
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
0db0cb2ffdd5-1
'Page: Hunter × Hunter\nSummary: Hunter × Hunter (stylized as HUNTER×HUNTER and pronounced "hunter hunter") is a Japanese manga series written and illustrated by Yoshihiro Togashi. It has been serialized in Shueisha\'s shōnen manga magazine Weekly Shōnen Jump since March 1998, although the manga has frequently gone on extended hiatuses since 2006. Its chapters have been collected in 37 tankōbon volumes as of November 2022. The story focuses on a young boy named Gon Freecss who discovers that his father, who left him at a young age, is actually a world-renowned Hunter, a licensed professional who specializes in fantastical pursuits such as locating rare or unidentified animal species, treasure hunting, surveying unexplored enclaves, or hunting down lawless individuals. Gon departs on a journey to become a Hunter and eventually find his father. Along the way, Gon meets various other Hunters and encounters the paranormal.\nHunter × Hunter was adapted into a 62-episode anime television series produced by Nippon Animation and directed by Kazuhiro Furuhashi, which ran on Fuji Television from October 1999 to March 2001. Three separate original video animations (OVAs) totaling 30 episodes were subsequently produced by Nippon Animation and released in Japan from 2002 to 2004. A second anime television series by Madhouse aired on Nippon Television from October 2011 to September 2014, totaling 148 episodes, with two animated theatrical films released in 2013. There are also numerous audio albums, video games, musicals, and other media based on Hunter × Hunter.\nThe manga has been translated into English and released in North America by Viz Media since April 2005. Both television series have been also licensed by Viz Media, with the first series having aired on the Funimation Channel in 2009
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
0db0cb2ffdd5-2
by Viz Media, with the first series having aired on the Funimation Channel in 2009 and the second series broadcast on Adult Swim\'s Toonami programming block from April 2016 to June 2019.\nHunter × Hunter has been a huge critical and financial success and has become one of the best-selling manga series of all time, having over 84 million copies in circulation by July 2022.\n\nPage: Hunter × Hunter (2011 TV series)\nSummary: Hunter × Hunter is an anime television series that aired from 2011 to 2014 based on Yoshihiro Togashi\'s manga series Hunter × Hunter. The story begins with a young boy named Gon Freecss, who one day discovers that the father who he thought was dead, is in fact alive and well. He learns that his father, Ging, is a legendary "Hunter", an individual who has proven themselves an elite member of humanity. Despite the fact that Ging left his son with his relatives in order to pursue his own dreams, Gon becomes determined to follow in his father\'s footsteps, pass the rigorous "Hunter Examination", and eventually find his father to become a Hunter in his own right.\nThis new Hunter × Hunter anime was announced on July 24, 2011. It is a complete reboot of the anime adaptation starting from the beginning of the manga, with no connections to the first anime from 1999. Produced by Nippon TV, VAP, Shueisha and Madhouse, the series is directed by Hiroshi Kōjina, with Atsushi Maekawa and Tsutomu Kamishiro handling series composition, Takahiro Yoshimatsu designing the characters and Yoshihisa Hirano composing the music. Instead of having the old cast reprise their roles for the new adaptation, the series features an entirely new cast to voice the characters. The new series premiered airing weekly on Nippon TV and the nationwide
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
0db0cb2ffdd5-3
cast to voice the characters. The new series premiered airing weekly on Nippon TV and the nationwide Nippon News Network from October 2, 2011. The series started to be collected in both DVD and Blu-ray format on January 25, 2012. Viz Media has licensed the anime for a DVD/Blu-ray release in North America with an English dub. On television, the series began airing on Adult Swim\'s Toonami programming block on April 17, 2016, and ended on June 23, 2019.The anime series\' opening theme is alternated between the song "Departure!" and an alternate version titled "Departure! -Second Version-" both sung by Galneryus\' vocalist Masatoshi Ono. Five pieces of music were used as the ending theme; "Just Awake" by the Japanese band Fear, and Loathing in Las Vegas in episodes 1 to 26, "Hunting for Your Dream" by Galneryus in episodes 27 to 58, "Reason" sung by Japanese duo Yuzu in episodes 59 to 75, "Nagareboshi Kirari" also sung by Yuzu from episode 76 to 98, which was originally from the anime film adaptation, Hunter × Hunter: Phantom Rouge, and "Hyōri Ittai" by Yuzu featuring Hyadain from episode 99 to 146, which was also used in the film Hunter × Hunter: The Last Mission. The background music and soundtrack for the series was composed by Yoshihisa Hirano.\n\n\n\nPage: List of Hunter × Hunter characters\nSummary: The Hunter × Hunter manga series, created by Yoshihiro Togashi, features an extensive cast of characters. It takes place in a fictional universe where licensed specialists known as Hunters travel the world taking on special jobs ranging from treasure hunting to assassination. The story initially focuses on Gon Freecss and
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
0db0cb2ffdd5-4
on special jobs ranging from treasure hunting to assassination. The story initially focuses on Gon Freecss and his quest to become a Hunter in order to find his father, Ging, who is himself a famous Hunter. On the way, Gon meets and becomes close friends with Killua Zoldyck, Kurapika and Leorio Paradinight.\nAlthough most characters are human, most possess superhuman strength and/or supernatural abilities due to Nen, the ability to control one\'s own life energy or aura. The world of the series also includes fantastical beasts such as the Chimera Ants or the Five great calamities.'
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
0db0cb2ffdd5-5
previous Twilio next Wolfram Alpha By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/wikipedia.html
537ea39b0486-0
.ipynb .pdf GraphQL tool GraphQL tool# This Jupyter Notebook demonstrates how to use the BaseGraphQLTool component with an Agent. GraphQL is a query language for APIs and a runtime for executing those queries against your data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools. By including a BaseGraphQLTool in the list of tools provided to an Agent, you can grant your Agent the ability to query data from GraphQL APIs for any purposes you need. In this example, we’ll be using the public Star Wars GraphQL API available at the following endpoint: https://swapi-graphql.netlify.app/.netlify/functions/index. First, you need to install httpx and gql Python packages. pip install httpx gql > /dev/null Now, let’s create a BaseGraphQLTool instance with the specified Star Wars API endpoint and initialize an Agent with the tool. from langchain import OpenAI from langchain.agents import load_tools, initialize_agent, AgentType from langchain.utilities import GraphQLAPIWrapper llm = OpenAI(temperature=0) tools = load_tools(["graphql"], graphql_endpoint="https://swapi-graphql.netlify.app/.netlify/functions/index", llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) Now, we can use the Agent to run queries against the Star Wars GraphQL API. Let’s ask the Agent to list all the Star Wars films and their release dates. graphql_fields = """allFilms { films { title director releaseDate speciesConnection { species { name classification homeworld { name }
https://python.langchain.com/en/latest/modules/agents/tools/examples/graphql.html
537ea39b0486-1
name classification homeworld { name } } } } } """ suffix = "Search for the titles of all the stawars films stored in the graphql database that has this schema " agent.run(suffix + graphql_fields) > Entering new AgentExecutor chain... I need to query the graphql database to get the titles of all the star wars films Action: query_graphql Action Input: query { allFilms { films { title } } } Observation: "{\n \"allFilms\": {\n \"films\": [\n {\n \"title\": \"A New Hope\"\n },\n {\n \"title\": \"The Empire Strikes Back\"\n },\n {\n \"title\": \"Return of the Jedi\"\n },\n {\n \"title\": \"The Phantom Menace\"\n },\n {\n \"title\": \"Attack of the Clones\"\n },\n {\n \"title\": \"Revenge of the Sith\"\n }\n ]\n }\n}" Thought: I now know the titles of all the star wars films Final Answer: The titles of all the star wars films are: A New Hope, The Empire Strikes Back, Return of the Jedi, The Phantom Menace, Attack of the Clones, and Revenge of the Sith. > Finished chain. 'The titles of all the star wars films are: A New Hope, The Empire Strikes Back, Return of the Jedi, The Phantom Menace, Attack of the Clones, and Revenge of the Sith.' previous Gradio Tools next HuggingFace Tools By Harrison Chase © Copyright 2023, Harrison Chase.
https://python.langchain.com/en/latest/modules/agents/tools/examples/graphql.html
537ea39b0486-2
By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/graphql.html
4f0213801ddf-0
.ipynb .pdf Gradio Tools Contents Using a tool Using within an agent Gradio Tools# There are many 1000s of Gradio apps on Hugging Face Spaces. This library puts them at the tips of your LLM’s fingers 🦾 Specifically, gradio-tools is a Python library for converting Gradio apps into tools that can be leveraged by a large language model (LLM)-based agent to complete its task. For example, an LLM could use a Gradio tool to transcribe a voice recording it finds online and then summarize it for you. Or it could use a different Gradio tool to apply OCR to a document on your Google Drive and then answer questions about it. It’s very easy to create you own tool if you want to use a space that’s not one of the pre-built tools. Please see this section of the gradio-tools documentation for information on how to do that. All contributions are welcome! # !pip install gradio_tools Using a tool# from gradio_tools.tools import StableDiffusionTool local_file_path = StableDiffusionTool().langchain.run("Please create a photo of a dog riding a skateboard") local_file_path Loaded as API: https://gradio-client-demos-stable-diffusion.hf.space ✔ Job Status: Status.STARTING eta: None '/Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/b61c1dd9-47e2-46f1-a47c-20d27640993d/tmp4ap48vnm.jpg' from PIL import Image im = Image.open(local_file_path) display(im) Using within an agent# from langchain.agents import initialize_agent from langchain.llms import OpenAI
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
4f0213801ddf-1
from langchain.agents import initialize_agent from langchain.llms import OpenAI from gradio_tools.tools import (StableDiffusionTool, ImageCaptioningTool, StableDiffusionPromptGeneratorTool, TextToVideoTool) from langchain.memory import ConversationBufferMemory llm = OpenAI(temperature=0) memory = ConversationBufferMemory(memory_key="chat_history") tools = [StableDiffusionTool().langchain, ImageCaptioningTool().langchain, StableDiffusionPromptGeneratorTool().langchain, TextToVideoTool().langchain] agent = initialize_agent(tools, llm, memory=memory, agent="conversational-react-description", verbose=True) output = agent.run(input=("Please create a photo of a dog riding a skateboard " "but improve my prompt prior to using an image generator." "Please caption the generated image and create a video for it using the improved prompt.")) Loaded as API: https://gradio-client-demos-stable-diffusion.hf.space ✔ Loaded as API: https://taesiri-blip-2.hf.space ✔ Loaded as API: https://microsoft-promptist.hf.space ✔ Loaded as API: https://damo-vilab-modelscope-text-to-video-synthesis.hf.space ✔ > Entering new AgentExecutor chain... Thought: Do I need to use a tool? Yes Action: StableDiffusionPromptGenerator Action Input: A dog riding a skateboard Job Status: Status.STARTING eta: None Observation: A dog riding a skateboard, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha Thought: Do I need to use a tool? Yes Action: StableDiffusion
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
4f0213801ddf-2
Thought: Do I need to use a tool? Yes Action: StableDiffusion Action Input: A dog riding a skateboard, digital painting, artstation, concept art, smooth, sharp focus, illustration, art by artgerm and greg rutkowski and alphonse mucha Job Status: Status.STARTING eta: None Job Status: Status.PROCESSING eta: None Observation: /Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/2e280ce4-4974-4420-8680-450825c31601/tmpfmiz2g1c.jpg Thought: Do I need to use a tool? Yes Action: ImageCaptioner Action Input: /Users/harrisonchase/workplace/langchain/docs/modules/agents/tools/examples/2e280ce4-4974-4420-8680-450825c31601/tmpfmiz2g1c.jpg Job Status: Status.STARTING eta: None Observation: a painting of a dog sitting on a skateboard Thought: Do I need to use a tool? Yes Action: TextToVideo Action Input: a painting of a dog sitting on a skateboard Job Status: Status.STARTING eta: None Due to heavy traffic on this app, the prediction will take approximately 73 seconds.For faster predictions without waiting in queue, you may duplicate the space using: Client.duplicate(damo-vilab/modelscope-text-to-video-synthesis) Job Status: Status.IN_QUEUE eta: 73.89824726581574 Due to heavy traffic on this app, the prediction will take approximately 42 seconds.For faster predictions without waiting in queue, you may duplicate the space using: Client.duplicate(damo-vilab/modelscope-text-to-video-synthesis) Job Status: Status.IN_QUEUE eta: 42.49370198879602
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
4f0213801ddf-3
Job Status: Status.IN_QUEUE eta: 42.49370198879602 Job Status: Status.IN_QUEUE eta: 21.314297944849187 Observation: /var/folders/bm/ylzhm36n075cslb9fvvbgq640000gn/T/tmp5snj_nmzf20_cb3m.mp4 Thought: Do I need to use a tool? No AI: Here is a video of a painting of a dog sitting on a skateboard. > Finished chain. previous Google Serper API next GraphQL tool Contents Using a tool Using within an agent By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/gradio_tools.html
b4b909cbd0fa-0
.ipynb .pdf Search Tools Contents Google Serper API Wrapper SerpAPI GoogleSearchAPIWrapper SearxNG Meta Search Engine Search Tools# This notebook shows off usage of various search tools. from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain.llms import OpenAI llm = OpenAI(temperature=0) Google Serper API Wrapper# First, let’s try to use the Google Serper API tool. tools = load_tools(["google-serper"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I should look up the current weather conditions. Action: Search Action Input: "weather in Pomfret" Observation: 37°F Thought: I now know the current temperature in Pomfret. Final Answer: The current temperature in Pomfret is 37°F. > Finished chain. 'The current temperature in Pomfret is 37°F.' SerpAPI# Now, let’s use the SerpAPI tool. tools = load_tools(["serpapi"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I need to find out what the current weather is in Pomfret. Action: Search Action Input: "weather in Pomfret"
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
b4b909cbd0fa-1
Action: Search Action Input: "weather in Pomfret" Observation: Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 ... Thought: I now know the current weather in Pomfret. Final Answer: Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 mph. > Finished chain. 'Partly cloudy skies during the morning hours will give way to cloudy skies with light rain and snow developing in the afternoon. High 42F. Winds WNW at 10 to 15 mph.' GoogleSearchAPIWrapper# Now, let’s use the official Google Search API Wrapper. tools = load_tools(["google-search"], llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret?") > Entering new AgentExecutor chain... I should look up the current weather conditions. Action: Google Search Action Input: "weather in Pomfret"
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
b4b909cbd0fa-2
Action: Google Search Action Input: "weather in Pomfret" Observation: Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%. Pomfret, CT Weather Forecast, with current conditions, wind, air quality, and what to expect for the next 3 days. Hourly Weather-Pomfret, CT. As of 12:52 am EST. Special Weather Statement +2 ... Hazardous Weather Conditions. Special Weather Statement ... Pomfret CT. Tonight ... National Digital Forecast Database Maximum Temperature Forecast. Pomfret Center Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for ... Pomfret, CT 12 hour by hour weather forecast includes precipitation, temperatures, sky conditions, rain chance, dew-point, relative humidity, wind direction ... North Pomfret Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for ... Today's Weather - Pomfret, CT. Dec 31, 2022 4:00 PM. Putnam MS. --. Weather forecast icon. Feels like --. Hi --. Lo --. Pomfret, CT temperature trend for the next 14 Days. Find daytime highs and nighttime lows from TheWeatherNetwork.com. Pomfret, MD Weather Forecast Date: 332 PM EST Wed Dec 28 2022. The area/counties/county of: Charles, including the cites of: St. Charles and Waldorf. Thought: I now know the current weather conditions in Pomfret.
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
b4b909cbd0fa-3
Thought: I now know the current weather conditions in Pomfret. Final Answer: Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%. > Finished AgentExecutor chain. 'Showers early becoming a steady light rain later in the day. Near record high temperatures. High around 60F. Winds SW at 10 to 15 mph. Chance of rain 60%.' SearxNG Meta Search Engine# Here we will be using a self hosted SearxNG meta search engine. tools = load_tools(["searx-search"], searx_host="http://localhost:8888", llm=llm) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) agent.run("What is the weather in Pomfret") > Entering new AgentExecutor chain... I should look up the current weather Action: SearX Search Action Input: "weather in Pomfret" Observation: Mainly cloudy with snow showers around in the morning. High around 40F. Winds NNW at 5 to 10 mph. Chance of snow 40%. Snow accumulations less than one inch. 10 Day Weather - Pomfret, MD As of 1:37 pm EST Today 49°/ 41° 52% Mon 27 | Day 49° 52% SE 14 mph Cloudy with occasional rain showers. High 49F. Winds SE at 10 to 20 mph. Chance of rain 50%....
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
b4b909cbd0fa-4
10 Day Weather - Pomfret, VT As of 3:51 am EST Special Weather Statement Today 39°/ 32° 37% Wed 01 | Day 39° 37% NE 4 mph Cloudy with snow showers developing for the afternoon. High 39F.... Pomfret, CT ; Current Weather. 1:06 AM. 35°F · RealFeel® 32° ; TODAY'S WEATHER FORECAST. 3/3. 44°Hi. RealFeel® 50° ; TONIGHT'S WEATHER FORECAST. 3/3. 32°Lo. Pomfret, MD Forecast Today Hourly Daily Morning 41° 1% Afternoon 43° 0% Evening 35° 3% Overnight 34° 2% Don't Miss Finally, Here’s Why We Get More Colds and Flu When It’s Cold Coast-To-Coast... Pomfret, MD Weather Forecast | AccuWeather Current Weather 5:35 PM 35° F RealFeel® 36° RealFeel Shade™ 36° Air Quality Excellent Wind E 3 mph Wind Gusts 5 mph Cloudy More Details WinterCast... Pomfret, VT Weather Forecast | AccuWeather Current Weather 11:21 AM 23° F RealFeel® 27° RealFeel Shade™ 25° Air Quality Fair Wind ESE 3 mph Wind Gusts 7 mph Cloudy More Details WinterCast... Pomfret Center, CT Weather Forecast | AccuWeather Daily Current Weather 6:50 PM 39° F RealFeel® 36° Air Quality Fair Wind NW 6 mph Wind Gusts 16 mph Mostly clear More Details WinterCast...
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
b4b909cbd0fa-5
12:00 pm · Feels Like36° · WindN 5 mph · Humidity43% · UV Index3 of 10 · Cloud Cover65% · Rain Amount0 in ... Pomfret Center, CT Weather Conditions | Weather Underground star Popular Cities San Francisco, CA 49 °F Clear Manhattan, NY 37 °F Fair Schiller Park, IL (60176) warning39 °F Mostly Cloudy... Thought: I now know the final answer Final Answer: The current weather in Pomfret is mainly cloudy with snow showers around in the morning. The temperature is around 40F with winds NNW at 5 to 10 mph. Chance of snow is 40%. > Finished chain. 'The current weather in Pomfret is mainly cloudy with snow showers around in the morning. The temperature is around 40F with winds NNW at 5 to 10 mph. Chance of snow is 40%.' previous SceneXplain next SearxNG Search API Contents Google Serper API Wrapper SerpAPI GoogleSearchAPIWrapper SearxNG Meta Search Engine By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 02, 2023.
https://python.langchain.com/en/latest/modules/agents/tools/examples/search_tools.html
66457d097e58-0
.ipynb .pdf Google Serper API Contents As part of a Self Ask With Search Chain Obtaining results with metadata Searching for Google Images Searching for Google News Searching for Google Places Google Serper API# This notebook goes over how to use the Google Serper component to search the web. First you need to sign up for a free account at serper.dev and get your api key. import os import pprint os.environ["SERPER_API_KEY"] = "" from langchain.utilities import GoogleSerperAPIWrapper search = GoogleSerperAPIWrapper() search.run("Obama's first name?") 'Barack Hussein Obama II' As part of a Self Ask With Search Chain# os.environ['OPENAI_API_KEY'] = "" from langchain.utilities import GoogleSerperAPIWrapper from langchain.llms.openai import OpenAI from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType llm = OpenAI(temperature=0) search = GoogleSerperAPIWrapper() tools = [ Tool( name="Intermediate Answer", func=search.run, description="useful for when you need to ask with search" ) ] self_ask_with_search = initialize_agent(tools, llm, agent=AgentType.SELF_ASK_WITH_SEARCH, verbose=True) self_ask_with_search.run("What is the hometown of the reigning men's U.S. Open champion?") > Entering new AgentExecutor chain... Yes. Follow up: Who is the reigning men's U.S. Open champion? Intermediate answer: Current champions Carlos Alcaraz, 2022 men's singles champion. Follow up: Where is Carlos Alcaraz from? Intermediate answer: El Palmar, Spain
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
66457d097e58-1
Intermediate answer: El Palmar, Spain So the final answer is: El Palmar, Spain > Finished chain. 'El Palmar, Spain' Obtaining results with metadata# If you would also like to obtain the results in a structured way including metadata. For this we will be using the results method of the wrapper. search = GoogleSerperAPIWrapper() results = search.results("Apple Inc.") pprint.pp(results) {'searchParameters': {'q': 'Apple Inc.', 'gl': 'us', 'hl': 'en', 'num': 10, 'type': 'search'}, 'knowledgeGraph': {'title': 'Apple', 'type': 'Technology company', 'website': 'http://www.apple.com/', 'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQwGQRv5TjjkycpctY66mOg_e2-npacrmjAb6_jAWhzlzkFE3OTjxyzbA&s=0', 'description': 'Apple Inc. is an American multinational ' 'technology company headquartered in ' 'Cupertino, California. Apple is the ' "world's largest technology company by " 'revenue, with US$394.3 billion in 2022 ' 'revenue. As of March 2023, Apple is the ' "world's biggest...", 'descriptionSource': 'Wikipedia', 'descriptionLink': 'https://en.wikipedia.org/wiki/Apple_Inc.', 'attributes': {'Customer service': '1 (800) 275-2273', 'CEO': 'Tim Cook (Aug 24, 2011–)',
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
66457d097e58-2
'CEO': 'Tim Cook (Aug 24, 2011–)', 'Headquarters': 'Cupertino, CA', 'Founded': 'April 1, 1976, Los Altos, CA', 'Founders': 'Steve Jobs, Steve Wozniak, ' 'Ronald Wayne, and more', 'Products': 'iPhone, iPad, Apple TV, and ' 'more'}}, 'organic': [{'title': 'Apple', 'link': 'https://www.apple.com/', 'snippet': 'Discover the innovative world of Apple and shop ' 'everything iPhone, iPad, Apple Watch, Mac, and Apple ' 'TV, plus explore accessories, entertainment, ...', 'sitelinks': [{'title': 'Support', 'link': 'https://support.apple.com/'}, {'title': 'iPhone', 'link': 'https://www.apple.com/iphone/'}, {'title': 'Site Map', 'link': 'https://www.apple.com/sitemap/'}, {'title': 'Business', 'link': 'https://www.apple.com/business/'}, {'title': 'Mac', 'link': 'https://www.apple.com/mac/'}, {'title': 'Watch', 'link': 'https://www.apple.com/watch/'}], 'position': 1}, {'title': 'Apple Inc. - Wikipedia', 'link': 'https://en.wikipedia.org/wiki/Apple_Inc.', 'snippet': 'Apple Inc. is an American multinational technology ' 'company headquartered in Cupertino, California. ' "Apple is the world's largest technology company by " 'revenue, ...',
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html
66457d097e58-3
'revenue, ...', 'attributes': {'Products': 'AirPods; Apple Watch; iPad; iPhone; ' 'Mac; Full list', 'Founders': 'Steve Jobs; Steve Wozniak; Ronald ' 'Wayne; Mike Markkula'}, 'sitelinks': [{'title': 'History', 'link': 'https://en.wikipedia.org/wiki/History_of_Apple_Inc.'}, {'title': 'Timeline of Apple Inc. products', 'link': 'https://en.wikipedia.org/wiki/Timeline_of_Apple_Inc._products'}, {'title': 'Litigation involving Apple Inc.', 'link': 'https://en.wikipedia.org/wiki/Litigation_involving_Apple_Inc.'}, {'title': 'Apple Store', 'link': 'https://en.wikipedia.org/wiki/Apple_Store'}], 'imageUrl': 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRvmB5fT1LjqpZx02UM7IJq0Buoqt0DZs_y0dqwxwSWyP4PIN9FaxuTea0&s', 'position': 2}, {'title': 'Apple Inc. | History, Products, Headquarters, & Facts ' '| Britannica', 'link': 'https://www.britannica.com/topic/Apple-Inc', 'snippet': 'Apple Inc., formerly Apple Computer, Inc., American ' 'manufacturer of personal computers, smartphones, ' 'tablet computers, computer peripherals, and computer ' '...', 'attributes': {'Related People': 'Steve Jobs Steve Wozniak Jony ' 'Ive Tim Cook Angela Ahrendts',
https://python.langchain.com/en/latest/modules/agents/tools/examples/google_serper.html