Build An Audio AI App Transcripts
Chapter: Feature 1: Transcripts
Lecture: Adding AI Action Views

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now, we're going to need somewhere when we click this button for the API to call to or
0:08 HTMX to call into to say they've clicked the button to create a transcript and moreover which episode.
0:14 So we'll use this episode variable and episode ID and those types of things to pass that over and say create a transcript for this episode.
0:23 Now we could stick it in one of these views but I like to have everything kind of broken up and you know isolated.
0:27 So I'm going to create a new file called AI views. And in here, we're going to have two functions def start job. Now you might say start transcript.
0:44 But in fact, there's different kinds of jobs there summarize, there's transcribe, there's
0:49 chat, all these different things that we are going to be able to do. And it turns out to be exactly the same.
0:56 The way it works is just what is the action we pass off to this background subsystem that is in here.
1:02 So we're going to just have a start job and def check job status. Okay. Now we want to make these something that we can call from fast API.
1:16 Now a lot of times you'll see at app dot. How do you get app here? Well, it's over here. There it is. But we're going to need to import this library.
1:26 We can't give it that. So it's going to turn out to be a circular reference, which doesn't go well with Python. So fast API has a cool way to do that.
1:36 PyCharm is suggesting we do something with flask. Thanks. But how about we do this router equals fast API, API router like that.
1:47 And then this can stand in for. I do a get here and we'll put in slash URL. And let's put a check status for this one.
1:59 Now this is not enough information, but let's just make sure that's working well. We'll just return. Hello world. Just for a second.
2:10 And we want to make sure just that we're clicking everything together here in the app.
2:14 So what we're going to do is we're going to go down to this register or configure routes and we'll do another one of these.
2:20 And we'll say API or AI views. Import that at the top dot router. Now if we run it, we should be able to go over here and just say, what did I call it
2:38 again? Slash URL. Hello world. Okay. So we got this new view plugged in and everything's ready to go. these are not the URLs that we're going to need.
2:50 We'll put those in in a minute.


Talk Python's Mastodon Michael Kennedy's Mastodon