langchain/docs/modules/utils/examples/requests.ipynb

85 lines
17 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "markdown",
"id": "f34864b5",
"metadata": {},
"source": [
"# Requests\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "81aae09e",
"metadata": {},
"outputs": [],
"source": [
"from langchain.utilities import RequestsWrapper"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fd210142",
"metadata": {},
"outputs": [],
"source": [
"requests = RequestsWrapper()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "29a77bb2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'<!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=\"/logos/doodles/2022/seasonal-holidays-2022-6753651837109831.4-law.gif\" itemprop=\"image\"><meta content=\"Seasonal Holidays 2022\" property=\"twitter:title\"><meta content=\"\" property=\"twitter:description\"><meta content=\"summary_large_image\" property=\"twitter:card\"><meta content=\"@GoogleDoodles\" property=\"twitter:site\"><meta content=\"https://www.google.com/logos/doodles/2022/seasonal-holidays-2022-6753651837109831.2-2xa.gif\" property=\"twitter:image\"><meta content=\"https://www.google.com/logos/doodles/2022/seasonal-holidays-2022-6753651837109831.2-2xa.gif\" property=\"og:image\"><meta content=\"1150\" property=\"og:image:width\"><meta content=\"460\" property=\"og:image:height\"><meta content=\"https://www.google.com/logos/doodles/2022/seasonal-holidays-2022-6753651837109831.2-2xa.gif\" property=\"og:url\"><meta content=\"video.other\" property=\"og:type\"><title>Google</title><script nonce=\"aq19wV2T4C1ihTXRxVhtqg\">(function(){window.google={kEI:\\'um-uY4OhDtLMytMPwYep6A8\\',kEXPI:\\'0,1359409,1709,4349,207,4804,2316,383,246,5,1129120,1197786,615,380089,16109,19404,9286,22430,1362,12313,17586,4998,13227,3848,10622,22741,6674,1279,2742,149,1103,840,1983,4314,108,3406,606,2023,2297,6345,8325,3227,2845,7,29074,4696,17175,432,3,1590,1,5445,148,11323,2642,4,1538,2304,7039,22023,5708,7357,13658,2980,16808,1435,5815,2542,4094,17,4035,3,3541,1,42154,2,14022,2373,342,23024,5679,1021,2380,28742,4568,6255,23420,1253,5835,12141,2827,4332,2204,5280,445,2,2,1,23827,10960,6680,701,2,3,15965,873,9625,10010,5,1922,5784,3995,12415,6715,2261,9931,4832,26504,106,17512,2518,14,82,3890,751,11873,3013,679,109,830,683,899,880,3851,1125,3785,5205,4138,1763,1742,813,1514,578,1772,1497,2,563,931,60,970,31,1093,351,90,399,96,426,1034,42,291,2260,409,723,925,836,575,20,3,260,607,1344,917,424,1304,1197,2311,4,6,845,1,856,823,207,795,1443,26,378,71,3,538,515,84,551,157,327,331,270,6,261,764,184,394,87,4,994,1254,5,342,459,718,130,108,68,394,219,84,129,109,23,91,11,115,328,3,182,1,1985,337,3,500,62,3644,555,625,575,102,38,425,36,12,1477,1422,495,128,427,621,311,267,103,191,219,2145,337,785,578,72,22,4,191,40,2,355,199,353,1420,1072,712,5277284,435,5994420,2804424,3311,141,795,19735,1,1,346,3579,66,5,23946834,553,2772342,1269248,1964,1007,15665,3406,5595,11,3834,1924,5046,228\\',kBL:\\'Dl4b\\'};google.sn=\\'webhp\\';google.kHL=\\'en\\';})();(function(){\\nvar 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(\"&lei=\")&&(d=m(d))&&(e+=\"&lei=\"+d));d=\"\";!c&&f._cshid&&-1===b.search(\"&cshid=\")&&\"slh\"!==a&&(d=\"&cshid=\"+f._cshid);c=c||\"/\"+(g||\"gen_204\")+\"?atyp=i&ct=\"+a+\"&cad=\"+b+e+\"&zx=\"+Date.now()+d;/^http:/i.test(c)&&\"https:\"===window.location.protocol&&(google.ml&&google.ml(Error(\"a\"),!1,{src:c,glmm:1}),c=\"\");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).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,
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"requests.run(\"https://www.google.com\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3f27ee3d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}