0:03And we're live. Hello everybody. And well, Jono, you're part of everybody, but special hello.
0:11Thanks. Hey, nice to see you. Nice to see everybody. Got some folks joining from Europe in the middle of the night. That's very impressive.
0:23Always impressive. Mhm.
0:25Um I know Jonno, well, we've both been very impressed with uh some of the student projects during the week. Um any ones that caught your eye that you wanted to talk about?
0:36I grabbed a couple that I quite liked. Um one was Oh gosh, I'm blanking on the name. I'll have to look it up. And or you can see the um share it channel. It's one of the most like once or twice.
0:47Mhm. Um so this was a um student who was trying to find a nice sort of friendlier way to consume the news. And so they've been exploring pulling different articles from the hacken news API to see what's on the front page there using um Claudette to summarize the contents of the page and so exploring like fire crawl for fetching the contents and then putting that all together into this kind of um nice sort of summarried here's one
1:17article per block uh representative way to see what the articles are without going in and reading. And I particularly like this because I've written a few variants of this myself. So this is um distill hn um same sort of idea pulling the article contents summarizing it with with an AI just giving me like a smaller digest of the news that I can't get sucked into spending too much time reading comments and reading long articles and so on. So I really appreciate that someone else is doing it. Also quite on topic for today the um
1:47creation of that HTML representation and bundling that into an app is going to come up in the lesson I suspect. Um so I really enjoyed that one. I also liked um some kind of classic data science explorations done by another Discord username I can't pronounce um exploring some language classification and making some visualizations and again it's like the perfect promotion for notebook driven data science in general and this AI enabled version in particular because you're exploring this data you're
2:16manipulating it you're adding columns you're viewing pieces of a data frame right this kind of table structure for those of you who aren't familiar with pandas Um but every step you can see how many of them have this, how many don't.
2:28Uh what is the various scores? Okay, can I like plot the distribution of those scores? It's very iterative, very exploratory, very perfectly suited to the um the notebook style incremental exploration that we teach. So enjoyed both of those demos and there's plenty of other good um advent of code solutions and so on as well.
2:46That's great. Thank you. [clears throat] Um yeah. And uh yeah, we've had a lot of folks uh comment on the the homework walkth through from last time that they found it really helpful to see maybe almost a bit surprised to see the level of depth that I was going into. Um, which I think is understandable because maybe at
3:15school we all kind of for various reasons get into the habit of often I know for me kind of doing as little as possible. Um, just to check off that I did the homework for teacher kind of box. But actually, yeah, if you want to really get a lot out of the work you do, there's a lot of room to go into a lot more depth um with the help of AI as well to help you identify places that you could understand deeper or go further.
3:44Um so it's great to hear how many people found that useful. Um yeah, I also wanted to kind of comment on um craftsmanship a bit more, you know, as something that kind of keeps coming up. Um we've touched on it before, but I kind of wanted to return to this idea of software engineering once again. And I've only mentioned it in passing but um
4:12obviously I think most people in this course are not professional software engineers but we're most of us are doing some stuff with code which is can all benefit from the craft of software engineering. Software engineering is definitely not a science and um it's a craft where I think the key goal of software engineering is is to allow you to the more work you do on a project the easier it gets. You know, the faster it goes, the more powerful things you can create.
4:40Um, that may sound like I'm saying like, oh well, you should never hack something together messily or get an AI to do it or whatever, which definitely isn't the case. And in fact, we're going to explore a bit of those I won't say tensions, but um nuances today um with um some stuff that uh um Jonno was playing with um which I think might
5:08explain things really well. Um I will say though, it's um you know, there's no silver bullets. This isn't one of these courses where it's like, hey, the answer is always to do X or Y. But yeah, JTO, we can probably talk about as we go thoughts that pop into your mind about what we've observed, what you've observed. Um Mhm.
5:33Yeah. But maybe before we do, um I might um Oh, I should turn on my what's it called? Keycaster. Keycaster. I'll turn on my keycaster.
5:48Um, and yes, looks like that's working good. Um, and I'll just want to show a couple of little features of solv that we've touched on but maybe haven't spent time on. Um, I don't think we've talked about the different uh solvent modes, have we, Jono?
6:13No. Um, some people have discovered them in passing or noticed that we're changing them. Um, great. So, um, let's ask a question.
6:27Um, hi, could you please show me how to plot a sine wave?
6:39So, this looks like a pretty good answer, which if some random person asked me how to plot a sine wave, I'd be like, "Sorry, [laughter] who are you? What do you want to know exactly?" Um, so it's like, um, I'm somewhat familiar with Python. I don't even know what Mattplot Lib is, but I do vaguely remember my trigonometry from high school.
7:07So, you know, this is going to go down this path of taking you through it reasonably slowly, you know. So, we've got a line of code in an import. Um, so this is in the default mode, which is called learning mode. um where it's going to try to encourage you to spend a little more more time to learn what you're doing as you go and to also ensure that it understands your needs better as you go.
7:37You'll find that the longer your dialogue, the less the modes make any difference because after a while it's going to understand what you want by seeing the context. But it's particularly helpful for the first, you know, bit. Um, if I want to show how different modes work by comparing, um, I could either create a new message above this one by pressing A.
8:01Um, and I should remember to do the thing that Jonno taught me last time, which is move this over here. Um, and so remember, it can only ever see stuff below what's in in the dialogue. So if I switch now to cons, let's do standard mode. So standard mode is basically going to just reply like normal claude would using something like claw.ai on the whole.
8:27Hi, could you please show me how to plot a sine wave?
8:31Okay, so it can't see the thing underneath. So this is doing standard mode.
8:38And you can see it's created a lot of code, lots of stuff that doesn't really help me learn about sine waves. and in fact even some stuff that isn't necessary in this environment and lots of more suggestions and so forth. So that's probably what you've seen that a lot before. Um I could also um put my question at the bottom. So I could just hit CV to paste it down there. And then to make sure it can't see the previous ones um I can just hit H or press the
9:07little I button. Um so then I'll go down H. And so that hides it from the AI. Uh so now if I switch to concise mode um and someone asked if if this is changing the system prompt. So learning mode I mean sorry standard mode is as close as we can get to vanilla claude with just a system prompt that's very much like anthropics. The other two we also do some other bits and pieces to steer the behavior further. But yeah, you can
9:36think of this as different like personalities or different system prompt styles and um guidance towards different ways of writing.
9:45Yeah, one of the things that's included for example is the whole fast AI style guide or at least a subset of it um for concise mode. Um uh and so you can see it this is kind of ends up being like write code the way Jeremy would. Um,
10:07so, um, there's some other differences, um, with modes. So, I hit W to pull that out and I'll run that. Um, um, so we could say um, S plot. Oops. Um, and you see how it's popped that gray text up there, which we talked about before, shows the sign function. So, in everything except learning mode, it's going to do that automatically.
10:42Um, if I switch to learning mode, however, it won't. Um, so at this point, I have to hit uh alt full stop or option full stop um to um cause that to happen. Um, alt full stop. Is that not where I'm working? Well, that's never happened before.
11:10The completion might just be a new line.
11:14So, it's funny though cuz it was um giving me a sensible completion last time. Anyway, uh we'll see that before, but we'll figure it out.
11:22Um so, normally alt full stop would work. Um, that's different to like if you start typing something and press full stop for instance, you get the kind of list of things it can do. So that'll always pop up regardless. And if you start uh typing things, um, it will search. You see here, I type A and so it finds things with an A and an L in it.
11:46So there's some kind of nice ways to to do that. Um, yeah. Okay. Okay. So then when I pressed alt full stop it did work this time. So maybe last time it was a bit not sure about what I wanted to say. Uh I think that's all I wanted to say about modes.
12:02Am I missing anything?
12:04I think that's good. So we might use a fair bit more concise mode today. Um but it'll still be the same style, but it'll be I think more Jeremy teaching us versus Jeremy showing how to learn.
12:16Yeah, we could do that. Yeah. Um I also not sure we've talked about this button enable versioning. Do you know? I don't think so.
12:28Um I don't think so. Maybe in the so features video if I hit this button. Yeah. So there you know remember we have a a features video which is pinned. Um um Scott in the chat says we have talked about versioning.
12:45Okay, only mentioned briefly. Okay, we'll just mention a bit more. Um, so when I clicked that button, um, for those of you who have done some, um, software engineering before, um, you might guess what just happened. It added, um, what's called a git repo. And so you can see here, it's created a git repo, and it's created a branch, which we actually give it a random name. And
13:10nothing's in that branch yet. Um when you're then working along, you can hit um s at any time and what s will do is it saves your work. Um what it actually does is it um commits it to GitHub. Um so if I just hit sit to git. Sorry, that's a really good point. We should talk about that. So you'll see here it says, "Oh, there's
13:38nothing to commit." And so I could see what's happened exactly. It's like, okay, it's made a commit. Um, so what's doing is it's versioning my work. Um, and so I might make a few changes. Um, and then I'll hit S again.
14:01And so now if I say log, it's now got multiple commits. Now they don't have names. The idea being these are just things you could like uh if you haven't used git before just have solve it help you if you're like oh I've messed everything up I want to go back to that earlier version you can have um solve it show you um you know
14:32and you could even like add little bits before it if you wanted to Um, oops, I pressed S instead of A to kind of help it get a bit of a sense of where what you're up to. Um,
15:01yeah. So, that's one way. and we're going to add more user interface features so that you don't have to have AI do everything for you. Um, that's great. It's like, okay, great. So, if I did that, that should mean that then it's going to take me back to the one I had previously. Um, so I could just hit W and I could run that. Um, and then you'll see there's a button here called checkpoint.
15:26Um, and it asks you to pop a info in there. And now if I go status, you'll see I'm actually on a different branch. It's now called coral pulse starts rather than admiring cipher begins. And so what happened there is it actually um actually what I should do easiest would be to show the whole lot.
16:05What actually happened there is it um created a it it squished all of these unnamed commits up together into one and it created a single commit on um a special branch which is called main. And so if we look to that you'll see here there it is right. Um, so this is like if you're quite a new coder and you haven't really used Kit before, like
16:33don't worry about any of these details.
16:35Basically, all you have to know is hit S to save a version that you can always go back to later if you ever make a mistake. Um, and if you want to kind of create a named version, then hit checkpoint and then have the AI help you go back to prior versions and stuff like that. If you are a more sophisticated git user, then you'll probably recognize this as a really common pattern, highly recommended pattern amongst git experts, which is always develop on a branch and from time to time squash your changes
17:04and give them a name. So we've managed to get that down to a single button, which I'm quite pleased with. Um, so uh, so there's, um, so that the the the git repo I just created is in this folder here. So if I go back to my parent folder, that's not versioned. Okay. So that versioning refers to this folder and everything beneath it.
17:31Um so none of this needs to be connected up to GitHub or anything, right? It's all happening. So actually a lot of people don't realize this, but when um Lennin Tvoldz created Git, obviously it's a long time before GitHub existing.
17:48It wasn't designed to have a server. It was designed to be something where you just work locally, create versions of things, and send other people in a distributed way your changes. Um, so we're using it in that more classic way.
18:03Um, and anybody who's more advanced and is on GitHub and syncing repos and stuff, you can totally do that too, of course. But just to be clear, I would recommend all of your folders just click that enable versioning button and hit S from time to time because that way you're saving a history of your changes to that folder and you don't have to think about anything.
18:29Um, yeah. Anything I should mention there, Jono? It's a big topic kit, but hopefully [laughter] this is just enough for people to like not lose their work.
18:39Yeah, and I think like this is still a newish thing that we've added. There'll be at some point nicer ways to see the history and go back to previous checkpoints and previous versions. But um yeah, it's it's nice especially if you like some of the projects that we work with already have a git repository that we're all syncing back to something like GitHub and so then it's you might as well just do that manually the way you always have. But if you've never used that before, the idea I mean we even had this for for our legal team was saying like I really need it roll back changes occasionally when something
19:08catastrophic happens and I edit some clause you know so it's a very nice sort of minimal baseline for having some history and to answer a question from the chat on the file um after you close your dialogue stop your instance to anything all of that history is still maintained so it's all being saved to your to your volume to your hard disk that lives within your your virtual um Linux instance.
19:33Um yeah, great. Um so time permitting, we might talk more about versioning um later. Um certainly otherwise we'll be we'll probably be doing like a startup engineering course next year and probably go quite deep into it then.
19:51So, today we're going to do something very straightforward, which is we're just going to write solve it in solve it. So, um, let's go ahead and do that, shall we, J? [laughter] This might this might be a two lesson uh endeavor.
20:09Oh, come on. I was thinking Sorry if I might be a little bit too little faith.
20:13We could maybe this could be one of the one of three things we do today. After this we'll write Google Docs and then after that we'll write Gmail.
20:27Um so um yeah um Jonno showed a very rapid like hey here's me creating um a pretty sophisticated um um LLM eval um or multimodal model eval in lesson one which you called SVG arena um and that was kind of a high level rapid drive through of kind of putting together something like that in this
20:55dynamic environment So, we're going to slow down a bit now and try to do more of a like um how to do web programming. Um we'll go quite a bit too quickly for someone who's never done any web programming before and quite a bit too slowly for somebody who does web programming all the time. Um but actually really the thing here we want to show is uh how you can take this lesson dialogue and then
21:24at your own pace go way faster or way slower. So we'll share Jonno's created a annotated version um of something similar to what hopefully I will create dynamically today um which we will share with you afterwards. Um, so yeah. Um, and actually what I might do is I'm just going to grab a bunch of imports to start with, which I've already got. Um,
21:53just to save myself some time. Um, I'm just going to close my door because there's something noisy outside. Excuse me.
22:07So the high level goal here is um I think some someone already attempted something like this. Um we were discussing back and forth. Oh, we'd like to show more of this web application development. You know, something where you have some dynamic user interface that's changing and you're building different components for it, some different styling, but also adding these bits of interactivity. Um so we're trying to think of something more interesting than a to-do list. And then at some point Jeremy said, "Hey, why don't we show like something like solve
22:36it?" where you can execute code, you can submit messages for a language model to answer and you can have the same kind of like dialogue engineering interface um but starting a little bit simpler and building up. So yeah, that's kind of the uh the goal for the the day. Um okay, sorry about that. Um good time for our um neighbor to start mowing their lawn. Mhm.
23:02Um, okay. So, yeah. So, the idea is to kind of create something that that we can build up to do a couple of the key things that solve it does. So, one would be to uh let us run some calculations and get the results back in a persistent interpreter. And another would be to send some AI prompts. Um, we'll see how we go. Um, and as Jonno said, it might take more than one lesson to finish
23:29writing solit. Um, and I'm going to intentionally try to do things in a way which um is using less conveniences we have built already because just like we wanted to show you like how to use reax, how to use sets, how to use map and filter, you know, we want to kind of try to show you some lower level foundational technologies for those who you aren't familiar with it. Um so what I'm going
23:55to do is uh use a different um kind of styling system which doesn't have a fast HTML wrapper. Um and by using it you'll see how I go about the process of designing libraries. Um, and so specifically I find generally I prefer to use what's
24:23called the CDN version of of libraries I use. So that's the basically a version you don't have to do anything other than copy and paste a couple of lines. So we're going to use this thing called Daisy. Um, and uh, Daisy is a very nice um, uh, system for creating websites.
24:42Um, and they've got various ready to go templates that you can use and then it cost like 30 bucks or whatever. Uh, although they're built-in templates pretty okay as well. Um, so yeah, we quite like it. Um, and so it's given us a couple of lines of HTML. Um, so rather than using HTML, we generally prefer to use um, fast HTML which is the Python dialect of HTML. it maps one to one and
25:10so to convert between dialects dialects you can do HTML to fast HTML or actually it's fast tags um so if we paste in uh the URL there um then we can um grab the last HTML version but it's the same thing right link link href equals hf equals rail stylesheet type CSS
25:38Cool. So, um, this is how one uses the Daisy UI framework. So, we're just using what it says in their introduction. So, those are some headers we have to add to every page in our application to have it work. So, we could go ahead and say we'd like to use those headers, please.
26:02Um, you might need a comma there. do you think?
26:07[laughter] [gasps] Yeah, that reminds me actually. It's um this is not really HTML. It's two separate pieces. So if we made it a div, that would actually give us the comma for us. So that's probably a better way to do it. Um if you want to, we could also have styles um by adding this one as well. Um so um
26:34to create a fast HTML application um you you just say so you say I want a fast HTML application and when you do that you say which headers should be included in every page just by passing them in. Um, as J said, we could switch to concise mode today. Um, and that way I wouldn't have to keep pressing uh option full stop. Um, so much someone in the chat asked why aren't we using
27:03Monster UI? So, Monster UI is a styling library that someone at Answer AI developed and that we've been using for example to style solve it. Um, but partly we wanted to show that there's other options, right? We're still exploring the space of how one builds nicel looking things on the web. And also a big motivation for this lesson was Jeremy showing people how one might build something like Monster UI, right?
27:24Some piece of reusable library or code or components that others can then build on. And so by starting from a closer to a clean slate to say what is it like to do things with Daisy UI, which neither of us have really worked with before, um, we can then start to build up the pieces that make it nicer and nicer and more and more like Monster UI. Um, I added a new thing to dialogue helper called get preview, but I don't think I actually remember to release it. So, um, by the time hopefully you run this, this you won't have to define this thing
27:52called get preview. Um, but, uh, might also be interesting to see how we define it. Um, but basically, and I'd probably rather not type preview all the time. I just say P. Um, so it's uh we have a way to basically preview what your application is going to look like and so you need to it creates a new function and this function p is a function that will preview that application.
28:21Um so let's maybe take a look at that. So if we want to create a um um a fast HTML component which is a maybe it's a P tag that says um hello world. Um that's not bad. Um, print. See?
28:57Um, so to take a little bit of a step back, the every web page you see is built out of these HTML tags with styles applied, right? So like a P is a paragraph, there's H for heading and A for anchor tag or link. um there's buttons and inputs and so on um and they can have different styles and so we're going to try and build up some visual UI from these pieces but instead of writing out those HTML strings we have the fast tags
29:27thing like this capital P is a function that takes the children and some classes and some other arguments and then we can now preview what it looks like with the Daisy UI headers and things included with our application and so this is going to give us the way to like slowly build up um yeah the pieces of our of application.
29:46And I have HTML here. I forgot to mention that.
29:50And first HTML.jupiter defines that HTMX function which you don't have to worry about what's going on behind the scenes there.
29:56Yeah, I think that's going to be done automatically for us by dialog helper by the time you get this video. Um okay. Yes. So um here um in this case uh we created a paragraph and uh uh classes define basically sets of mainly visual behavior. Um and this particular so there's kind of a it's not a a standard but nearly everybody nowadays uses a particular way of um
30:29styling things which is called tailwind. Um and uh tailwind is um basically a set of these classes that give things certain looks and behaviors. Um so here this says I want to style this as triply big text.
30:52Um and so it's such a common way to write things that you probably noticed as soon as I started typing P the ghost text assumed that I wanted to put in some tailwind. like it's kind of yeah it's just what everybody tends to use nowadays. It's you don't have to um you can use um traditional style tags or traditional CSS styles although um I do find most things are a little uh more concise and easier to do with Tailwind.
31:20So I almost never use plain CSS styles. We do a tiny bit. Um you can always look at our styles in fact if you open up your web your dev tools and you can see our styles.css. Um, so this is how we can create a bunch of HTML as a Python object and we can print it.
31:46Um, or we can preview it. Um, so where it gets um a bit more interesting would be if we try using daisy. Um, what would be a fun daisy one to do?
32:06Little accordion maybe. Um, so we could here's an example of an accordion.
32:12You just click on things or with an arrow icon. So, if we grab that HTML and copied it into here and we could uh let's do that trick again, shall we?
32:35Pop that all in a div. Okay, let's see if that works. Uh, so we could create a new component here, which is all that.
32:59So you can kind of see how um you can quite quickly put together nice looking UIs um just by putting together stuff from a existing framework. Um so I might just close that up a bit. Um, so let's talk a bit about like what this looks like. It's um, actually let's take a look at a simple example. So let's make a button.
33:38Uh, so here's an example of a daisy button. Here's the HTML for it. Right?
33:44And just to give you a sense, rather than using uh, a H2F, I will just manually do it here. C equals uh so you replace the tag name with a function with a capital letter but um because class is a keyword in Python you're not allowed to use it so we just get rid of it and call it cls and then that's going to become the first parameter
34:14um and then this I'm going to go back into learning mode. I don't like it. Keep on popping this up for me.
34:22Um, and so then the children actually go first. They become positional parameters. And then rather than that, you just say close bracket.
34:38It's just called P, right?
34:40Did I do something wrong?
34:42Uh, your your preview is just called P.
34:44It is called P. Thanks. Okay, got a button. Um, there's something weird going on here, which is we said it's button and then we said the class is button. Just like seems to be repeating ourselves. Um, and indeed we are. Um, and I'll say I'm not thrilled with this way that the world has decided to do things, but it has.
35:12This is the way the world's decided to do things. Basically, all things are done this way. Um, a lot of people will claim there's all kinds of reasons it has to be done this way, but actually I've built things in other ways and it definitely doesn't have to be done this way. Um, but I think it's kind of sometimes just easier to go along with like everybody does it this way. And I'll show you how we can actually make this totally convenient anyway. So, it's not going to bother you at all. Um, but to kind of give you a
35:40sense, we created this um accordion before, right? This is called an accordion component. And there isn't a an accordion tag in HTML, so this can't say accordion. You can actually make up your own tag names, particularly if you got a hyphen, that's officially fine. So you could have said like daisy- accordion.
36:00Um, but instead, um, the way that Daisy does it is by using these collapse, collapse, arrow, etc. classes, right? So you can use a class for everything. So this is at least it's nice. It's a style where you can do everything the same way, which is a convenience. Um, but yeah, so I just wanted to mention that's something that you're going to see all the time.
36:27Um, and we want to um create something that's going to be using buttons. Uh, and I don't actually want to type this every time. So I would be entire at this point, you know, already I'm going to be making stuff with buttons and I don't want to type this every time. So I'm just going to go ahead and define a new function called button. And so the nice thing is in Python, soon as you define a function that already exists, it just replaces the one that was there. So
36:54we're going to be passing in um some children um you know to the button. I mean generally it's going to be just one, which is the text in the button. And we're going to be uh also passing in um uh potentially some uh additional classes um uh to use. Um um and so we're going to be returning.
37:19Okay, so we want to return the original button component, not this new one. Um so that's actually why I imported fast html.components here. Um, basically we can use fc dot anything at all and it's going to instantly create for us even if it didn't exist before um a a component with that name. Um, so it's going to take in uh the
37:45children. It's going to need the class and but we're going to save ourselves some time by putting button first and then our class.
37:56Uh, and then it's always nice to be able to customize things any way we want. So, we can say can pass some additional keyword arguments. Again, if you haven't done this before, have solve it explain to you what star and star mean in these situations cuz they're like super super convenient. Um, but yeah, now we can not have to worry about typing that every time. Get rid of class equals button.
38:25There we go. Nice. It still looks like a button.
38:28It does. And yeah, it still behaves like a button. So that was fast HT. We would import fast HDL components as FC. Maybe FC is a bad name because often people call fast core FC. So you could call it FH.
38:44Jeremy, there was a more general question about these imports. Someone saying, "Oh, would Solit know that we needed these particular imports for web?" I guess my answer would be we're developing in fast HTML and this is probably what you want to start with.
38:57You'd probably start from this example rather than from scratch if you'd never done this before. Um or you could check out the fast HTML documentation which is going to have demos that include similar imports or some subset of them. But these are the pieces that Jeremy knew was going to come up today.
39:11Yeah. In fact, for the, you know, and for the bit you would be deploying, you wouldn't need the Jupiter bit. So, if you wanted it to be a bit cleaner, you might split that out. Um, but yeah, pretty much anything that you want to deploy, you'll probably want at least these two. Um, and then anything where you're going to customize the components, you probably want this one.
39:32Um, yeah, let's say FH. Maybe it is cleaner fast HTML. So, that'll be our fast HTML button.
39:44Um, something else I just want to mention that's come up during the week. One person did ask like they feel like things get really confusing in any of this kind of dynamic ripple environment like solve it or like Jupyter notebook or like Jupyter lab or whatever because you can run anything in any order and so like the AI could get confused because you might have run something beneath the
40:13thing the AI is currently looking at or you can get confused because you can't remember what you've run yet. Um, and so yeah, this is definitely one of those things where it's just like, yeah, that's not a great idea. It does get confusing, so don't do it. Um, and so we make it really easy to don't do it, which is we we have buttons and keyboard shortcuts here. This is our restart button, which is shift R, and we also have our run up to here button. So I
40:40quite often I'll say shift R. Um, and you'll see it's finished restarting when these times disappear. There we go. And then to run everything up to here, I'll press, let's say, to go to here. I'll say shift A. Um, and so you can see they've all run.
40:59This one hasn't. Um, so I I use the kind of out of order execution only very small amounts. you know, maybe I've got a couple of different messages. I want to try them both and I kind of try one then the other and go back, but I'm restarting running from top pretty regularly. Otherwise, yeah, it gets way too confusing.
41:25Um, okay. So shall we create a route now that displays a button, [clears throat] right? Like we're making this HTML. How do I share it with the world? What is the RT thing that there's a couple of questions related to that? So that's perfect.
41:46So uh I want to create a web page and I want that web page to display this button and I want people other than me right here to be able to display it. So to do that you create something called a route. Um, so a route for example in in this URL for solv
42:10parameters. So this is the thing I want to create a route. Okay, so my route is going to be called show button. So a function in fast HTML is a route.
42:25Um, but to say you want to make it a route, you just have to write at RT above it. So that's what this RT here was. Normally you'd have to write at app.oute, which I'm too lazy to type that, so I just map it to the same thing. So now I just create a function and you just return what you want to return. I want to return the button.
42:45Okay. Or maybe I'll just go ahead and copy its definition if I want to. Um, actually, it' be more fun just to return the button. I'm just going to return the button.
42:54[snorts] Um and then the other thing we need to do is we need to run a web server. Um so uh it's very easy to run a web server. You can create a web server object. Um and we've got a special web server that runs in an either Jupiter or solvit environment. We've made it compatible with both thanks to Jono. Um um which is called um GPU.
43:23Um, so it to say I want to create a web server that's running my application, my fast HTML application. You just do that and that'll go ahead and start your web server. And uh, by default um, as you can see, it's going to run it on port 8000.
43:40Um, so we've now got uh, ah, now this is very helpful to see. Um, I've already got something running on port 8000, so I can't run it again. So that must mean if I um go into my dialogue list um there must be something already running and there is. So I'll shut it down and then go back into my right solver.
44:07And because I know everything always runs from the top, I can just hit R or the run all button and it'll go ahead and run everything. Um so this time it worked. Um cool. So, how do I see my application running? Um, and uh the answer is that you can go into your solve it dashboard and hit the copy public URL button on the on your instance. Um, and then you can paste it here.
44:43Um, and that won't work because I didn't say the name of my route. Show button. Okay. So then I'll add slash show button and there's my program. It's running. Now I said before if you're a web programmer you'll have noticed this weirdness. I said before this is running on port 8000. Um so what we actually do is we map your public URL to port 8000.
45:11Um, so this way, um, any of you right now watching can go to determine show descends 6v5 blah blah blah. And I'm actually using our special internal instance just to make sure nothing breaks. Um, uh, rather than solve it.
45:26Um, but yeah, you'll be able to see a running program there. And this is publicly available. So we have a number of um production public apps at at uh our company which are literally just running inside. Um, and one of the really fun things about this, um, is I can redefine C
46:00and I don't have to restart anything. I don't have to do anything. You know, this is a live application. So, back over here, it's already updated, right? Um, so that's the basic idea. Now, rather than popping back and forth to a different tab, um, we also make it, this might sound quite surprising, but we actually also make it so that this route is also available in your private instance as
46:28well. So, in fact, if I typed here show button, it also worked. So, um, hey, what happened to my back button? I must have accidentally pressed shift or something when I did it. Okay. Um, that would have been clever actually if I did it intentionally. Um, and so the reason that's helpful is because that means you can always refer relatively to
46:56um slashshow button and and it will work. Um, so we'll see in a moment why that's super handy.
47:06Um, Jonno, what do you think in terms of anything to add or talk about before we try to make our button do something?
47:15Yeah, this looks good. Um, if I wanted to preview that route without opening it in a new tab, is that easy enough to do?
47:22Sure. Yeah. So, um, absolutely. So you can um I'm going to rename this function I think but for now it's called HTMX but it's nothing to do with HTMX. We might rename this to preview. Um you can um preview a um actually I think we could even use your your your P function should work.
47:48I was just thinking I think so. Yeah, you're right. My P function should work right because yeah so actually get preview should work. So even though we said use app, if I pass it a string, then it's going to preview that route. Yes, you're right. So if we said slash show button. Yeah, thank you Jonno. That also works.
48:15So if we look at this, you get used to using dev tools, right? Get used to it using inspect to see what just happened. So, we just created a button. Um, and the way that we do these previews is we actually basically embed an entire copy of that web page using this iframe. That's what's happening behind the scenes if you're wondering.
48:36And it source is slashshow button and slashshow button means in our current proto in our current host. Um, so that's why that all works. Um, cool. So to sort of recap what we've seen, web pages are made up of these HTML tags. We've seen a way to create them, including sticking multiple together using these fast tags like capital P or capital B. You've made this new new version of button that adds a class name so that our Daisy styling
49:05works. We've got an application and it's got the Daisy and Tailwind scripts and links and so on included in the headers which is just part of the HTML that's included with every page. Um, and then we can preview what those components or those pages look like. And now we've just added a route that says when someone goes to this particular URL, your URL/show button, they get back the HTML that we produce from this um route here and that's rendered in a page
49:35so they can see it with all the styling and so on. So we have the pieces that we need to show user interface to anyone who wants to visit our application.
49:44Thank you. That's a great wrap-up. Okay.
49:46So, ideally we'd want the button to do something. Um, so, oh, one thing to look out for which just happened to me because these this button is actually inside its own whole document called an iframe. Um, none of my keyboard shortcuts work when this is focused. If I try to hit B now, nothing happens, right? So I just need to click anywhere else basically so that the frame's not focused. And now hitting B
50:18does work. Um so let's do um adding interactivity. So, um um yeah, and sorry, some people in the chat are asking like this is slightly different to how they're used to if they're web programmers. Normally, they're used to looking something more like that. And then you could call this anything you like.
50:56That works too, right? But you know why do we do it that way? [laughter] This has all the same information. So we try to not have you have to tell the computer stuff it can figure out for itself. So um
51:17all right. So um adding interactivity. So let's write our a new route. Um, and this needs uh we're going to have a button. Um, but we're also going to have a place that when you click the button, something gets displayed.
51:46Um, so we're going to so to create kind of a package of multiple components in HTML, you use something called a div. A div is just literally a an invisible container for other things. And so we can make a list of our other things. So we're going to have a button um
52:12and we'll have uh a place to store the result. So a place again just a generic place to store a result. You could use a div or you could use a pretty similar actually. So, a paragraph. Um, but it's going to need a name um to know like where do we want to put it. So, the way we tend to name things in HTML is use something called ID. Um, so we'll call this the destination for what happens when we click our button.
52:39Um, there we go. And so if we take a look at that um there it is. Um we don't even need the the route around it. So again, why tell computers things they don't know? This computer knows perfectly well what route this is. So I can just write that on its own. Um so it looks very similar to before. Um but um you know if we inspect it, we'll see we've got our div containing our button.
53:25Um so now we want something to happen when we click the button. So the way um we do that so we use something called um HTMX. Um, and so HTMX is um, it it's actually being proposed as a standard, a new standard that'll be built into your browser hopefully in the future. Um, but for now you have to add it, which you just add another um, script header. Uh, we already have the script header in um,
53:53solving that you want to appear when you click the button. So, I'm going to create a route. Um, let's call this the button result. And I'm going to return, hi Jonno. Okay, that's my route. So, obviously, we could um view that as well. So, again, we could we could do it over here.
54:27Okay. And so, um, that's our hydrogen.
54:32Um, so how do we say what happens?
54:36Instead of, yeah, go on.
54:38Instead of me manually going to that address, we want the button to somehow go to that address and then do something with it.
54:43Yeah. So, we want to say we want to tell HTMX when I click on this button, go to this address, call it, get the result, and put it in here. Okay. So this is basically very much built on the way the web is designed at its foundations. It's it's based on HTML and HTTP. So to be more precise, we're saying please make an HTTP request and update our DOM with the result. Um so that's the more kind of formal way to
55:13describe this. Um so htmx was written by a professor who has basically studied academically the nature of hyperdia and realized this is kind of fundamentally the foundation of kind of how the web should behave. So with this very small number of pieces you can basically create anything that you can think of.
55:33So to say we want to go and get some information we use hx that's the pre prefix for all things in htmx. we say get something and to say where should we get it from we can write the name of the function and that's actually just right sorry we want button result because we want to go and get that button result thank you button result [laughter] um and that's actually just short for kind of as we've already seen putting a string they do the same thing okay but again
56:02why write something that takes more characters um and then okay what happens we go we go there we get that information. What happens to the result? Well, we just say where we want to put it. And to use that, you use the target. So, the target is this paragraph here. And so, to say a paragraph with a particular ID in um in HTML, you have to use a special character, which is hash.
56:29So, we're skipping over a lot of stuff here, which any web programmer knows like the back of their hand. And anyone who's not a web programmer, it's going to look really obscure. So this is where you can ask for more help from solv. Um so if I now um click this button, it should make a request to this route get hydrono and put the result into this paragraph.
57:00And indeed it did. Cool. Then if you're watching this and you're brand new to this, like I'd say now is a good time to kind of pause and appreciate what's happening because there's a lot that just came up in this demo. We've got two different routes. We've got a button and when we click it, it triggers a request.
57:16Maybe Jeremy, you can show like the network tab so that you can see the request going back and forth.
57:20Um, so yeah, spend some time use a different target. See what happens when you don't specify the target.
57:26Try asking solvent to explain what is this get piece, you know, or or open the page in a new tab and and look at it there. Just spend a bit of time appreciating what's happening and then realizing like this is a piece of building block that we can use to do all sorts of things. When you click this button, something else happens on the page. That can extend to when you submit a prompt, the language models response appears, right? Or when I click sign up, I get signed into the platform. It's the foundation of all of the interactivity that we'll see in our web application.
57:56Yeah, let's take a look at it. So, as Jono mentioned, the dev tools network tab is great. So, I've I've to make this more clear, I've opened it up into its own without that that public URL into its own tab here. So, if I hit F12 if you use Chrome, um it will bring up the dev tools and it's actually defaulted to the network tab. Um and so now anything I do, any network thing that's happened, um is going to appear at the bottom. So if I click this, watch what happens. Oh,
58:24it made a call to button res, which if you remember was exactly what we asked it to do. We said when you click it, make a call to button res.
58:34And what happened? Well, it called this host /buttonres. It did a get and then in return it got hydrono. And then because we said to HTMX, please put the result into the destination paragraph, that's exactly what happened. Okay. So if I hit command R, you can see all our Daisy UI stuff and you can see HTMX and
59:00fast HTML all coming in here. Um, but once that's done, the that's the only other request is to say, "Hi, Jono."
59:13So it's Yeah, it's one of these things where the kind of surface area is is is tiny. It's like go get something from the network and put it somewhere. But the power that gives us allowed us to write all of solit. So you can write solve it and solve it because this is all we do nearly. We do a kind a tiny bit of JavaScript to support for example the Monaco editor that we use. And you know
59:43if you're interested in JavaScript you can we don't minimize or obfiscate any of it. So you can actually go into solve it click application and click on um maybe sources would be the easiest way.
59:58Sorry sources um I always do that I don't know why. And you can see here's my assets and for example selection mode. So the thing of when you press up and down and stuff like that it makes things happen. We can see. Oh, here it is. Right. J K L is to change the prompt. Cool. Arrow up and down. Select messages. Right. So, you know, there's not very much. What do we got there? 219 lines of JavaScript to make all that
1:00:26happen. Um, so yeah, that's how uh solve it's written. Um, so I guess I don't I like saying hi to Jono, but sometimes I might want to say hi to somebody else, like Rachel for instance. You might be like, "You always say Jono, I'm your wife. Say hi to me." So, um, sorry, Jonno, but you're going to be slightly less special. Um, and instead we're going to make something that can say hi to anybody.
1:00:58So we'll put in their name here and that's a string. So just like with um language model tools you have to put the type. You also have to do that for um web routes. You have to put the type. Fast HTML has to know what is this thing. So here I'm going to say return hi whoever Jonno Rachel I don't know right.
1:01:24Um, and you know, like I'm probably going to say Jono. Hi Jono a lot. I could make him the default. It's like no, I'm going to get in trouble. Just say hi to my wife first.
1:01:35So Rachel's now the default. And notice as soon as I do this, um, I don't have to again, no reload. I don't have to refresh. I don't have to do anything. As soon as I click, it's done. Right? This is the amazing thing about in a truly interactive environment like this. It's It's all connected all the time. Um, but yeah.
1:01:57All right. Now, I still also want to be able to say hi to Jonno. [snorts] So, I just go C and V to make a copy of this. Um, and uh what I want to do now is add a input box. Um, so how do I add an input box? Um, so I'll find down here we are data input input field. Um, text input. Yeah, that looks beautiful.
1:02:22Let's just do that. Okay. Input blah blah blah. Okay, that looks great. So, we could do that. Um, so I guess we'll take a look at one, shall we, John? See what it looks like.
1:02:50Yeah. Nice. Okay. And actually, interestingly to me, this function again, this is weird thing. It's an input class input. Okay. Such is life. I never want to have to think about that again. So, um, what I'll do is um,
1:03:13uh, sorry, it control Oh, control. I always forget that. control shift t is I'll go up to where I defined um uh oh I guess it's not where was it sorry functions button so let's go up here I'll hit C I'll press end I'll press V maybe swap these around and then we'll change this here to input
1:03:52Um, control shift V. And now I shouldn't ever have to type that again. So don't be typing stuff you don't need, you know, because it's overhead. It's to read, to maintain.
1:04:09So, uh, I want to use that now. So, we're going to add an input input.
1:04:21Um, I don't really need anything other than the placeholder, I guess, right?
1:04:29Placeholder equals type name. Um, and so again, just like you need an ID to say where to put something, in this case, this input, we need an ID to refer to it. Um, so I'll just call this name, input, or whatever.
1:04:55Um, great. So, you know, we could either pop back over here, um, or we could Yeah, do that. Um, and then when you're putting together inputs and buttons and stuff like this in HTML, you generally want to put them in something called a form. Um, so there's our form. Um so now um we need to somehow pass the name across to button res.
1:05:44Um so to do that you have there's basically two main ways. We only ever use two ways. There's there is more but you don't need them. Uh of doing stuff in um HTTP which is get and post. We could use get for this but generally speaking for sending information over it's easier to say post or more common to say post.
1:06:06Um and so what's going to happen here is it's going to pass along this input. And so actually we need to make sure the ID matches the parameter name. So I should change it there to NM. Okay. So this is just a a nice little pattern um that says like okay in in a form. Um and so now this post we actually wanted to be able to do things like press enter rather than just click.
1:06:37Right. So to make this all work together, all that has to be moved into the form. Um, and you can actually put the attributes at the top instead of the bottom if you prefer, which I often prefer to do.
1:06:53Uh but the idea here is that instead of just the button just triggering something by itself, we now want this whole form which could be like name, email, you know, preferred plan and then send all of that data at once. And the way that we separate those pieces of data are going to be based on the ID. So we said in this case when we send the name, we're going to give it the ID NM.
1:07:15And that's exactly what the um the route is expecting.
1:07:20So I'm not even going to click the button. I'm just going to press enter. Oh, there we are. And again, remember, we don't have to refresh, right? Um, like we don't have to like do any kind of reload. I guess we have to refresh this form because we've changed the definition of the form. Um, but if I go over here, same thing. Okay.
1:07:44Um, all right. Is that good time for a 7 minute break, J?
1:07:50Yeah, sounds good.
1:07:52Okay, see everybody at quarter past and put questions in the chat in the meantime. We can stew on them and um continue to work through.
1:07:59See you in seven minutes. And the video just scroll ahead because I'm not sure if we'll pause it.
1:15:14We're back. Um, so I imagine for most people watching this, um, even if they're experienced web developers, this [clears throat] likely looks quite different to how you develop web applications. Um this is a solve it style approach to developing web applications where we go in small
1:15:44steps and we look at each step as we go. Um this is how we actually develop this is how we actually developed solv um wrote it in Jupyter NB classic um so the original version of Jupyter notebooks and we um wrote some extensions to try and add some solvent like behavior to try to write solvent in a somewhat solitish environment um till we got to the point
1:16:16where solv worked on the whole better than Jupiter and now on the whole we write things in solv. But it's the basic idea is the same.
1:16:27It's like these small steps look at each piece and then when somebody else comes along and I check out Jono's padmo and I'm confused about how something works, I can see he's got each step there and I can view it and I can say like, "Oh, okay. I see how it works." Um, so that's kind of what we're trying to show here.
1:16:46Um, regardless of what level you're at with web programming, whether it be zero or hero, hopefully this style is um is interesting, you know, um, and hopefully gives you a sense of what we're talking about. We found it works very well. Um,
1:17:09and as Jenna said, you know, there's various points along this path where you might be like, not sure if I understood that or like, I have no idea what that was. And those are good places to kind of pause, ask solve it lots of questions, ask it to give you problems to solve. So, think about in lesson three how I showed how to do the homework.
1:17:31Um, if you're a a new web programmer, your homework here is going to be potentially many months. You've got to like learn the entirety of how the web works. And we'll have a whole course on that next year. Um, so you decide how deep you want to go. Um, and there's also quite a lot of um, little tricks for those of you that are more advanced that you can look at as well.
1:18:00Um but I guess yeah shall we create a simple code the code execution part now Jonno?
1:18:12Yeah that sounds good.
1:18:14So like zooming out our our overall goal here is to have some way to type in some input and then either execute that as code or send that to an LLM and display all of this in a nice visual way. Um so we've got different pieces that we could build. We've seen some of the foundations of the interface part. I guess we can quickly now fill in the back end that's able to not just say hi to whatever we send, but execute that as code. That sounds like a good next step.
1:18:42Oh, LM do shell. Wondering why my thing wasn't popping up. That's more like it. Um, so we've done this before. So maybe we'll just go ahead and try to remember. So we created a little execution function. So before we did, we created a shell.
1:19:05So if you've forgotten this, it was uh is this lesson two?
1:19:11Um, where we were creating a the world's most powerful LLM tool, which is an entirety of Python. [snorts] Um, and so we were able to do uh stuff like run cell
1:19:31and then um [snorts] um yeah. So then we create a little function where we could pass in some code um and we'd go result equals sh. Let's see if we can remember what we did. We went sh.run run cell and then we returned result if
1:20:02result it's not maybe else res do it out something like that uh one + one. Oh, that's certainly not going to work. Uh, and ex rent. Cool. Okay, so that's basically working.
1:20:33[snorts] Um, so same basic idea, I guess. Um, we're going to have a form. Um, and we're going to send this to uh exact code. Target desk. That sounds fine. Again, placeholder.
1:21:13Um, ID equals code button run code. Uh, so my destination test. Okay, that all sounds fine. So, call this run code. Um, so we said that the thing we're going to post to is called exec code. So that needs to be called exec code. Um, and we're going to be passing in code. And so we need to return um, ex code guess something like that. Mhm. Great.
1:22:00Um, so let's take a look. Run code one + one. Ah, we basically recreated solit. Look at us. [laughter] Yeah, that's done.
1:22:24Uh, wait. Now what happened?
1:22:41Something about this environment. This is working. We haven't had SH cause this problem before. something about doing this in this environment. Restart and run above.
1:22:59So, while you do that, Jeremy, there was a question about um we had this syntax where when we created a tag like form or div, you put all the children and then at the end you could also say class equals id equals and all of that. M but then here Jeremy has this format where he says form open brackets hx post etc. he does the attributes close brackets and then he does second open brackets does the children um different people have different preferences but this is the same as saying in that first set of brackets we're like
1:23:29calling form with just the named attributes that we want and then everything else that follows after that is going to be interpreted as being the children of that form as in other words things that are put into the form um and some people like that it's especially nice for not having extra lines at the end and then trying remember. Oh, right.
1:23:47That class right at the end belongs to this form that we started right at the top.
1:23:51We got an example here, Jonno.
1:23:54So, this is the accordion example again.
1:23:57Um, so you can see here we've got div child child child attributes. Those attributes belong to this div, right? Because these are all the positional parameters to the function div and these are the keyword parameters to the function div. So yeah, I can find I find this a bit confusing because this is just a long way away from the thing it's changing.
1:24:21Um so it works fine to do it this way and in fact this is the default but in um H2F you can change it to attributes first. And you can see now the parameters go the keyword parameters go first and then the positional parameters go afterwards. Um and yeah, anyone who's interested in deepening their Python knowledge, learn how this works under the hood, get solve it to teach you because uh it's quite interesting.
1:24:59After I restarted, this started running again.
1:25:08I don't know. I've never seen that before. Um, okay. Um, great. Jono, anything you think this is think this is basically done or can you think of anything we could do to improve our solit?
1:25:30So it would certainly be nice to have the input ready for the next piece of code and also to be able to see the history of the previous pieces of code we've run and the results um and start to think as well you know we wanted to have some language model chat as well.
1:25:45All right be nice if it looked pretty. Hey. Yay. Stop. All right. Okay. Fine. Let's do the um sticking it at the end. See your history. Okay. Um so to see a history rather than just putting the strings underneath, we probably want to create new paragraphs, right? So let's have this return a paragraph. Okay. So now exec code is going to return a paragraph.
1:26:10Um, and so then, and you see what I do is I tend to just redefine things lower down. Um, so you can kind of see how it builds up. Um, so since we're adding paragraphs, you can have a paragraph and a paragraph, but I think it's clearer now if we make this a div. Um, so that'll still work. Won't do it won't solve any of Jono's questions yet. But it still it works. And if you have a
1:26:39look at the what's happened here, it's put a paragraph inside the div. So Jono's demand was that sorry gentle request, Jono's gentle request was that instead of replacing each one, we should instead keep a history. So, [clears throat] um, check this out. This is actually the entire set of core attributes in HTMX. And also, I never use select, so it's actually everything else. This is also a bit of a special case.
1:27:25also a bit of a special case. So really 1 2 3 4 5 6 7 is the core. Um so one of them [clears throat] is uh hx swap. So you've noticed that um when I uh click the button or if I press enter the form um calls this route
1:27:53gets the results and places them inside the target. Um and the reason it did that is because this is called the swap and the swap by default is inner HTML. It replaces the contents of the div with the thing I returned.
1:28:14Um, I don't want to replace the contents or Jono doesn't want to. I think it's reasonable that he says that. Instead, I think, um, he wants to put them just after the start. So then each time I put a new thing in, it's going to insert the response before the ch first child of the target. So if I go after begin, this is called my swap strategy. Going to replace my swap strategy. So to do that, you type
1:28:41hx And you can see fast html kind of has this all ready to go. You can choose which one. So hx, there it is. hx swap.
1:28:53And I will use after to begin. So it's going to call this route and then place at the top of this thing whatever it gets back. Um, so 1 2 1 1 + 2.
1:29:16Are you happy, Jonno? Is that what you wanted?
1:29:19Yeah. Getting there.
1:29:20Okay. Okay. And that's all right. I remember. I remember. The second thing you wanted me to do was to clear this out after I'm done.
1:29:28Um, so there's a a a really nice way to do that. um uh using one of the other core attributes, common attributes, which is this one, hx swap o. Um actually, you know what we could do, Jonno? I could show you. Okay, I'm I'm going to show you a different way to do what we already have first, which is I'm going to put here Um, no, I'm not. I'm just going to show it.
1:30:08Okay. Um, so in order to clear out this input box, um, what I could do is just replace it, right? So here, um, I'm saying, uh, post to here and get the result and put it at the start of here. But what if I return two things? I return the result of the calculation to put here. And I also return a new copy of the input box which
1:30:38has been cleared out to put here to tell HTMX that some things in what you're returning shouldn't be put where the caller wants them, but instead be put somewhere else. You use the HX swap OO. OB stands for out of band. So watch this. So I can just copy this
1:31:04and I can just say here don't only return that paragraph but also return that input. Right now that is going to be less than great if I stop there because they're both going to be put at the start of my not this again. Is that the same as before? No. Oh, that's interesting.
1:31:39Okay. Um, so if I go one, you see the problem? It didn't just put the one at the end, but it also put the new input box. So, I don't want to put it at the end. This is all new strange things.
1:31:55Um, that's okay. It's probably because I'm doing this weird stuff. So what I want to do is to tell it I don't want to put it in the same place that the paragraph goes. I want to put it somewhere else. And so you can say hx swap o b equals and you can say outer html. I better know why my mom's calling. It's my birthday today. She wants to say happy birthday.
1:32:25Um but she's not watching this video clearly. Okay. So this says um don't put it where the caller asked to put it. Instead replace the outer HTML of the matching ID component.
1:32:43So if I now try that, do you see how the thing's been cleared out?
1:32:55Right. And again, I think Jonno's suggestion of looking at the network tab sounds good. So, I'm just going to do it over here to make it a bit more clean. So, I hit F12.
1:33:14So, if we have a look, we've got I've got two things. So there's two network calls and you can see it's returned the thing to replace the target with and an input to be swapped fully into wherever that was. Um okay so I think we've um do something more interesting. You could show that it's persistent, right? By times three.
1:33:52You could also show that it's persistent like define a variable and then look at it later.
1:33:59Um B equals a B * 3. Yeah, absolutely. Thank you, Jeremy. Call your mom. Okay. Thank you, chat. I'll call her after this if that's right. [laughter] Lots of good happy birthdays, too.
1:34:19Yeah, quite right.
1:34:21Um, fantastic. Okay, so in quite sure where that came from, right there.
1:34:33Is it possible that um sharing a URL where arbitrary people can run arbitrary code on your instance is maybe not a good idea?
1:34:42That's a good point. [laughter] In fact, server.stop stop might be uh expedient.
1:34:48Um [laughter] so that's great.
1:34:54Yes, [clears throat] good lesson folks.
1:34:55If you're opening up an arbitrary execution [laughter] on your device, then um uh yeah, good lesson for us all. Um okay, Jeremy. So um yeah, there's a few different directions we could go now, I guess. Um, we could talk about go back to the styling piece and continue to build up different pretty components and look at that.
1:35:21Um, so something else more interesting.
1:35:24Well, it just depends how you'd like to do it. We could um kind of cheat and bring up one we've prepared earlier or continue to build up.
1:35:30No, no, no, no. Come on. It's live coding here. Um, yeah. All right. No, you're right. I've I probably shouldn't open up my instance to anybody. So, um, let's replace this with something that does that. And we'll pretend that it's holding my code.
1:36:18So, if I now run that. There we go. Okay.
1:36:27A little bit safer.
1:36:34Um, okay. So, so we'd like to make it look a bit better. Um, and uh, yeah, I I generally like to just scroll through and kind of Well, one simple way to do this actually is to click on components. Most of these have something like this and you can
1:37:02kind of get a sense of what kind of components there are. Um, and it's like, oh, chat bubble.
1:37:12So, they've got some examples here of different chats. So, we could kind of do what we've done before. Um, but I'm possibly a bit biased here, but I um wrote a kind of uh informal standard um called LMS.ext.
1:37:36Oh my god, people are advertising on it now. How funny. Um which has become quite popular. And basically the standard is that if you put llm.ext text in your root, you will get information um necessary to help a language model solve problems for you. And uh increasingly people do this now. So Daisy UI has one.
1:38:00There we go. Um so the way to use llm's.ext is, you know, there's a number of ways to do it, but the easy way I reckon is just grab it and um pop it in a note. You could also ask solve it to read that URL, right? Because it has the read URL tool. But this way you can also look at it if you want. And yeah, exactly.
1:38:30Um, you can hit shift I to put it in a little scrollable area. Um, or since I'm not going to read it, I'm just going to hit I. Um, we might talk more about writing docs and stuff in the future because there's something fascinating that happens when you try to create your own LLM's text if you're doing it for your own product.
1:38:52Put your draft LLM's text in solve it and then start asking like a new customer to do stuff and if it hallucinates or gives wrong answers or whatever that tells you your docs, they're not even good enough for a language model, let alone for a human.
1:39:09Um, so this is actually a really great tip for how to create better documentation. And most of our documentation nowadays is written in this way where I tend to so fast HTML text I put it into my context and then I ask it lots of questions and any time it gives a bad answer that's my fault, not the language model's fault because it tells me my documentation is insufficient.
1:39:35Um, so here I might say um um I want to learn how to use Daisy UI chat bubbles uh in order to make my um little minimal execution web app look nicer. Could you show me a really concise, simple example of a chat involving asking a question and then getting an answer? And I guess the question should be on one side and the answer on the other.
1:40:14Um, so it should be pretty easy for it to do if the um LLM's any good. Um, if maybe I'll just switch into concise mode. It probably won't make much difference at this point because this is a long enough dialogue that it's probably just going to keep things in my style.
1:40:33All right. So, I hit W and uh yeah. So, you can see it's using my preferred um class first here, which is interesting. Although I wouldn't use class first for these ones. Um but anyway, just getting on the fussy side.
1:40:52Ah, nice. Cool. Um, so yeah. Um, could you wrap that up into a Tailwind container or something that makes it um not use the whole width of my screen?
1:41:12Um, so yeah, generally the way the most web styling works nowadays is things are kind of designed to go inside what we call a container. And so, [clears throat] uh, Tailwind provides a container and double XL means a double extra-l large container. So, I rather suspect that if we run this, it's huge, right? So, you know, you can start to remove some of the numbers or some of the X's. I think it might be
1:41:42like LG for large. Um, yeah. And so, this one's centered. MX auto makes it centered. I'm not even sure we particularly want it centered. So, we could start to um do that. Um Oh, that actually looks quite good.
1:42:03Yeah. Yeah, not bad. Um, so yes, I go on.
1:42:08I was going to say normally the your messages are on the right like the question and the responses on the left or am I speaking as a not how we do it in sol. We have our questions on the left and our answers tab on the right. I don't know.
1:42:23Okay. Yeah, that's how my brain works.
1:42:25[laughter] Maybe. Yeah, maybe just chat GPT and stuff. I can't even imagine which way around to close. [laughter] Little uh moment of brain piece. Okay. Um, so Jeremy, I have a question for you here. Um, before you didn't even like typing input class equals input, right? And you refactor that out straight away. And then here making a few different versions of the chat with the AI helping.
1:42:51Um, what what's the sort of thought process for how you're thinking about when to immediately refactor into something you like a little bit better? Are we going to do that next?
1:43:01Yeah. Well, this is something, you know, you've helped a lot inspire thinking around Jono. So, um, kind of channeling Jono's own thoughts here a little bit, but like let's let's take a look at like what it would look like to push a little bit further along in this in this mode. So, I kind of say like um so I might even hit command shift comma here um to let it see the output. Um, and then I might
1:43:30say like I think that's looking pretty good. What do you think? Um, let's also add a input box and a button at the bottom where we could type in our question and maybe add a second question and answer as well to kind of complete the mockup of what our application might look like. So I think there's a number of ways we could do this. You know, Jono, we we can definitely explore.
1:44:10Um and so here we could kind of keep exploring. Um it's like, yeah, I think that looks all right. like does this look good direction? Like yeah, I think this looks good direction.
1:44:30So like maybe this is this kind of like feel free to repeat yourself [laughter] um theory. Um particularly because we didn't even have to type this and so we're this is like um we don't tend to use stuff like Figma at Answer AI. Um, I'm not saying not something we never do, but we don't use it stuff like that very much at all because it's so easy to mock up stuff directly, right? And then
1:45:00we're like, yeah, that's looking pretty good actually. Um, so I'd be like, yeah, don't create abstractions you don't need. And like, yeah, I quite like this. So now I'd be inclined to create an abstraction. And so I'm like, well, we already have an input. We already have a button. And I'm like, oh, these are looking good.
1:45:22Now we got a chat. You know, earlier on we saw the accordion. There's a chat and a chat bubble. Um, so at this point, I'd be inclined to say like, okay, I I I like Daisy. It looks good. I'm going to use it for my for solve it for my solve it and solve it. So, um, why don't I go ahead and um create obstructions? And you think like, oh, why create obstructions? Because obviously the computer can doesn't need them.
1:45:51And actually, it does. At some point, it does. like if you um tried to have it create a 3D game and didn't give it access to 3JS or you tried to have it create a interactive uh animated mathematical explanation and didn't give it access to manium like it's not going to do a good job. it won't create anything any good. Like the the better the abstractions you give the AI, the better its results are going to
1:46:20be. Just like with a human, you know, if you even if you ask somebody very capable like Jono and said, Jono, please create, you know, an interactive three-dimensional flight simulator, um, PS, you're not allowed to use anything but C and no libraries. It would take him a while. Um um and um yeah, so this is this software engineering thing, you know, the the as
1:46:50you create the abstractions, you allow you combined with the AI to create more and more powerful artifacts that you can under that you and the AI can understand better and you keep building to create this like exponentially improving ability to do work, which I think we're starting to see at Answer AI. Like I feel like you know our people have noticed in the discord it's like how come how come you guys seem to be accelerating what what just happened? Did you hire more people?
1:47:19It's like no this is just because we do software engineering. So I I would be inclined to have a little think here and be like, okay, Daisy UI basically has this pattern where you have a tag and you have a a class that's kind of the main definition of that and then you have a number of things where that class followed by dash followed by some extra info is used to then define that thing.
1:47:45So um it's interesting I was chatting to John about it. I think it was just this morning how we would go about creating this kind of daisy component generator.
1:47:58We're like, well, we could have AI help or I could write it myself. And like I prototyped it myself then we prototyped it with AI and obviously actually not obviously it turned out it was actually much faster in my case to write it myself. Um so I'm inclined to write it myself here just because I want to show you some fun things. Um, so I want to create something called button, right? That works the way we've seen.
1:48:26Um, but it's totally fine to use AI for this too, right? Um, just whatever. So, I want to create my own thing called button and and I kind of want to define that it's going to work a bit like this.
1:48:37I'd say um, make a make a component function. That's what I call it. I call this a component function. It's going to be for a button and uh it's going to need the class button because that's how if you're a member. Don't click there. Click here. Um that's what it uses, right? So it's going to be button button. Um so it's going to work like that.
1:49:10Um, on the other hand, um, for a, let's just close that up by hitting O so I can see. Okay, we're going to have a chat component. I won't say chat because um, that might get us confused with the uh, Claudet chat. Um, but we might create something called like chat component or something. I don't know.
1:49:38And um that is going to be a yeah chat. Okay. So that's easy. Um but maybe more interestingly there's a chat bubble. We might just call that um ah but that is not chat here, right?
1:49:57That's a div. So we might have to have a third optional thing where we say what kind of thing is it? Right? Because in this case it uses a button. But in this case it's going to use a div. Um, yeah. So that's then going to be the same. Um, you know, and and so what you're doing here is you're writing how you would use the function that doesn't exist yet.
1:50:18Kind of like hopefully programming. I really wish what this would do is create a component called bubble that always has the class chatb and that builds on the existing div.
1:50:28So it's like you do something like this too, John, where you kind of like imagine like I wish I had something that worked like this, you know, and kind of sketch it out. Yeah. Yeah, for sure.
1:50:37I've always worked that way. If the AI uses a function that doesn't exist, it's like, oh, I guess it ought to there ought to be a function that's um Yeah, you know, yeah, we do that quite a lot, don't we?
1:50:47We we every time we see an LLM use a function that doesn't exist, and then we try to do it ourselves and we're like, oh, if the AI function did exist, it sure would be handy. We we tend to go back and be like, yeah, yeah, okay, let's let's instead write it that way.
1:51:01Um, okay. So, yeah. And uh somebody mentioned in the chat chat this is very much like TDD you know testdriven development but this is kind of test driven design. Um so um for that button then Jeremy like just to just to push on that in the in the second to last message there.
1:51:23Um you're not writing assert print you know button. You know open tag no button. You're not writing an assert for that. Right.
1:51:34You're looking and seeing though that looks like a button.
1:51:38That's your exactly. And so we do a bit of both that in our company code, right? We we sometimes we have asserts or in fast core we have a test equals test egg. Um um but you know quite a lot of our things are just like shows something on the screen and there'll be a markdown thing above it saying and as you can see this is a beautiful pink and purple gradient stripes that Jono likes. And then you can check is it beautiful pink and purple. I don't know if Jonno actually
1:52:06likes that but yeah. Um so then the person looking at it can be like yeah that looks very nice. Um yeah so if we want to have a function that creates a button um we we've actually briefly seen this before which is if you go a= 1 um that is actually syntax sugar for globals a
1:52:36equals 1. So just to prove it to you, I'm going to do that. A is actually syntax sugar for globals. A um so yeah, Python is like built on a very very small kind of base and then everything else falls out of that. It's it's as we kind of discussed before, it's it's a bit like a lisp like that. Um so we can uh create a button function by saying globals button.
1:53:18Oh, don't forget the parenthesis equals and we can do anything we like, right? We can we can give it a function. We we can say it's actually the same as the print function. So now we could say button I right. So um so that's kind of how we can assign it.
1:53:45Um so here's what we can do. Define make uh comp function. And isn't this cool?
1:53:52Because I defined how I wanted it to look. Um, ghost text is guessing what I mean, right? So, uh, this is actually the tag. Yeah, this is the name is fine. That's what we're going to call it. Plus, yeah, guess that's fine as well. Um, that's actually the tag that it needs to create.
1:54:20Um, and actually, it's not div by default. It's none by default, right?
1:54:26Cuz if you don't pass in a tag, then the tag is going to be the same as the name, right? So in the case of button, the tag is actually button, right? Um, so we're going to define the function that we want. Ah, again, it's guessed, right? So the function is going to take some children and it's going to take some um keywords.
1:54:56So, what's the, you know, so we need to now grab the actual um H. So, we've got something else that we haven't figured out. Um, we've got a a string like div and we need to we need to we need to change that to FC.D, right? Or we'll have a sorry FH FH. Um uh or you know if we have if we've got the tag equals name so that would be button fh.button.
1:55:28Um so uh how do you do that? Um again um uh from a string um solver it can teach you but it's uh another of these very small key underlying parts of Python which is called get atra get that attribute. So fh dobbutton is actually syntax sugar for get atra fh string button.
1:55:56So we can actually get our you know um our function the function we want to call um or kind of the component function we want to call by just doing that get atra uh from fh and we need to grab the tag that's correct thank you ghost text um yeah so the function that we end up with is one where we're going
1:56:24to return calling that component function um with these children um with this class.
1:56:37It hasn't quite got it correct, but it's on the right track. Nice try, ghost text and these keyword arguments. And again, this is quite advanced Python, right?
1:56:45So, it's it's fine. Um Oh, wow. Aren't you being clever here?
1:56:52We could even give it that name if we wanted to return that function. So this is a function that returns a function. Um actually we don't even want to return the function, right? We actually want to define it, right? So we actually this is where we're going to do this trick where we go globals square bracket and this is the name we want to give it. Yeah, exactly that.
1:57:16Thank you. Okay, so Jeremy, what if we want to pass some additional class? Yeah, exactly button.
1:57:23So, and so it's kind of going to say like let's start using it and then we're going to find that we get annoyed. Um, so but let's start here. Um, make our various things. See if it works. So, button um click. Hey there. Whatever. Fine. Um, that looks good. Make sure it looks correct.
1:57:58Nice. Yeah. So, this is where exactly where Jonno was heading. Um, no, don't have the daisy open anymore. Daisy.
1:58:19I don't want my buttons to always be gray. So, yeah, could be button primary. Probably got some examples of that here. Button sizes response. Here we are. Button colors primary. H. So one thing I could do then is say yeah this um this class is the kind of the special daisy class you know um or the kind of the special component class.
1:58:54Um so if we kind of do that and then yeah let's do that cuz then we can say that the function it returns let people define you know additional classes they want to add. Um yes exactly right ghost text it should default to nothing at all. Um,
1:59:18and so then the class that we pass in, let's see if we can figure it out. I'm guessing it real. Yeah, it's exactly that. It's both this uh component class, which would be button, and optionally any other class that they've passed in. Um, so we should now be able to say class equals button prime. Look, it's scared. Hey. Hey. [laughter] I'm So, this is how you know that you're um uh it's not called Wait, hang on.
1:59:52It's called Oh, I put it in the wrong place.
1:59:57To top. Anyway, this is how you know when you're predictable. There we go. We got a nice primary blue button. Um and like, well, why do I have to type button dash? It knows it's button dash.
2:00:12So, actually, why don't we also be able to pass in, let's call these extras. So, extras are the button dash bits, right? So, we're kind of defining our own little API here because we want to, you know, we don't want to do stuff ourselves. Um, so basically, I'm going to say like extra.split.
2:00:34So, I pass it in with spaces and I just want to put that button dash on the start of each of those, right? So I say extra equals join up together and again I would you know depending on your comfort with um Python you know create a message above this get it working you know and whatever but um this is I think this is pretty straightforward for me so I just say f
2:01:01and it's going to be the um um bit at the start which was the Pump class think here.
2:01:21And it's actually it doesn't need to be X the dash.
2:01:25Okay. And so now, you know, we can pop all this together. It's fine. There's going to be some extra spaces there, but no one cares. Um, and so now I should be able to say extra equals.
2:01:45Hey, nice, you know, but we can still add other classes. So in oopsy in Tailwind, you can add, for example, a margin around something by just saying m dash and then how much do you want? For instance, Okay. You see how it's got a little bit of spacing around there?
2:02:06Maybe we want a bit more padding as well. Padding. So, that's inside around outside the text, but inside the button. [snorts] Um, that's interesting. Maybe that's the default. There we go. We made it super squishy.
2:02:24Um, it's not bad. So, we could like um at this point, you know, I just say to it like um okay, I've added some um simple Oh, crap. [clears throat] [laughter] That's not a Oh, no. Hang on. But yeah, no, that's right. That's bubble. No, never mind. Okay. Added some simple um bubble button and chat C components. Um, use these to refactor your early earlier um simple mockup.
2:03:23Oh, haven't seen that before. Use these to refactor your earlier mockup, please. Well, it's not happy. Use these to ref your earlier mockup. Haven't tried this before. be interesting to see how it goes. I think I should be all right. Like this is one of these things that a year ago it probably wouldn't have got right.
2:04:05Yeah. See here's got extra equals primary. Um yeah. Um I don't like this. Um actually I think we should reorder this so that we use normal keyword parameters instead of putting the keyword parameters in that functional style that you've used here. Okay. So, my something's totally broken with uh all that. Um, let's just ignore it. Okay, so we've got our chat demo.
2:04:55Oh, nice. That seems like a good place to finish. But, um, you know, I guess Jonno this this is this is how I work. Like I'm not it's not the only way to work, but I I you know I like this idea of and I definitely do I definitely do this a lot as well. It's like play around and find something nice but then try to create a nice API and then redo the
2:05:24thing. Let the AI redo the thing because it's just a minor style transfer. I learned nothing by doing this myself, you know. Um and it's like, yeah, that's great. Now I've got something that I feel looks nice, but I also feel like, and we could refactor this a bit more. Maybe we'll do this start this next lesson to create like a Q&A component because we're repeatedly doing this start end pair, you know. Um, so we might refactor a
2:05:50little more, but we've definitely seen this at um, you know, at at at Answer AI that we have, you know, built. So, for example, our whole landing page was originally more kind of like get the AI just to write the whole thing. Um, and we didn't refactor it reasonably quickly and then everybody stopped contributing to the landing page because it was too
2:06:19complicated, you know, and there were some components in solver. They're a bit like that. And so then we went back and rewrote the landing page using a nice simple little system where we actually had external markdown files and we wrote it in that and then we could pull them in and now people, you know, contribute to the landing page all the time. So I think we've been through that process of realizing when we don't take the time to step back and refactor things, we end up with
2:06:48something that none of us feel very comfortable working with. On the other hand, when we do refactor things, we get something very nice. And so I think at the end of this process, I'm hoping we're going to have an FH Daisy library we can give to the world and we can use for ourselves. Um, and that'll be that'll be nice. And there's there's a number of pieces there in what you did Jeremy that I wanted to highlight because so you could say that right we've just said look this refactoring is nice and and making libraries and
2:07:17abstractions that you can use is nice.
2:07:19You could have started out this project and said well I want to use Daisy UI so I should start by creating the FHUI library. M so [clears throat] then you look at button and you make a FHD button component right which does button with class equals button and then you set up something special for primary and secondary ones and then you do a FH Daisy input component right and then for your things like your chat bubble you just use the whole example from Daisy
2:07:47but you replace it with Python and fstrings um and you build it all there whereas what you did instead was like well let me start out with theirs like, okay, let me do it for just for button, just for input, some things that felt somewhat ergonomic and that you knew you could do, right? And maybe somebody else would know about globals and wrapping and so on, but you you made some tweaks that made it better for you.
2:08:11Um, and then you start to go, okay, I I can see I'm going to do this a lot, right? So, I've tried it out once or twice. It's the same thing as doing it on the first advent of code sample, right? I've done it once, I've done it twice. Then you go like, okay, I really would like something that does this for all of them. So you made your um make comp fn special piece of magic.
2:08:31Um and so then now the resulting if we end up with an FH daisy library is going to be very different to if you started out first by saying I want to do the abstraction.
2:08:41Um and so I just wanted to highlight that like that's that's the key with this kind of API design and library design is that a you're probably never going to get it right on the first time, right? we might write several different versions like, oh, I didn't like the wrapping function cuz it broke in this way, so I made a different thing instead.
2:08:57Um, but also you can try things and okay, I'm going to use this chat for my thing now. Let me try make something that works for that and build it up from usage or from even like that hypothetical, I wish there was something like this, right? Hypothetical usage. This is what I would like to see.
2:09:12Um, as opposed to trying to sit down and write the spec for the whole thing.
2:09:15Yeah. The a common phrase that I tell people that are new to answer AI is yagny. You ain't going to need it. Uh so often people when they start they're very keen to impress and please and kind of like oh we could do this and we could do this and then like what if somebody wanted this then we have like jaggy like like if if you don't have a need for it right now don't write it right. So yeah I think what you're saying is exactly
2:09:43right Jonno. So, like quite quickly people get used to this idea of being like, "Okay, I'll just do the work." All right, Jeremy said, "Can you make the landing page?" Okay, here's the landing page. And then it's like, "Cool. Um, now we want a course details page." I say, "All right, I'm going to need these things again.
2:10:07Let's pop that on a function." And now that's convenient. I I needed it right now. and I wished that function existed, so I made it exist. Um, so yeah, our our our none of our we have hundreds of libraries and none of them have anything that we don't use because they only exist because we first of all used a thing and then we pulled it out. And one of the things that's
2:10:33quite surprising, I think, is that um when you don't actually design, you still end up with a nice like API.
2:10:46You still end up with a nice API because what you do is when you pull the thing out, you're like, "Oh, we used this two or three times." Why is that? Oh, it's because Daisy has this pattern, you know? So cool, we'll call this the daisy component class or oh, it's because we regularly add prefixes to classes. So we'll create the prefix class thing. And so when you name it, then you're starting to design. And then
2:11:16you suddenly realize like, oh, these four things use the same parameters. Why is that? Oh, because there's this stateful thing. Cool. All right. Now we need to make it a class. Put the state in the class. Now they're methods. Now they delete all the parameters. Um and so and then you realize oh every time I import this class I also want this class. Oh yeah because we need them every time we do this kind of problem.
2:11:42Okay, that's now a module, right? And then it's like, okay, anybody else out there on the internet who needs this behavior, I've now provided this pip installable module that you can use. And you know, you named the module, you named the classes, you named the methods, you named the parameters, and the design fell out of you needing to get your work done. Um, yeah. And I find it's just delightful how that ends up
2:12:10with designs where um it just it feels good to use. Yeah. So, I think that's I think that's something that's worked consistently really well and it's very different to how most API design is taught. And um something I'm interested in exploring is pushing harder on now getting AI to help. So for example, once we've done this a few times with Daisy Jonno, I was thinking of just saying to solve it like, okay, here's the llm.ext,
2:12:44do the rest, you know, and at this point maybe it just needs to go mf funk, you know, and then we'll have them all uh or something. Um, but it'll be fun to see where I think um, FH Daisy UI ends up.
2:13:00Fantastic. Okay, thank you Jeremy. Well, I see we're just a little over two hours. Um, in terms of between now and the next lesson. So, next lesson we're going to continue. This is not a a single lesson theme. We're going to carry on with the web and with playing with our mini solve it. Um, but in the meantime, we'll share both a version of this notebook that we kind of practiced for with the lessons. So slightly different ordering but some annotations and maybe Jeremy you can also share the one that we've built up during the class just so that people can have the reference for the different ones. Um so
2:13:29if you're brand new to this maybe start at the top with just the um creating a route and creating a component and looking at it and then see if that hopefully that inspires all sorts of rabbit holes for uh what kinds of UI can I create, what kinds of applications can I make. Um we can yeah have some good discussion going on fast HTML and related things there. Um, if you're more interested in some of the deep Python internals, like how is globals working?
2:13:56Um, what is get atro like see if you can ask solver to teach you some of those pieces and forget about the web stuff. Um, we'll carry on with the process. But yeah, I think the main takeaway would be go explore the dialogue that we share. Um, see which parts spark for you. Like I'd like to dig into that part deeper.
2:14:13Um and then homework you know is um [clears throat] pick an pick a feature or two in solver it and implement it. So the obvious one would be to add a um a uh two buttons to choose between prompt and code and um prompt should uh ask language model um and code should ask Python and make give them slightly different styles so that
2:14:39the user can see which one is which. Um, and then yeah, if you get that done, find it easy enough and you want to go further, pick another solvent thing you like. So maybe clicking on a previous message edits it instead of always putting them at the bottom. Um, or add markdown notes. Yeah, have fun. Yeah.
2:15:06Thank you everybody.