Build An Audio AI App Transcripts
Chapter: Feature 1: Transcripts
Lecture: Passing Data to AI Views

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well, /url looks fun, but kind of useless. What are we gonna put? Let me just paste this in 'cause there's kind of a lot going on here.
0:08 So we're gonna have /ai to represent our AI view here. Start, start some action. This is transcribe, summarize, whatever.
0:17 And so this is gonna be a string I'm gonna pass in here. And we're gonna have which podcast ID is this?
0:25 Is this talk Python, Python Bytes, Fresh Air, whatever. PyCharm is suggesting to auto-complete that perfectly, so I'll accept that.
0:33 And then episode number, and that's an int. Now, one thing we can do is we can actually, if you look here, we can go to a symbol. There's a job action.
0:45 There's the job action class over here. Where is this living? It lives in the database under jobs. And this is an enumeration that we can use.
0:52 You can see it's a string enumeration. Transcribe, summarize, and chat. And that restricts what strings can be passed in here
0:58 because FastAPI is awesome. I can actually go over here and say this is a required job action and import that, not just a string.
1:08 Okay, so let's just print out the things that are coming in here now. Here we go. Try it again. And I'm gonna need to copy this URL
1:18 'cause I won't remember it. So we wanna go up here and say, well, what goes in here? Let's put the action, we transcribe.
1:27 Podcast ID is gonna be Python-bytes episode ID. Let's put 344. Then transcribe Python bytes, 344, perfect. And what if we put something else in here
1:40 is like jump up, error. Input for that section of the URL must be either transcribe, summarize, or chat. You said jump up. Jump up is not one of those.
1:52 See how cool it is we're using that string enumeration and how cool FastAPI is. Okay, so yeah, that doesn't work, but this sort of thing right there,
2:00 that's exactly what we're looking for. So we've got this data being passed over. And while we're at it, let's just do the other one as well.
2:07 On this check status, instead of that, we're just gonna say check status for job ID. So what in practice this is gonna do
2:14 is you're gonna say we started your job. Here's the ID. You can ask later whenever you want. Just come back and ask using this endpoint
2:21 to see if it's done. And if it's done, we'll do one thing. If it's not done, we'll do another.


Talk Python's Mastodon Michael Kennedy's Mastodon