id stringlengths 14 16 | text stringlengths 45 2.05k | source stringlengths 53 111 |
|---|---|---|
dd6daa9d75f6-6 | "TrackId" INTEGER NOT NULL,
PRIMARY KEY ("PlaylistId", "TrackId"),
FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"),
FOREIGN KEY("PlaylistId") REFERENCES "Playlist" ("PlaylistId")
)
SELECT * FROM 'PlaylistTrack' LIMIT 3;
PlaylistId TrackId
1 3402
1 3389
1 3390
Thought: I can use a SELECT statement to get the... | https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/sql_database.html |
dd6daa9d75f6-7 | Thought: I now know the final answer.
Final Answer: The total number of tracks in each playlist are: '90’s Music' (1477), 'Brazilian Music' (39), 'Classical' (75), 'Classical 101 - Deep Cuts' (25), 'Classical 101 - Next Steps' (25), 'Classical 101 - The Basics' (25), 'Grunge' (15), 'Heavy Metal Classic' (26), 'Music' (... | https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/sql_database.html |
dd6daa9d75f6-8 | CREATE TABLE "Artist" (
"ArtistId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
PRIMARY KEY ("ArtistId")
)
SELECT * FROM 'Artist' LIMIT 3;
ArtistId Name
1 AC/DC
2 Accept
3 Aerosmith
CREATE TABLE "Track" (
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"AlbumId" INTEGER,
"MediaTypeId" INTEGER NOT NULL... | https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/sql_database.html |
dd6daa9d75f6-9 | "InvoiceId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
"UnitPrice" NUMERIC(10, 2) NOT NULL,
"Quantity" INTEGER NOT NULL,
PRIMARY KEY ("InvoiceLineId"),
FOREIGN KEY("TrackId") REFERENCES "Track" ("TrackId"),
FOREIGN KEY("InvoiceId") REFERENCES "Invoice" ("InvoiceId")
)
SELECT * FROM 'InvoiceLine' LIMIT 3;... | https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/sql_database.html |
dd6daa9d75f6-10 | Thought: I should double check my query before executing it.
Action: query_checker_sql_db
Action Input: SELECT Artist.Name, SUM(InvoiceLine.Quantity) AS TotalQuantity FROM Artist INNER JOIN Track ON Artist.ArtistId = Track.ArtistId INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId GROUP BY Artist.Name ORDER... | https://langchain.readthedocs.io/en/latest/modules/agents/agent_toolkits/sql_database.html |
0cb7cf374e77-0 | .md
.pdf
Key Concepts
Contents
Python REPL
Bash
Requests Wrapper
Google Search
SerpAPI
Searx Search
Key Concepts#
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 ge... | https://langchain.readthedocs.io/en/latest/modules/utils/key_concepts.html |
0cb7cf374e77-1 | Requests Wrapper
Google Search
SerpAPI
Searx Search
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Mar 22, 2023. | https://langchain.readthedocs.io/en/latest/modules/utils/key_concepts.html |
43b06cff9e46-0 | .rst
.pdf
Generic Utilities
Generic Utilities#
There are a lot of different utilities that LangChain provides integrations for
These guides go over how to use them.
The utilities listed here are all generic utilities.
Bash: How to use a bash wrapper to execute bash commands.
Python REPL: How to use a Python wrapper to ... | https://langchain.readthedocs.io/en/latest/modules/utils/how_to_guides.html |
6128c93d3b7d-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 Z... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-1 | %autoreload 2
import os
# get from https://platform.openai.com/
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 ... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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 dep... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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",... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-4 | 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 f... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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_... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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 & h... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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[... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
6128c93d3b7d-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[You... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/zapier.html |
faf4ea7a7012-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 command... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/python.html |
0b6d88463c54-0 | .ipynb
.pdf
Bash
Bash#
It can often be useful to have an LLM generate bash commands, and then run them. A common use case for this is letting the LLM interact with your local file system. We provide an easy util to execute bash commands.
from langchain.utilities import BashProcess
bash = BashProcess()
print(bash.run("l... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bash.html |
ecb3d9b48a55-0 | .ipynb
.pdf
SearxNG Search API
Contents
SearxNG Search API
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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 ... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 '
'ϕ... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 '
... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 '
... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 intentio... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 "Evalua... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 '
... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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':... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
ecb3d9b48a55-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 Lingu... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/searx_search.html |
bb782251a688-0 | .ipynb
.pdf
Google Search
Contents
Number of Results
Metadata Results
Google Search#
This notebook goes over how to use the google search component.
First, you need to set up the proper API keys and environment variables. To set it up, follow the instructions found here.
Then we will need to set some environment vari... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_search.html |
bb782251a688-1 | '1 Child\'s First Name. 2. 6. 7d. Street Address. 71. (Type or print). BARACK. Sex. 3. This Birth. 4. If Twin or Triplet,. Was Child Born. Barack Hussein Obama II is an American retired politician who served as the 44th president of the United States from 2009 to 2017. His full name is Barack Hussein Obama II. Since th... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_search.html |
bb782251a688-2 | Number of Results#
You can use the k parameter to set the number of results
search = GoogleSearchAPIWrapper(k=1)
search.run("python")
'The official home of the Python Programming Language.'
‘The official home of the Python Programming Language.’
Metadata Results#
Run query through GoogleSearch and return snippet, title... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_search.html |
bb782251a688-3 | 'title': 'Apples: Benefits, nutrition, and tips',
'link': 'https://www.medicalnewstoday.com/articles/267290'},
{'snippet': "An apple is a crunchy, bright-colored fruit, one of the most popular in the United States. You've probably heard the age-old saying, “An apple a day keeps\xa0...",
'title': 'Apples: Nutrition... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_search.html |
c06b30a234ba-0 | .ipynb
.pdf
Requests
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.utilities import RequestsWrapper
req... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-1 | '<!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"... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-2 | nonce="skA52jTjrFARNMkurZZTjQ">(function(){window.google={kEI:\'5dkIZP3HJ4WPur8PmJ23iAc\',kEXPI:\'0,18168,772936,568305,6059,206,4804,2316,383,246,5,1129120,1197787,614,165,379924,16115,28684,22431,1361,12313,17586,4998,13228,37471,4820,887,1985,2891,3926,7828,606,29842,826,19390,10632,15324,432,3,346,1244,1,5444,149,1... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-3 | 7428,5821,2536,4094,7596,1,42154,2,14022,2373,342,23024,5679,1021,31121,4569,6258,23418,1252,5835,14967,4333,7484,445,2,2,1,24626,2006,8155,7381,2,3,15965,872,9626,10008,7,1922,5784,3995,19130,2261,14763,6304,2008,18192,927,14678,4531,14,82,16514,3692,109,1513,899,879,2226,2751,1854,1931,156,8524,2426,721,1021,904,1423... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-4 | 974,9,184,26,469,2238,5,1648,109,1127,450,6708,5318,1002,258,3392,1991,4,29,212,2,375,537,1046,314,1720,78,890,1861,1,1172,2275,129,29,632,274,599,731,1305,392,307,536,592,87,113,762,845,2552,3788,220,669,3,750,1174,601,310,611,27,54,49,398,51,238,1079,67,3232,710,1652,82,5,667,2077,544,3,15,2,24,497,977,40,338,224,119... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-5 | 393,1137,781,4,81,1558,241,104,5232351,297,152,8798692,3311,141,795,19735,302,46,23950484,553,4041590,1964,1008,15665,2893,512,5738,12560,1540,1218,146,1415332\',kBL:\'Td3a\'};google.sn=\'webhp\';google.kHL=\'en\';})();(function(){\nvar | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-6 | f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}\nfunction n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&l... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-7 | 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=... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-8 | !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{f... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-9 | 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="skA52jTjrFARNMkurZZTjQ">(function(){window.google.erd={jsr:1,bv:1756,de:true};\nvar h=this||self;var k,l=null... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-10 | 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])... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-11 | 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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-12 | 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>... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-13 | Women\'s Day 2023" border="0" height="200" src="/logos/doodles/2023/international-womens-day-2023-6753651837109578-l.png" title="International Women\'s Day 2023" width="500" id="hplogo"><br></a><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%"> </td><... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-14 | Feeling Lucky" name="btnI" type="submit"><script nonce="skA52jTjrFARNMkurZZTjQ">(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="... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-15 | 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_... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-16 | 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">© 2023 - <a href="/intl/en/policies/... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-17 | nonce="skA52jTjrFARNMkurZZTjQ">(function(){var u=\'/xjs/_/js/k\\x3dxjs.hp.en.ObwAV4EjOBQ.O/am\\x3dAACgEwBAAYAF/d\\x3d1/ed\\x3d1/rs\\x3dACT90oGDUDSLlBIGF3CSmUWoHe0AKqeZ6w/m\\x3dsb_he,d\';var amd=0;\nvar d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){retu... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-18 | l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-19 | 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,\\... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
c06b30a234ba-20 | previous
Python REPL
next
SearxNG Search API
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Mar 22, 2023. | https://langchain.readthedocs.io/en/latest/modules/utils/examples/requests.html |
488be996378e-0 | .ipynb
.pdf
Google Serper API
Contents
As part of a Self Ask With Search Chain
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
os.environ["SERPER_API_KEY"] = ""
from langchai... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_serper.html |
488be996378e-1 | previous
Google Search
next
IFTTT WebHooks
Contents
As part of a Self Ask With Search Chain
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Mar 22, 2023. | https://langchain.readthedocs.io/en/latest/modules/utils/examples/google_serper.html |
7e239ed037eb-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 wil... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/wolfram_alpha.html |
0fb8d2659d01-0 | .ipynb
.pdf
Bing Search
Contents
Number of results
Metadata Results
Bing Search#
This notebook goes over how to use the bing search component.
First, you need to set up the proper API keys and environment variables. To set it up, follow the instructions found here.
Then we will need to set some environment variables.... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
0fb8d2659d01-1 | 'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentials, JMESPath result parsing, lazy initialization, network-less unit tests, and more. Building an open-source and cross-platform Azur... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
0fb8d2659d01-2 | assignment operator.It adds two values and assigns the sum to a variable (left operand). W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, <b>Python</b>, SQL, Java, and many, many more. This tutorial introduces t... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
0fb8d2659d01-3 | To install <b>Python</b> using the Microsoft Store: Go to your Start menu (lower left Windows icon), type "Microsoft Store", select the link to open the store. Once the store is open, select Search from the upper-right menu and enter "<b>Python</b>". Select which version of <b>Python</b> you would l... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
0fb8d2659d01-4 | Number of results#
You can use the k parameter to set the number of results
search = BingSearchAPIWrapper(k=1)
search.run("python")
'Thanks to the flexibility of <b>Python</b> and the powerful ecosystem of packages, the Azure CLI supports features such as autocompletion (in shells that support it), persistent credentia... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
0fb8d2659d01-5 | {'snippet': '<b>Apples</b> boast many vitamins and minerals, though not in high amounts. However, <b>apples</b> are usually a good source of vitamin C. Vitamin C. Also called ascorbic acid, this vitamin is a common ...',
'title': 'Apples 101: Nutrition Facts and Health Benefits',
'link': 'https://www.healthline.com... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/bing_search.html |
192acce45352-0 | .ipynb
.pdf
IFTTT WebHooks
Contents
IFTTT WebHooks
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://iftt... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/ifttt.html |
192acce45352-1 | 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 🎉
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
ht... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/ifttt.html |
5b700ba48a4e-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... | https://langchain.readthedocs.io/en/latest/modules/utils/examples/serpapi.html |
260d71273e1f-0 | .md
.pdf
Key Concepts
Contents
Prompts
Prompt Templates
Input Variables
Few Shot Examples
Example selection
Serialization
Key Concepts#
Prompts#
A prompt is the input to a language model. It is a string of text that is used to generate a response from the language model.
Prompt Templates#
PromptTemplates are a way to... | https://langchain.readthedocs.io/en/latest/modules/prompts/key_concepts.html |
260d71273e1f-1 | Country: United States
Capital:
"""
Few Shot Examples#
Few shot examples refer to in-context examples that are provided to a language model as part of a prompt. The examples can be used to help the language model understand the context of the prompt, and as a result generate a better response. Few shot examples can con... | https://langchain.readthedocs.io/en/latest/modules/prompts/key_concepts.html |
260d71273e1f-2 | How-To Guides
Contents
Prompts
Prompt Templates
Input Variables
Few Shot Examples
Example selection
Serialization
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on Mar 22, 2023. | https://langchain.readthedocs.io/en/latest/modules/prompts/key_concepts.html |
e268ed4bb662-0 | .rst
.pdf
How-To Guides
How-To Guides#
If you’re new to the library, you may want to start with the Quickstart.
The user guide here shows more advanced workflows and how to use the library in different ways.
Custom Prompt Template: How to create and use a custom PromptTemplate, the logic that decides how input variable... | https://langchain.readthedocs.io/en/latest/modules/prompts/how_to_guides.html |
ad8529d318c1-0 | .md
.pdf
Getting Started
Contents
What is a prompt template?
Create a prompt template
Load a prompt template from LangChainHub
Pass few shot examples to a prompt template
Select examples for a prompt template
Getting Started#
In this tutorial, we will learn about:
what a prompt template is, and why it is needed,
how ... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
ad8529d318c1-1 | no_input_prompt.format()
# -> "Tell me a joke."
# An example prompt with one input variable
one_input_prompt = PromptTemplate(input_variables=["adjective"], template="Tell me a {adjective} joke.")
one_input_prompt.format(adjective="funny")
# -> "Tell me a funny joke."
# An example prompt with multiple input variables
m... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
ad8529d318c1-2 | In this example, we’ll create a prompt to generate word antonyms.
from langchain import PromptTemplate, FewShotPromptTemplate
# First, create the list of few shot examples.
examples = [
{"word": "happy", "antonym": "sad"},
{"word": "tall", "antonym": "short"},
]
# Next, we specify the template to format the exa... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
ad8529d318c1-3 | print(few_shot_prompt.format(input="big"))
# -> Give the antonym of every input
# ->
# -> Word: happy
# -> Antonym: sad
# ->
# -> Word: tall
# -> Antonym: short
# ->
# -> Word: big
# -> Antonym:
Select examples for a prompt template#
If you have a large number of examples, you can use the ExampleSelector to select a s... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
ad8529d318c1-4 | # These are the examples is has available to choose from.
examples=examples,
# This is the PromptTemplate being used to format the examples.
example_prompt=example_prompt,
# This is the maximum length that the formatted examples should be.
# Length is measured by the get_text_length function below... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
ad8529d318c1-5 | # -> Word: happy
# -> Antonym: sad
# ->
# -> Word: big and huge and massive and large and gigantic and tall and much much much much much bigger than everything else
# -> Antonym:
LangChain comes with a few example selectors that you can use. For more details on how to use them, see Example Selectors.
You can create cus... | https://langchain.readthedocs.io/en/latest/modules/prompts/getting_started.html |
4981211d3af7-0 | .ipynb
.pdf
Prompt Serialization
Contents
PromptTemplate
Loading from YAML
Loading from JSON
Loading Template from a File
FewShotPromptTemplate
Examples
Loading from YAML
Loading from JSON
Examples in the Config
Example Prompt from a File
Prompt Serialization#
It is often preferrable to store prompts not as python co... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/prompt_serialization.html |
4981211d3af7-1 | prompt = load_prompt("simple_prompt.yaml")
print(prompt.format(adjective="funny", content="chickens"))
Tell me a funny joke about chickens.
Loading from JSON#
This shows an example of loading a PromptTemplate from JSON.
!cat simple_prompt.json
{
"_type": "prompt",
"input_variables": ["adjective", "content"],
... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/prompt_serialization.html |
4981211d3af7-2 | output: sad
- input: tall
output: short
Loading from YAML#
This shows an example of loading a few shot example from YAML.
!cat few_shot_prompt.yaml
_type: few_shot
input_variables:
["adjective"]
prefix:
Write antonyms for the following words.
example_prompt:
_type: prompt
input_variables:
["i... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/prompt_serialization.html |
4981211d3af7-3 | !cat few_shot_prompt.json
{
"_type": "few_shot",
"input_variables": ["adjective"],
"prefix": "Write antonyms for the following words.",
"example_prompt": {
"_type": "prompt",
"input_variables": ["input", "output"],
"template": "Input: {input}\nOutput: {output}"
},
"exampl... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/prompt_serialization.html |
4981211d3af7-4 | Output: short
Input: funny
Output:
Example Prompt from a File#
This shows an example of loading the PromptTemplate that is used to format the examples from a separate file. Note that the key changes from example_prompt to example_prompt_path.
!cat example_prompt.json
{
"_type": "prompt",
"input_variables": ["in... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/prompt_serialization.html |
2d2ff4b69a87-0 | .ipynb
.pdf
Partial Prompt Templates
Contents
Partial With Strings
Partial With Functions
Partial Prompt Templates#
A prompt template is a class with a .format method which takes in a key-value map and returns a string (a prompt) to pass to the language model. Like other methods, it can make sense to “partial” a prom... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/partial.html |
2d2ff4b69a87-1 | print(prompt.format(bar="baz"))
foobaz
Partial With Functions#
The other common use is to partial with a function. The use case for this is when you have a variable you know that you always want to fetch in a common way. A prime example of this is with date or time. Imagine you have a prompt which you always want to ha... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/partial.html |
eab1382e11f7-0 | .ipynb
.pdf
Example Selectors
Contents
LengthBased ExampleSelector
Similarity ExampleSelector
Maximal Marginal Relevance ExampleSelector
NGram Overlap ExampleSelector
Example Selectors#
If you have a large number of examples, you may need to select which ones to include in the prompt. The ExampleSelector is the class... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-1 | ]
example_prompt = PromptTemplate(
input_variables=["input", "output"],
template="Input: {input}\nOutput: {output}",
)
example_selector = LengthBasedExampleSelector(
# These are the examples it has available to choose from.
examples=examples,
# This is the PromptTemplate being used to format the ex... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-2 | print(dynamic_prompt.format(adjective=long_string))
Give the antonym of every input
Input: happy
Output: sad
Input: big and huge and massive and large and gigantic and tall and much much much much much bigger than everything else
Output:
# You can add an example to an example selector as well.
new_example = {"input": "... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-3 | example_selector=example_selector,
example_prompt=example_prompt,
prefix="Give the antonym of every input",
suffix="Input: {adjective}\nOutput:",
input_variables=["adjective"],
)
Running Chroma using direct local API.
Using DuckDB in-memory for database. Data will be transient.
# Input is a feeling, so... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-4 | # This is the list of examples available to select from.
examples,
# This is the embedding class used to produce embeddings which are used to measure semantic similarity.
OpenAIEmbeddings(),
# This is the VectorStore class that is used to store the embeddings and do a similarity search over.
FAISS... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-5 | The selector allows for a threshold score to be set. Examples with an ngram overlap score less than or equal to the threshold are excluded. The threshold is set to -1.0, by default, so will not exclude any examples, only reorder them. Setting the threshold to 0.0 will exclude examples that have no ngram overlaps with t... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-6 | # and excludes those with no ngram overlap with input.
)
dynamic_prompt = FewShotPromptTemplate(
# We provide an ExampleSelector instead of examples.
example_selector=example_selector,
example_prompt=example_prompt,
prefix="Give the Spanish translation of every input",
suffix="Input: {sentence}\nOut... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
eab1382e11f7-7 | # Since "My dog barks." has no ngram overlaps with "Spot can run fast."
# it is excluded.
example_selector.threshold=0.0
print(dynamic_prompt.format(sentence="Spot can run fast."))
Give the Spanish translation of every input
Input: Spot can run.
Output: Spot puede correr.
Input: See Spot run.
Output: Ver correr a Spot.... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/example_selectors.html |
2d66cbce8b80-0 | .ipynb
.pdf
Provide few shot examples to a prompt
Contents
Use Case
Using an example set
Create the example set
Create a formatter for the few shot examples
Feed examples and formatter to FewShotPromptTemplate
Using an example selector
Feed examples into ExampleSelector
Feed example selector into FewShotPromptTemplat... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/few_shot_examples.html |
2d66cbce8b80-1 | Follow up: Who was the founder of craigslist?
Intermediate answer: Craigslist was founded by Craig Newmark.
Follow up: When was Craig Newmark born?
Intermediate answer: Craig Newmark was born on December 6, 1952.
So the final answer is: December 6, 1952
"""
},
{
"question": "Who was the maternal grandfather of ... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/few_shot_examples.html |
2d66cbce8b80-2 | Question: Who lived longer, Muhammad Ali or Alan Turing?
Are follow up questions needed here: Yes.
Follow up: How old was Muhammad Ali when he died?
Intermediate answer: Muhammad Ali was 74 years old when he died.
Follow up: How old was Alan Turing when he died?
Intermediate answer: Alan Turing was 41 years old when he... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/few_shot_examples.html |
2d66cbce8b80-3 | Follow up: Who was the mother of George Washington?
Intermediate answer: The mother of George Washington was Mary Ball Washington.
Follow up: Who was the father of Mary Ball Washington?
Intermediate answer: The father of Mary Ball Washington was Joseph Ball.
So the final answer is: Joseph Ball
Question: Are both the di... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/few_shot_examples.html |
2d66cbce8b80-4 | OpenAIEmbeddings(),
# This is the VectorStore class that is used to store the embeddings and do a similarity search over.
Chroma,
# This is the number of examples to produce.
k=1
)
# Select the most similar example to the input.
question = "Who was the father of Mary Ball Washington?"
selected_examples ... | https://langchain.readthedocs.io/en/latest/modules/prompts/examples/few_shot_examples.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.