chainlink staking percent chainlink gate wheels top chainlink wallets Integrating ChatGPT with Decentralized Applications using Chainlink Functions
foreign GM everyone uh so you should be able to hear some music you should be able to hear me or see me at least lets get some GMS into the chat were gonna so I can confirm that you can actually hear me and were gonna start in couple of minutes so were gonna wait for everyone to join us and then were gonna kick this Workshop kick off fantastic thank you whats up foreign music templates whatever so I just think that hit the Lo-Fi so I dont know but I can maybe Shazam it later or Google it and post it on Twitter and were gonna find out but yeah lets start so first to turn off the music okay so Im gonna turn on the music turn off sorry hide this manner and yeah lets start so hello everyone welcome to another Channel Workshop uh Channel hackathon Workshop todays topic will be integrating chart GPT with this Android application using channeling functions so hopefully you already know what training functions is but if not were gonna cover that as well I assume that all of you here watching this uh know what chat jpd is obviously if you uh and maybe try it and maybe have a couple of ideas how to use it in about three space or with blockchain technology so this Workshop is going to be all about that I can also say that we for this hackathon for the first time we have a separate AI tracks of sort of partial intelligent track so anything that use similar Technologies to this one is applicable to that track as well so if you have some ideas make sure to apply to that drug as well and yeah lets build so before that my name is azure maybe I already know Andre rakich and Im one of the developer advocates for China products and clubs here you can see I listed my Twitter and land schedule handles uh if you have some questions after this Workshop after the Q a session feel free to uh to to bring me there to write a tweet on my wall Ill Ill make sure to to answer you okay so yeah but this is gonna be like a Hands-On session so you can follow along or code along with me Im gonna try to keep it at a reasonable Pace but for you to be able to to use training functions later you will need to sign up for beta so General functions is currently still in beta Im gonna actually Im gonna during this Workshop Im gonna assimilate the response so were not gonna actually deploy our smart contracts to the blockchain but if you want to deploy it to some of the available testnets at the moment you will need to sign up for General functions and you will be approved in 24 to 48 hours max but probably under 24 hours so if this QR code for some reason does not work the official website is functions.jain.link um and this is like a simple type form typing has a good question if we did the math class yesterday are we registered already yes so if you already sign up for beta and youre whitelisted yeah I dont need to do one more time so how to be whitelist you will need to enter the address the wallet address basically of your wallet account its from your own account and you will be able to create functional subscriptions manage them Etc uh if not if youre not whitelisted or youre using different wallet address uh you will you should be able to actually see inside the terminal uh like the error message saying hey youre not whitelisted this is this project is already currently in beta blah blah so go to this URL and register so again Im gonna just simulate the response but if you want to deploy and actually use this on some of the test Nets uh ethereum support on Mumbai are at the moment available then you will need to sign up for the data okay so what is training functions so training functions is basically a system to execute any code you want to run and get decentralized and verifiable consensus on the result so uh you are aware that chain link has a system called any API or external API whatever and that system like if you it works great but its not extremely suitable for production ready code the the main reason or the major reason is that if you follow along the official documentation youll see that the I dont know the like beginner friendly example actually use one single node and one single API endpoint this means that this thing is extremely centralized right so for you to be able to actually properly build a production ready code you will need to manually speed up multiple loads and have multiple API endpoints and then you also have like a verifiable result Journey functions take this to Next Level so lets say you have API endpoint and you want to create for example HTTP get uh requests to that API any API endpoint lets say its like forgetting a price of some assets whatever uh the request is not going to go through the node actually its gonna go its gonna go through the dot so as you already know or maybe you dont know Don stands for teeth sanchoice Oracle Network and its it is a network of chain link nodes which uh basically functions separately but and this Dawn is just a decentralized Oracle network is not a blockchain but it needs it needs to reach a consensus so thats the main range the reason so how this thing works basically if you create an HTTP get request each each node is going to execute the same request on its its in its own serverless environment provide a callback result to the rest of the network via peer-to-peer Network called OCR then the dawn will reach consensus of the on the final result and then send it back as a callback value to the calling smart contract which is purely the sacrifice solution and much easier for you rather than uh like managing multiple nodes and multiple endpoints okay but besides this HTTP get request now you can actually write any type of code it can be HD post request like you can send email notification emails notifications Etc you can perform uh like computation that is usually extremely expensive to be done on a blockchain or in solidity like for example you have a D5 project and you need to create some kind of complex net or some I dont know like uh some some net computation for I dont know like some extreme use cases in D5 whatever like these type like solidity is not the best language for for that like so it doesnt have decimal places all of these computation can be extremely expensive to to be done on chain for example I dont know like uh logarithmic values etc etc so you can actually Outsource or crowdsource this work to the Dawn at the fixed price as like simple chain link requests so it literally any code we have a couple of versions so any API is not also your agnostic right and generic functions is yes pretty much yes yes so this is much decentralized solution and and also have much more functionalities than just any API literally any code at the moment for the beta thats only vanilla JavaScript but this is beta on a test net we are going to expand it pretty soon to multiple languages but male JavaScript means that for this hackathon at least you will not be able to install external libraries like I dont know either jest or something like that but again its still pretty doable uh to to write a JavaScript because uh these functions think come with some predefined functions Library which are extremely easy easy to use okay so how this thing works for you as a smart contract or software developer back-end developer the only one thing is important and thats uh how to properly send a request thats it so in Step number one your smart contract is is gonna send your code as a like function argument and your code I mean literally JavaScript code two additional rhetorical Network or done and as I said each Dons Oracle node is gonna run the same code in separate serverless environment and then with step two the Don will aggregate all of these independent computational results applies a consensus and Returns the final cryptographically verified result to your smart contract for this Workshop I already mentioned for a couple of times Im gonna simulate the response why is that because if there is an error in your JavaScript code or some and handled error use case then you will still need to pay some amount of Link tokens per computation because nodes are still gonna execute that JavaScript code but a beauty is that you can actually change this JavaScript code because its literally a functions because its literally like a function argument solidity function argument so this is more fii fi Okay so this is a schema of training functions architecture uh okay we have a couple of questions uh actually one question thats amazing sometimes were gonna change everything uh yeah hopefully its gonna change everything but you will now need to build some amazing things with it Okay so uh youre youll be responsible only for creating this user dap slash smart contract so this is your smart contract which again is anything like whatever you want to build on chain is going to be present there and there is going to be a call to determine functions similar to call to I dont know database or vrf Randomness automation Etc so your end consumer can be your wallet account or maybe a time-based training automation if there is something to be uh automated uh I I see a question so Im gonna finish this sentence and answer the question so after that or before that you will need to create a functions subscription so subscription model is exactly the same as via wrap subscription model automation subscription model Etc so were going to create a subscription funded with some link and then you can add multiple consumer contracts to the same subscription so this is what these chain link functions smart contract billing registry is for just for handling subscriptions youll need to do this only once and thats it Im not sure uh for this beta but there should be like a UI for doing that if not its extremely simplified to call the the function method on train okay couple of questions uh questions yeah Evan says can you elaborate on training on governance yes so for at least beta uh we we where we only have like this thing on a test match the the like consensus mechanism that is being used is median value so imagine that you have like for example five nodes and uh finals needs to I dont know like divide two numbers uh then each of them are gonna respond like we appear to put the network report its own value and then were gonna have like a median value and I guess thats in the same way that if for example we have five nodes and three of them like uh managed to execute HTTP get request for example and two of them like fails to do that will still have a consensus with that if the uh if the Callback value from the from the get request is the same were gonna still have the the the consensus on that result uh this is still in beta once again so this consensus mechanism is subject to change uh but at the moment for this hackathon at least its gonna work like I described um okay yeah good question so when I ask strategypt the same question twice it answers differently so how do nodes reach consensus if each will get a different activity response well yeah uh the its per request based so your first ask to the chat to GPT is going to be one functions call and then theyre gonna have like the same response than with another is going to be another attack so thats thats pretty much the thing uh okay can you pass a seat uh can you pass the chdi so so all the Oracle for example the same thing with the same prompt yeah so you can pass whatever you want I havent talked about that but like you can actually pass like API uh Keys Etc because youre gonna need it uh and theyre gonna be encrypted Im gonna show you how to do that uh which means that theyre not going to be stored on chain or they cannot business so basically you can pass whatever you want uh your source code can be whatever you want you can Implement whatever logic you want in it uh the the node are gonna execute it okay we dont have any more questions so I can continue this is the second part of the the giantic diagram generally functions architecture and again this is the thing that you dont really need to worry about as a smart contract development but this is how it works under a hood so request is going through down through it on then each node were going to execute in the same serverless environment blah blah we already spoke about that and then its gonna as I said uh return the the Callback value uh to the calling smart contract so once again this is how it works under the hood but as smart contract development youre only in charge of this tiny part your smart control and the JavaScript code that you want to pass to the functions okay so coming back to the story what is this JavaScript code well as I said multiple times it can be anything literally anything so you can connect your smart contracts to some I dont know whether statistics data and create like Dynamic nfts you can connect data as I said to password protected iot devices because as I said uh the secrets are not are not stored on chain theyre encrypted and only nons can decrypt decrypted theyre encrypted with the nonspad with the nodes public key and then uh each node can decrypt it with its own private key and then after the execution the secrets are automatically deleted so extremely safe mechanism so like you can connect it to positive devices like smart watches do whatever you want like I dont know Tesla cars like like Harry did and one of the previous hackathons Etc uh like yeah connected the central database like ibfs to some on-chain of chain governance whatever you want fetch any web 3D and when Im sorry for any web to data like connected with AWS cool cloud uh Facebook Instagram whatever like we have multiple of um like boilerplate code or demo examples like how to connect Channel functions or smart contract smart contracts on a blockchain with Instagram and Facebook business pages with twilio and Spotify endpoints uh with AWS currency managers etc etc so everything is on on Smart contract youll be GitHub and I can even provide all of these URLs on my Twitter afterwards if you want to check those examples as well uh yeah Twitter API connect with Twitter do whatever you want Etc so these are a couple of suggestions but if you still need inspiration theres a separate website called use chaining functions so at this website use trainingfunctions.com uh there is like uh there are uh JavaScript code Snippets that you can copy paste and use in your in your projects if you end yeah the best part is that even you can contribute to this website so you can open a pull request provide some JavaScript code that can be used between the functions sound from the team is going to review the pr code uh yeah well go from the pr and eventually merge it and its going to be and its going to appear at use chaining functions website so actually Im gonna use one of the code Snippets from this website for this for todays workshop and its written by the legend itself Patrick Collins uh so yeah lets lets build but before that we have a feedback form for this workshop and all our other previous and future workshops and all other things hackathon related so whenever you have time scan this QR code and fill it it means a lot to us uh okay so Im gonna remove this thing we have a question uh I made a PR or news training functions but its not reviewed can I please review that I think well see I think I cant but Im gonna double check it but someone from a team is gonna Im gonna review it and uh Financial emerge it so dont worry about it just a lot of things is happening to the hackathon so the thing is that I probably dont have time capacity at the moment but someone from the engineering its gonna review it uh okay lets start with the workshops so Im uh uh Im gonna actually paste this to the chat so functions Target so go to this website and clone this repo so this is like a hard cut project which is like a function Star card and starter kit uh which like which is like a boilerplate code for using functions but the thing is that there is like a bunch of other branches name tutorial Dash number so I highly encourage you to check those as well because there is like multiple tutorials present in the repo but we are gonna uh we are gonna uh git clone the the repo itself now so Im gonna present my terminal okay you should be able to see this and what Im gonna do is Im gonna stream out uh Im gonna type get clone testing and hit enter so Im gonna so this git cloned the repo inside functions Target and now Im gonna CD into that folder functions are historical and open my code editor of choice Im using visual studio code you can use whatever you want basically Im gonna open it with this command this is like a shortcut which means that Im gonna open Visual Studio code in this folder dot means in this folder so you can open it manually whatever but git Chrome the repo and open integrated uh like not in the return sorry your code editor okay Im gonna stop sharing this link give me a second hides uh sample project links uh Im gonna share it I dont have it with myself but Im gonna share it on Twitter afterwards so this is my Twitter handle uh and then I just need to to find it and Im gonna share all of this all this URLs number okay lets now uh present Visual Studio code in uh a couple of seconds so share screen window and you should be able to see this okay Im gonna assume it like this Zoom it a bit uh and yeah we can start with the workshop so this is the the repo um okay we have another question can you compare cost of running some code example and solidity versus training gun uh it really depends on the computation you want to perform like solidity can be extremely cheap for some things but extremely Coastal for other well this is kind of its a good idea maybe I can do some benchmarking but you should really come with the example and then we can figure this out like exact numbers like math thing should be like 10 ton times cheaper we are done than the solidity but again you get a point um uh how can I sign different arguments as input by user directly from the control to user or when you enter the arguments Im going to show you in 10 minutes okay lets lets start uh so we have a couple of stuff over here but the the first thing actually that we need to do is that we should install this thing so open integrate terminal and type npm and stuff okay now that we have and installed this thing lets take a look at the repo itself it has a really nice readme by the way so lets see if we can maybe do something like this that was kind of like a really nice readme we thought with the overview sport networks okay we have our launch Fuji doesnt as well some tutorials examples and then uh steps that Im gonna execute now during this Workshop environment variable management Etc all of the commands glossary Etc so I I really suggest you to to take a look and read it it will take five to ten minutes max but it is extremely it is an extremely valuable resource besides the official docs or obviously uh so cool we have so theres two real important files here actually three but two JavaScript files and one solidifier so the first uh file that is extremely important is this functions request config.js so this is the config thing for your uh for your training functions project the second one is the JavaScript code that we are gonna pass as a function argument um Im gonna create it right now and name it functions request source.js so create a new file name it functions request source.js and finally the third one is this functions consumer dot solidity so this is a solidity contract that actually sends the that actually communicates with done so um this is like a boilerplate code it has functions Library here imported they are going to be part of the npm package once this project is out of the beta uh and it has three historic variables latest request ID latest response and latest error if there is any errors so execute requests this is the source code that youre gonna pass basically were not going to touch the solidity code at all and fulfill request this is where youre actually gonna have a response so its here and then youre gonna actually do something with the response the code here is from dumb is just populate these storage variables over here but this is where youre gonna actually uh perform whatever you want with with the Callback values like execute request this is like a syntax literally copy paste it and thats it so config were gonna set in a minute but first we need a source code a JavaScript source code that were gonna that we wanna pass to the Dom so Im gonna again stop sharing my screen um a reminder with Branch youre on on the main branch so it doesnt you dont need to get checkout just clone the repo and uh uh I can zoom it to it yeah yeah I have an assert but for that Im gonna share my screen so as I said this is um use channelfunctions.com website you can add your own example over here and here is a prompt AI for response so again submitted by the legend itself this code will ask open AI for information on chain and this 31 line of code is everything that we need for this Workshop okay so what Im gonna do now is that Im gonna hit this button over here or select everything and copy this code inside that functions request source.js file okay so were just going to copy this and then were gonna explain what the the code actually does okay stop sharing my screen uh present Visual Studio code okay paste it here okay and Zoom it a bit okay save it so what this thing does it gets prompt as a function argument it checked for secrets and there is like if and there is an error handling means that if we havent set open AI key its gonna revert it makes HTTP request specifically HTTP post request to this API endpoint this is the authorization header this is the text model that used this is the official prompt Im gonna set temperature to 1 Chrome so from zero to one so dont forget to do that set temperature from zero to one I can wait a bit and finally we have Max tokens so max tokens you can you can imagine it as a number of words that air model is going to return to you not exact math but this is basically for you to limit the the response size because open AI API is is if Im not mistaken pay as you go so um you know like this is just for you to save you some money after that we have API response were were basically awaiting this promise to be resp um resolved and were returning the result as a string so this functional library has build it function and code shrink so console log is just a JavaScript console log for us to see it in terminal its not going to be part of the of the like its not being going to be present on chain okay so before we start Im gonna stop sharing my screen once again um and then Im gonna yeah uh thank you for the for the URL Im gonna present my screen once again sorry about that so represent this so you need to go to platform.openai.com account API keys Im gonna paste this link over here log in with your charge GPT account or sign up and generate a new API key just there will be a button generating new API key okay stop sharing here paste it in the chat and before we continue I must say that you there is a possibility that you will get error four to nine if Im not mistaken which is literally too many requests error you know that due to its popularity chargeability sometimes have the the issues that even you cannot use it like from the web-based UI so the same things applies to the API the keys if you have that problem you will need to upgrade your API key plan is it is pay as you go so that means that uh they they dont gonna charge you a lot if you limit the number of tokens as I have limited it to seven uh that that means that when you sign up I think youll get like 18 dollars of credit or something which should be more than enough for this example and which should be you know for again enough for hackathon projects after that were gonna figure it out but this is currently the status maybe you will not need to to upgrade it but we are gonna literally see so again if you have like four to nine error I think too many requests error uh there is like extremely high possibility that youll need to upgrade your API key so this is more of fii for you guys so I have my API key already uh so Im gonna for the final time present with audio code and thats thats gonna be it Im not gonna do it again and again and again Okay so Im gonna talk a bit now about secrets clear this thing uh and talk about Secrets management so for this example to work we will need to set three values open AI key or API key obviously our private key like wallet private key whitelist as well as private key and um RPC URL for uh for a blockchain that we want to be on so at the moment here in sepolia polygon Mumbai or Avalanche Fuji usually what you will do it will create dot Envy file paste that as a plain text write your private Keys Etc and you will make sure that you dont push that to to GitHub um we went one step forward so there is no dot Envy file we have created from scratch again this package chain link EnV Dash ENC which means that this package is gonna encrypt your secrets okay its going to create a secret secret GitHub gist for a single response for a single request sorry and that gist is gonna be uh its gonna be part of me its gonna be deleted after the request um it will automatically generate a file called Dot env.enc its not the best practice to push that file to GitHub either but nothing huge is gonna happen if you accidentally push it because there will be present encrypted values of your secrets private key API key Etc so to be able to encrypt those we will first need to set up the password so make sure you remember that password and to set it up the command is present in the readme actually as well so readme is extremely valuable valuable resource for this thing so the command is npx EnV set ew okay once again npx EnV Dash NC space set Dash PW send password and hit enter so again enter the password input will be hidden so Im going to enter some password and hit enter this is against really bad password by the way but I literally typed test just for this for this for this demo so Im gonna copy paste this thing to the chat as well so you can copy paste it so type this we have an interesting question does the version you can see have a ubiky integration um like 99 no actually I think no but this is this is good this is good suggestion maybe maybe engineering team can can expand it but at the moment I dont think so uh I got the error four to nine uh yeah so I spoke about error 429 uh that means that you will probably need to upgrade your open AI API key to update plan uh not much like its going to be extremely like like five youll spend like five dollars Max for for the hackathon itself but you will need to connect your credit card to do that sorry but thats like just open AI judge a bit I think nothing we can really do about it or just wait for for like less traffic on on activity but its its extremely popular so okay so we set the password and now our next command will be npx EnV Dash ENC set so Im gonna type that npx EnV dot dash sorry DNC sat okay so now for each variable name Im gonna enter the value itself so were gonna were gonna go really slowly with this so first this is the command for real to copy paste and we will need to set three values so value number one is RPC URL so Im going to use polygon Mumbai but like you Ill set polygon Mumbai RPC URL or you can use you can set these two as well okay so how Im gonna set polygon Mumbai RPC URL Im gonna give a second copy the the name of the secret variable itself polygon formed by RBC URL Im gonna hit enter now Im gonna enter the variable value so Im gonna now enter that endpoint which can be like which you can get from infuria Alchemy all of other these nodes as a service or if youre running your own polygon online node then your own node but here youre gonna enter the whole for example if youre using Alchemy the whole Alchemy URL with the key itself so Im gonna now copy paste this thing from my notes nodes your your eventually you unfortunately want to be able to see it but this is like Alchemy endpoint for like Alchemy RPC URL that Im gonna use for polygon Mumbai and Im gonna hit enter and now it says would you like to set another variable if yes again repeat the process so the second variable that I want to set is private key so this is my wallet private key that is whitelisted for the usage of chain link functions so private key this is the name of the secrets variable so copy paste private key or I can actually type it private key mannerable hit enter please enter the variable value so right now Im gonna copy paste my whitelisted wallet private key okay Im gonna grab it from my notes paste it here and hit enter again would you like to add another value yes we need to add open AI API key and lets see where it is oh um give me 20 seconds yeah we can we can actually do something like this open AI API okay so we are gonna set this value okay first paste it into the chat okay this is the the naming I used so open AI API key this is the variable name hit enter enter the or copy the API key itself and copying it right now and hit enter would you like to add another variable no so to finish I need to press enter and thats it Ive successfully set all of my secrets variables do we have any questions so far yeah another thing that I mentioned the new DOT Envy dot ENC so EnV encrypted file is going to be generated and this is put this down put this aside this is the content of of dot EnV dot encrypted file so this is my RP URL my private key and my open AI APK but they are encrypted this is these are not the actual values these are encrypted values of the secrets that I provide so even if you push that to the GitHub only with your password this can be this can be decrypted okay uh do we have any questions uh if someone is running a node what romance came from extracting decrypted secret key and use it in its own on its own uh this is currently work in progress so for the beta only uh chaining nodes are being run so uh so we dont have that concern at the moment but again for the production engineering team is currently working on a system that is going to prevent this from happening obviously this is a big concern um do we need all three of these RPC URLs no only one for this Workshop we are going to use polygon Mumbai but I paste it for you to know that there is supposedly I can avoids available and this is the respectable Secrets names so were gonna use both actually we we need this RP URL just for for a thing to work and as I said Im going to just simulate this Im not gonna deploy it to Mumbai um is there a script available that we can run to ensure that the keys have been correctly uh I dont think so I can create one for you but what you can do is that you can type npx and C uh sorry EnV ENC View this command and with this command you can validate that you have set them correctly so this is gonna decrypt them and display them in your terminal so Im not gonna do it at my end because youre gonna see my secrets but this is this is the way I mean there are dumbest Secrets by the way I created a new Keys new ones everything from front so no no worries about that but yeah so this is how youre gonna view it no activity no uh which algorithm is used I dont know but we can check it later theres like a source code available at the packet Json file or like uh at GitHub I havent checked it sorry uh I should know that actually were taking seconds and yeah I can maybe answer this on Twitter okay now the fun part lets combine these secrets with the config that can execute the source code we copy based from copy based from Patrick um good one good one uh okay but try it but these are all done with values by the way so there is no no money there okay uh yeah so you you yeah you can see um we also the code excellent so Im gonna split this on the right so you can follow along better no at the moment no okay so we have uh this config a couple of couple of so we have a location which can be inline remote for Secrets where you can store them uh we have languages that you can write write code for at the moment again only JavaScript whenever JavaScript is is important there are a couple of return types so uh this these are the types that can uh training functions can return to the calling smart contract so inside that fulfill request function and solidity you should actually be aware of the data type that is going to be that your response is going to be so we can send unsigned integer signed integer integers like numbers strings and buffer is basically for bytes so bytes can be anything like you can Abi Abi encoded on on the JavaScript side and API decoded on a solidity side so it can be like address array of addresses structs mappings array of structs whatever like this this is the current or whatever like bytes value can can be insulated okay then we have this request config that we need to set up so first of all location of your source code again inline or remote we are in beta so only inline is currently supported supported but can be can be remote as well then code language again JavaScript okay nothing that we can actually set here so were gonna skip this these two third one source code so so where is our source code so our source code is actually inside functions request source.js with which is present at the at the root of this repository so what you can see here that there is like calculation example an API requested example so these examples uh is like tutorial examples boilerplate code you can actually check it out right but I skipped it and go go straight to the chat Jupiter thing so what I need to do here is that I actually need to um to type functions request source thats it like this is the source code like JavaScript source code this one then we have secrets so Secrets can be accessed within source code why do we need Secrets like because we we maybe want to provide some some super data to the column uh to the calling transcript code so Im gonna split this to the right and here you can see that we are using only that you can access Secrets object this one with secret skewered and then this example has open air key so what I need to do is that I actually need to set this value here so Im gonna change so open AI key is open AI API key that I encrypted using envy-emc Library okay so this literally means that okay I have a typo here that from Secrets object from open ID its gonna decrypt it and use only this variable inside for for code execution okay then we we said we have HTTP get request which has this prompt and where this prompt comes from from here its the first argument so so again pronounce Secrets nothing for this Workshop basically uh its assigned to each done member uh so which means that if you have like four four nodes you can actually specify uh per node Secrets this this is gonna uh so and then you youll have like uh some code logic in your JavaScript code uh which uh so this is basically for you to prevent to hit like I dont know uh for uh so lets say that you have four four nodes and you want to send an email after some computation uh you dont want to send four emails you want to send only one email with per note secrets you will have some kind of flag as as another secret and then youll have like a actual JavaScript Logic for handling that that secret so if node is aware of the that flag value then its gonna send the the the email otherwise not so this is what why per node Secrets exist while wallet private key just get the private key from from the invar EnV and yeah arguments so these are the arguments that you can provide to the JavaScript code like a function argument it it needs to be a string array so these are a couple examples dummy one nummy ones here is the actual prompt that we want to to send so if you have any examples of or any recommendations for us for what should we ask chat gbt poor please write into the chat Im gonna wait for a minute or two and then we can continue with the workshop uh until then I can answer some questions so uh uh okay can we can we use functions without EnV ENC uh you will need to at least encrypt a World Private key and RPC URL um otherwise is gonna fail um and this is basically the reason why so thanks thanks DP for clarifying that uh what was the temperature temperature stuff uh in data HTTP request good questions so Im gonna discuss from the from the chat GPT docs actually open AI docs so Im just gonna quickly go there so to give you the exact answer give me 20 seconds Max basically um okay okay temperature temperature okay so temperature can be zero to one zero is minimum one is maximum the higher temperature the more creative uh is the response while the lower temperature the more predictable is is response this is basically tldr for the temperature um so for the return type if youre making our own custom version we just make a conversion of that argument which should be it solidity yes thats correct um the only thing we can guess basically okay create the character sheet for uh Dungeons and dragon Dragonborn wizard named okay okay uh and change the name currently that was clever okay uh asking because they want to use it in Foundry yeah uh uh Im not sure about the workaround for Foundry uh because this is a JavaScript only but maybe we can hack something and continue the conversation on the computer and temperature yeah thank you I cant send this uh the this this comments already so you this shame is same time from uh for from from Google okay um so we have only one suggestion um about Dungeons and dragon character but maybe we can do something similar because we want to limit the single line uh maybe okay lets see something like this please give me a name off chain link Dungeons and dragon character in one line maybe changing Marine than just a drawing character in one line lets lets try with that I dont know uh if you have something more exciting we can try that and final thing is that we need to uh specify the return types so we are not expecting number we are now expressed expecting string so we are we want this thing JavaScript thing to to send the string to calling smart contract which is actually written here so encode string okay the moment of true truth will be to simulate this thing so to simulate the response youre gonna type nbx hardcat functions simulate if I recall the the command correct and hit enter so it compiled a bunch of contracts because I havent compiled it yet for the first time and now executing a code and yeah we got the name varana the soup if I pronounce that correctly so this is the chaining Dungeons and dragon character name lets put it here into the chat uh if you want to ask something else we can try that uh lets see are the arguments passed in the contra cost request config fixed uh how one can pass multiple Secrets uh yeah you can just have another argument over here uh like another Secret type whatever and then inside the JavaScript code you will have secrets and other Secret and thats pretty much it delete this okay do we have more questions uh okay okay if not that will be it for todays Workshop now its is the time for Q a session we are right on time exactly one hour so that was school uh if we dont have question maybe I maybe we can ask judge if it is something else maybe we can um we can create a superhero name I dont know for for chaining character to see the actual name maybe I dont know oh yeah what was the command you just run okay give me a 20 seconds to share my screens once again uh and uh entrance requests yeah sorry we lost the code you should be able to see this so the command was uh clear uh npx hard hat functions simulate okay so Im gonna put another prompt here to create a superhero name for a chain link Marine in one sentence and while this is running Im gonna copy paste this to the chat this is the commands Okay and chain link Marine that was really dumb dumb name I think I got like Aqua link or something uh uh while I was testing this thing but nevertheless okay we have an error uh enrolled input yeah uh so actually were again and again passing the sword secrets and arguments can there be something done which requires only arguments to welcome and get results well uh the thing is that once you set the secrets thats pretty much it because you will need to handle them into the source code which you need to finalize like we did like Patrick actually did we literally copy paste it for music use gmailfunction.com so again after I set up Secrets like that part was done so you Ill just Im just now just changing the prompts which is like a function argument first uh first element in args Array so like uh pretty much after you set up you set everything up youll just need to to pass different arguments if you want of course so yeah uh okay so invalid input uh typically have you changed the expected value type to be string instead of doing two five six maybe thats the error we we need to encode uh is there an equivalent of gas limit Im doing to prevent running game from the loops yes at the moment uh so the maximum gas limit for you to send from solidity to the dawn it should be should be 3 000 uh this value so this should be like a gas limit uh to prevent infinite loops uh can talk a little bit about limitations training functions for now yeah uh first obvious limitation is that youll need to sign up for beta and then wait for 10-4 hours until then you can just simulate things a thing like I did second one its present only on test Nets so you can not go to mainnet and uh yeah well need to find the as as your colleague mentioned well need to find like a workaround for Foundry I havent tested this this thing with founder yet but there should be like a workaround over this library but again its its more like uh JavaScript opinion at the moment other than that I dont see I dont see any any downsides at the moment um you have a return type string do you need um actually no uh uh actually no but I can maybe push this thing to the GitHub and then you can only show the Line run it at your end and compare it I dont know foreign everything that I did should be should be enough so change secret arguments source code location expect the string and copy paste absolutely incorporates JavaScript stuff so that it is already there um uh no that theres not a limit I manually set it up uh with number of tokens at the seven which in theory means like seven words like in practice actually some words in theory is different and thats why I specified to to that that answer should be in one line this is just for you to save some some costs on using API open AI API because it is pay as you go you can change it uh by setting the higher number for number of tokens but if Im not mistaken you actually need a certain number of tokens per open AI documentation um maybe I didnt yeah so I could try that like youll need to paste The Prompt in as an argument as a string um getting an error yeah that means that uh you will that this is literally too many requests error so too many requests to the open AI API endpoint which means that unfortunately you will probably need to upgrade your openai API key to be the paid one and you will get some some credits like I think I think 18 or five dollars or something which should be enough for track open but yeah we will need to to connect your credit card there unfortunately uh when do you plan to make training functions available on mainnet I have no idea uh like soon but I dont know I dont know I dont know when exactly but I guess pretty soon I dont know um Patrick had like a interesting sentence somewhere on Twitter like like sooner than you think but not soon as you would like or something like that he he he he wrote that Banner but yeah if we dont have any further questions that will be it for this Workshop uh thank you again for attending the workshop once again uh yeah thats Administration sign up this feedback uh feedback form its a short type form uh which will help us make this workshop and general hacktime experience even better um yeah similar than you think but leather than you expected yeah this is the actual the actual samples for for from Patrick thank you guys for attending this Workshop thank you I hope this was a valuable usage of your time I hope you learned something new and dont forget to sign up for the AI track uh and uh I Im cheating for you I hope that you are gonna build some amazing stuff during Crackdown thank you and have a good one bye bye thank you Learn how you can combine the powerful computation properties of AI models like ChatGPT, with the highly secure, reliable and guaranteed execution properties of smart contracts running on a blockchain
movimientoantipiquetero.com.ar