New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Build On chain AI Agents on Galadriel - ETHGlobal Brussels 2024

ETHGlobalWed, Oct 9, 2024, 12:00 AM

Join Kaspar Peterson from Galadriel, for a workshop titled, “Build On chain AI Agents on Galadriel.” Kaspar will show devs how to build and deploy an on-chain Al agent on Galadriel Devnet using the tooling built by Galadriel. All of the code is written in Solidity which leverages Galadriel's teeML solution to bring Al (LLMs) inference on-chain, into smart contracts. This workshop took place during ETHGlobal Brussels, a 3-day hackathon held in Brussels, Belgium from July 12 to 14, 2024. ETHGlobal Brussels brought together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! ---------------- Follow us: x.com/ethglobal Website: https://ethglobal.com Email us at: hello@ethglobal.com

Transcript

[Music] hello welcome so I'm from gadal I'm a developer and a Founder in the company we're building the L1 for AI and our reasoning is that we started uh building on another change and then run into problems that we couldn't solve and decided to build our own layer one for this one uh that's optimized for AI use cases yeah okay is it better not that much ah yes um yeah I'm going to briefly go over like uh what we're doing and I would like to focus mainly on how to build it I will show some code examples and uh do some uh live live demo um yeah so what you can build on us is the um some of these examples it's also linked on our uh our docs uh so some of the AI gamings uh economics agents forms and uh trust and transparency for AI so you can actually see on the Chain what's going on uh how is this logic working um we have shipped some of the um examples as well fully open source what we have built so first one is the obvious one which is a like getting started one on chain chat gbt you can chat with it you can see the front end uh code what's needed uh the solidity contracts and the script how to call it call it out we created an AI game as well based on vitalic um which is a fully Dynamic game so each game is fully unique it's generated by llm so like what's the what's the environment in the game what's the actions can happen it's like a battle game you have to fight and um Al also fully open source so if you're building you can see how it's built um generative AI nfds the same thing uh it's fully open source you can check it out and also AI agents uh which is essentially one llm is one smart contract and it can interact with other smart contracts um yeah and this is um explanation in here how it works in the first phase of our Network we call it uh trusted execution Enclave so this is um um completely separate part of the CPU essential on the computer that's isolated from the rest of the machine so and you can cryptographically attest this that whatever is running inside you can completely verify that it's running exactly uh as it should be and here's the demo uh you can try it out immediately you need to have the metam mask so every everything you do in here is a specific transaction on the blockchain um and there's a small image as well how it works so you have your smart contract it's like any solidity smart contract contract all your existing tools work on evm U and you're calling our uh Oracle contract which uh then afterwards uh after it's done Computing it answers back to your contract and uh the Oracle itself is uh in the execution Enclave as I mentioned and you can see also these set stations um and how to how to verify this is also open source on GitHub so if you have more questions like how to verify this up there um will maybe jump into the quick start um maybe the wi screen is better uh before we can get started um so this is our quick start as well I'm not doing anything secret it's all up here as well uh you need to get um new wallet preferably new wallet you can use their existing wallet as well if you um want um but you need to first get the Dem tokens so you have to log to our Discord and get it from there um you also have to set up a new RPC if you're using metamask but it's also like linked on the website and after we have this ready uh we have the repository in GitHub so you can uh see what's inside there I have it already already cloned in here uh well maybe first look look into the quick start contract uh just to give you an brief understanding what it is so it's uh Sol the contract quick start uh it's a Constructor as you saw from the previous image you need to interact with our Oracle contract so you need to have the address of this Oracle contract uh you can set it up however you want but you know this is just one way to do it uh you also want to make sure that uh only Oracle can call back your uh your smart contract because otherwise like anyone can call it and you know inject uh rubbish inside Raku um and how it starts initializes uh initialize the uh interaction uh you call this function whatever is your input so this is like a just a text um and this one calls our Oracle so it works through the interface um and the message goes in here so this is just one of the function calls we support a couple of other ones as well you can uh check it out from the docs and uh if you call this out and then the your transaction is done um an asynchronous operation so the Oracle in the back end does its job generates it and then calls back your contract it calls back this function and then the response uh is Sav uh to the contract of course you can do anything that you want in here uh you can have your if Els sentences uh ah so the question is how to make sure I got the latest call um this is up to you to design to be honest so in here in here as you can see it's just you know last response you probably maybe want to have like an array yeah yeah yeah so the question is like how to understand which which callback was made uh this is for for the purpose of the demo just you know essentially have this one Bo you know it's set or not but in in reality you probably want to maybe uh introduce um you know your own data structure and array you can set it as an uh with an ID uh as you can see the first parameter is the Run ID so you can use this one to track like uh which is the call and which is the response and you can of course have like U more complicated data structures maybe like nested classes and uh and whatnot yeah perfect um maybe quick show how to how to run it as well um in this one as well we have the Dot N uh in the dot 10 I will show you what I have inside um so uh my private key you can copy paste this um uh which you need to add in there and the wait it's the wrong sorry yeah this is the one so the Oracle address you need to understand what's the Oracle U and your private key we have two two different ones in here one of them is for actual own uh blockchain but if you want to run your local blockchain you know want to use the different keys in there it's just for this reason but you can most likely just use the same ones um I have the dotm setup uh you need to of course install your dependencies and uh deploy quick start it's just um uh simple script um essentially we're using the e. Js we getting the Sol the smart contract code uh putting into orle address and then uh just deploying it pretty straightforward if you have done uh this sorry I already showed the yeah I mean this is was my example I just showed yeah all good it's compiling to contract and doing to deployment um and yeah it's working yeah so you get your contract address uh and I'm setting it in the terminal uh variable and then you can call this out so what we this quick start is image generation model so using dolly in the background and now I can call this contract out um it's asking for the input um so this uh is sent to this quick start contract as I showed uh and this is calling out the Oracle contract and now the Oracle in The Enclave is seeing that someone is requesting a job to do uh does this compute there uh generates the image and at the moment it's uh uploading this not to the IP F but to our our Cloud um but it conceptually doesn't really matter it's just more convenient to get it uh get it up and running for the demo purposes and now you can see that um yeah I generated the image hopefully there's Apes as well yeah a lot of AG um this time yeah uh I have eight minutes um so this is the first uh like simple example um we also have the Explorer as well maybe I'll show it uh it logged out that there was the um transaction and now you can see the transaction in here as well and I mean I think everyone has used some Explorer uh you can put in your transaction or your wallet address or you know whatnot and go there the contracts as well and then you can see what's happening in here one minute too called dysfunction yeah I think we have seen these ones before um but for our purposes we want to make make it possible to build a more complicated agents uh we'll maybe show the um Vector store support uh so rag is very common technique in the AI field which is um having a knowledge base for your AI so if you have use chat gbt you're asking some details of you know outside world it usually doesn't know it only knows what's inside the model so how you can improve this is to have uh a database essentially with with different facts for example or you know you put a a book the whole book PDF inside of it but this whole book you cannot send to the AI immediately or like the llm immediately you probably need to find the correct place in the book to to send to the to the llm and so this is what the retrieval augmented generation is so it's a a similarity based search database it's a bunch of vectors bunch of numbers um but we have made it hopefully a bit more uh accessible so on the python side you can put in your data so I've created this is also in the repository as as well so we have this R tools created a simple uh data uh when I'm presenting and I took the next one as well so cell is presenting uh we need to make this into uploaded this to ipfs so that the the Oracle can access this um I have a simple script in here it's unmodified it's just the latest version of in our repository and you can uh update update this to the upload this to the ipfs and then you get the U IPS uh CID back and then you can put this while it's uploading I will show you this is the J gbt example in here so it's a contract uh and how this works is you know um the knowledge based CID goes inside as well so it can forward this to the Oracle to be used um similar stuff so if you start the chat so first it checks like if it has a knowledge base and if it has it's uh making the knowledge based query it's again asyn asyn operation and after this finishes it calls back the uh call back function that you got the uh knowledge base query back so hopefully it found this first line of this uh text uh returns this to you and then after you got this back you can make the actual uh call to the llm and once this is complete you get the call back to this uh this function um this is one off example but now imagine you can have in here as well uh another maybe knowledge base query or another llm query essentially like a for Loop right or you can call another smart contract out that does you know maybe another piece of operations couple of calls uh question is about can we to multi chain uh not not yet at the moment uh currently supported chains so this is only this chain it's at the moment isolated we we don't do the gross chain integration at the moment um just only DVM but this is definitely on the road map it's F like okay for defi applications mainly like how can I get some more liquidity from other chains to llm stuff with respect to the other chain to the trades um yeah so uh out of the knowledge base I got back the CID I think I need to just quickly modify the previous example to deploy um now deploying the this contract I just showed uh the cht1 with the knowledge base and after this one is um deployed I can actually ask when is my presentation time and uh show up yeah it's deployed now so now what what happens is what I described it first gets the data from the knowledge base uh and puts this into the llm call and then hopefully uh it answers the right time yeah 15 20 I'm not sure why it's double it should be just once yeah uh that's what I wanted to show uh do you have any uh questions I guess not so that's it we at to boot yeah so the question is what do we expect and what are the prices yeah we expect to see AI agents this is what we're interested in the prices uh I'm actually not sure I think you should visit our boot uh our product people are going going to be there as well and we can uh syn ideas and share like what we're interested I think they listed a couple ideas out as well like uh what would be one of the examples if you just want to build on us but don't have any idea then uh we can suggest something as well yeah thank you very much [Music]

Automatic transcript — names and jargon may be misspelled.