Latest / CyberSecurity Summary / OpenAI API Cookbook: Build intelligent applications including chatbots, virtual assistants, and content generators
Transcript
- 0:00Speaker 1: Okay, let's untack this. What if you could take the
- 0:02Speaker 1: raw power behind tools like chat GPT and mold it
- 0:07Speaker 1: to your exact needs. We're talking about going beyond just
- 0:10Speaker 1: you know, chatting with an AI to actually building intelligent
- 0:12Speaker 1: applications and specialized assistants.
- 0:14Speaker 2: Exactly Today, our deep dive is all about the open
- 0:18Speaker 2: Ai API, focusing on how it empowers well anyone really
- 0:23Speaker 2: to create custom AI solutions. Our main source for this
- 0:26Speaker 2: is Henry Habib's Open Ai API Cookbook, which Packed Publishing
- 0:30Speaker 2: put out in March twenty twenty four.
- 0:32Speaker 1: And Henry Habib he knows his stuff over a decade
- 0:34Speaker 1: and AI and productivity right, and he's a big believer
- 0:37Speaker 1: in this citizen developer idea that you don't need to
- 0:40Speaker 1: be like a hardcore coder to build amazing things. He's
- 0:43Speaker 1: also the guy behind the Intelligent Worker newsletter.
- 0:45Speaker 2: That's right, and Sam Mackay, the CEO of Enterprise DNA.
- 0:48Speaker 2: He actually calls the book an essential guide for knowledge
- 0:50Speaker 2: workers eager to harness the power of open AI and
- 0:53Speaker 2: chat GPT to build intelligent applications and solutions. High praise.
- 0:58Speaker 1: So your mission for this, a deep Dive listener, is simple,
- 1:01Speaker 1: get a shortcut really understand how to use the open AIAPI.
- 1:05Speaker 1: We're focusing on the practical stuff, those real aha moments.
- 1:09Speaker 1: You've heard of AI chat GPT. They're everywhere, constantly talked about.
- 1:13Speaker 1: But what's cool here is how actionable they are. We're
- 1:15Speaker 1: going to show you how to turn ideas into reality.
- 1:18Speaker 1: Let's start with the basics. Why the API matters. It's
- 1:21Speaker 1: more than just the chat box you see online. I mean,
- 1:24Speaker 1: chat GPT's growth was just insane, wasn't it. One hundred
- 1:27Speaker 1: million users in two months. That's faster than TikTok, which
- 1:30Speaker 1: took what nine months. It really brought natural language processing
- 1:34Speaker 1: NLPE to the masses.
- 1:35Speaker 2: Absolutely, and the API it takes that democratization way further.
- 1:39Speaker 2: It's a genuine paradigm shift. It means anyone can generate
- 1:42Speaker 2: really human like text from simple prompts. You don't need
- 1:45Speaker 2: a PhD in machine learning anymore. It's not just for
- 1:47Speaker 2: the big players like Typeface or Jasper Ai building on
- 1:50Speaker 2: top of it. It's for you integrating that power into
- 1:52Speaker 2: your own stuff.
- 1:53Speaker 1: And the open II Playground is kind of the perfect
- 1:56Speaker 1: place to start messing around. Yeah, like a sandbox. It's
- 1:58Speaker 1: got three main parts the system message, the chat log,
- 2:01Speaker 1: and then the parameters. The system message is where you
- 2:04Speaker 1: tell the AI who it should be, like you are
- 2:08Speaker 1: an assistant that creates marketing slogans, simple as that shapes
- 2:11Speaker 1: its whole persona right.
- 2:13Speaker 2: And it's fascinating because the model isn't understanding like we
- 2:16Speaker 2: do no thoughts, no feelings. Think of it more like
- 2:19Speaker 2: super advanced autocomplete. It predicts the next word based on
- 2:24Speaker 2: patterns from tons of text data. So you put examples
- 2:26Speaker 2: in the chat log, say you give it company makes
- 2:29Speaker 2: ice cream, and then that apply sham the ice cream
- 2:31Speaker 2: that never melts. You're guiding those predictions. You're kind of
- 2:34Speaker 2: training it right there to follow patterns like starting with
- 2:37Speaker 2: sham and ending with an exclamation.
- 2:39Speaker 1: Mark that makes sense, guiding the probabilities. Okay, so once
- 2:43Speaker 1: you've got your prompts working well in the playground, you
- 2:45Speaker 1: move on to making real API requests, maybe using something
- 2:48Speaker 1: like postmam. And this is where it gets really powerful
- 2:51Speaker 1: because you're not just watching it work, you're controlling it
- 2:53Speaker 1: with code programmatically. And for an API request, there are
- 2:57Speaker 1: like four main things you need. Right First is the
- 2:59Speaker 1: endpoint that's URL, the address you're sending the request to
- 3:02Speaker 1: like https, dot API, dot openI, dot com, forward slash
- 3:05Speaker 1: v one chat completions exactly.
- 3:08Speaker 2: Then there's the header. Think of this as containing important metadata.
- 3:12Speaker 2: It tells open Ai what you're sending, usually content type
- 3:15Speaker 2: dot application JSON because Jason is just a standard way
- 3:18Speaker 2: for systems to swap structured data. And critically, it says
- 3:21Speaker 2: who you are with your authorization bearer, your API key.
- 3:25Speaker 2: That's your secret handshake with open Ai.
- 3:27Speaker 1: Okay, So header is like the envelope details, and the
- 3:29Speaker 1: body is what's inside the envelope.
- 3:31Speaker 2: Correct. A body is a Jason object. It holds the
- 3:33Speaker 2: specifics like which model you want to use, and the
- 3:36Speaker 2: messages that's your system message and chat log content. And
- 3:39Speaker 2: finally you get the response back from open Ai. That's
- 3:42Speaker 2: also Jason containing the AI's output. It's choices and usage
- 3:46Speaker 2: data like how many tokens you used?
- 3:48Speaker 1: Cool? But okay, let's break out of just text. The
- 3:50Speaker 1: open Ai API can do more than just words, can't it?
- 3:54Speaker 1: Multimodal stuff? Oh?
- 3:55Speaker 2: Absolutely, Beyond text. You've got image generation with Dally. The
- 3:59Speaker 2: newer versions Dally two and three use this technique called diffusion.
- 4:03Speaker 2: You can kind of picture it like starting with TV
- 4:05Speaker 2: static and slowly clearing it up until an image appears.
- 4:07Speaker 2: It's pretty neat. But the key with images, unlike text maybe,
- 4:10Speaker 2: is you have to be super specific in your prompts.
- 4:13Speaker 2: Just saying a dog gets you, well, a random dog,
- 4:16Speaker 2: but a brown, furry, medium sized CORKI doog on a
- 4:18Speaker 2: green grass field profile view that gets you much closer
- 4:22Speaker 2: to what you actually want. It raises an interesting point.
- 4:24Speaker 2: Text generation can infer context sometimes, but image generation it
- 4:28Speaker 2: needs precise descriptive language. Ambiguity is your enemy here.
- 4:32Speaker 1: Good point need to be crystal clear. And it does
- 4:34Speaker 1: audio too. Transcripts.
- 4:35Speaker 2: Yeah, the audio endpoint uses the Whisper model for that.
- 4:38Speaker 2: It transcribes audio files.
- 4:40Speaker 1: Ah and technically for file uploads you need to use
- 4:43Speaker 1: form data instead of JSON in.
- 4:45Speaker 2: The request right exactly. Jason is great for text data,
- 4:48Speaker 2: but form data is built for sending files, kind of
- 4:51Speaker 2: like attaching something to an email. It handles lots of
- 4:53Speaker 2: formats dot MP three, dot MP four, dot MPEG, dotwave,
- 4:57Speaker 2: dot web, dot WebM quite a few.
- 4:59Speaker 1: So you could transcribe a meeting maybe easily.
- 5:02Speaker 2: And the real magic starts when you chain these things together.
- 5:05Speaker 2: Imagine a voice assistant. Voice comes in whisper transcribes it,
- 5:08Speaker 2: chat Api figures out a response, maybe Dali even generates
- 5:12Speaker 2: relevant image.
- 5:12Speaker 1: Okay, that's starting to sound really powerful. Now, let's talk
- 5:15Speaker 1: about fine tuning the dials and knobs as you called
- 5:18Speaker 1: them in the book.
- 5:19Speaker 2: The parameters, right, The parameters let you control the AI's behavior,
- 5:23Speaker 2: and the model parameter is probably the biggest one. Usually
- 5:25Speaker 2: you're choosing between GPT three point five and GPT four.
- 5:28Speaker 2: GPT three point five has what one hundred and seventy
- 5:31Speaker 2: five billion parameters. GPT four is estimated to be way larger,
- 5:34Speaker 2: maybe over one hundred trillion parameters across a bunch of
- 5:37Speaker 2: models working together. More parameters generally means the model is
- 5:40Speaker 2: better at capturing subtle patterns and understanding complex instructions. So
- 5:44Speaker 2: GPT four tends to be more reliable, better with nuance.
- 5:47Speaker 2: It actually scores higher on things like standardized tests, EP calculus.
- 5:50Speaker 1: The lsat Wow, and you can see that difference in
- 5:53Speaker 1: the outputs. Can't you like that example in the book
- 5:55Speaker 1: asking for a sentence about Mars with six five letter words,
- 5:58Speaker 1: GPT three point five up the word count right, It
- 6:01Speaker 1: gives our Mars strip felt vast, new, cold.
- 6:04Speaker 2: Hard, grand grand isn't five letters.
- 6:06Speaker 1: Exactly If GPT four gets it, Mars Red World, Brave Crew,
- 6:09Speaker 1: Deep Space finds life. Perfect for the cigarette question how
- 6:12Speaker 1: many chemicals? How many harmful? How many cause cancer? Just
- 6:14Speaker 1: the numbers. GPT three point five gives you a paragraph.
- 6:17Speaker 1: GPT four just answers two hundred and fifty sixty concise
- 6:22Speaker 1: even logic puzzles. GPT four tends to reason more accurately
- 6:25Speaker 1: than three point five, and GPT four has a bigger
- 6:28Speaker 1: memory too. The context win much bigger.
- 6:30Speaker 2: Like GPT four thirty two k can handle around thirty
- 6:33Speaker 2: two thousand tokens maybe twenty four thousand words. GPT three
- 6:37Speaker 2: point five max is out around four thousand tokens about
- 6:39Speaker 2: three thousand words. Big difference if you're feeding it long documents.
- 6:43Speaker 1: Okay, but there's a catch, isn't there cost?
- 6:45Speaker 2: Huge catch? GPT four can be twenty to forty times
- 6:49Speaker 2: more expensive per token than GPT three point five. It's significant.
- 6:52Speaker 2: So the practical advice for you is always start with
- 6:55Speaker 2: GPT three point five. If it does the job great,
- 6:58Speaker 2: you save a lot of money. Only upgraded GPT four
- 7:00Speaker 2: if you absolutely need that extra reasoning power or the
- 7:03Speaker 2: larger context window.
- 7:04Speaker 1: That's a massive cost difference. Why is it so much
- 7:07Speaker 1: more just the size.
- 7:08Speaker 2: Primarily, Yeah, it's a much bigger, more complex model. Just
- 7:11Speaker 2: takes way more computing power to run each request. Think
- 7:14Speaker 2: supercomputer versus calculator.
- 7:15Speaker 1: Gotcha? Okay, another parameter dot N that controls how many
- 7:18Speaker 1: answers you get back right.
- 7:20Speaker 2: N sets the number of responses can be any whole
- 7:22Speaker 2: number for chat, but max ten for images. Super useful
- 7:25Speaker 2: for brainstormings, logans, getting different options, or for checking consistency,
- 7:28Speaker 2: maybe ab testing outputs.
- 7:29Speaker 1: And the interesting thing you mentioned is the cost isn't
- 7:31Speaker 1: linear like N three isn't three times the price?
- 7:34Speaker 2: No, it's often much less, maybe sixty percent more, not
- 7:37Speaker 2: two hundred percent more, which tells you something cool. The
- 7:41Speaker 2: AI isn't just running the request three times separately. It's
- 7:44Speaker 2: likely batching the computation somehow finding efficiencies. It's an optimization
- 7:48Speaker 2: hint clever.
- 7:49Speaker 1: Okay, what about temperature? That one sounds a bit abstract.
- 7:52Speaker 1: Controls creativity.
- 7:54Speaker 2: Yeah, temperature basically controls the randomness or let's say, creativity
- 7:57Speaker 2: of the output. It goes from point zero to two
- 7:59Speaker 2: point zero th of it, like tuning a radio. Low
- 8:01Speaker 2: temperature maybe twoint zero too point eight is like a sharp,
- 8:04Speaker 2: clear signal, very focused, consistent factual responses. Good for things
- 8:09Speaker 2: like code generation data analysis where you want deterministic.
- 8:12Speaker 1: Output and higher temperature more static, more like an eclectic
- 8:16Speaker 1: mix station.
- 8:17Speaker 2: Yeah, higher temps, say one point two to two point zero,
- 8:20Speaker 2: make the AI take more risks with word choices. It
- 8:22Speaker 2: flattens the probability curve for the next word, so you
- 8:24Speaker 2: get more diverse, unexpected sometimes more creative results. Great for brainstorming,
- 8:28Speaker 2: writing stories, generating slogans.
- 8:30Speaker 1: So for general use like a chatbot, maybe somewhere in
- 8:32Speaker 1: the middle point eight to one point two exactly.
- 8:35Speaker 2: Balance is making sense with being interesting.
- 8:37Speaker 1: So the advice is start around one point zero and
- 8:40Speaker 1: tweak it by like zero point two increments.
- 8:43Speaker 2: That's a good practical approach. Yeah, see what works for
- 8:45Speaker 2: your specific need.
- 8:46Speaker 1: Okay, makes sense. Now let's shift gears to building real applications.
- 8:52Speaker 1: Usually you don't just have your app talk directly to
- 8:54Speaker 1: open AI, right, there's often a back end layer in between.
- 8:57Speaker 2: That's right. The typical flow is from tend what the
- 9:01Speaker 2: user sees talks to your back end, and your back
- 9:03Speaker 2: end talks to the open AIAPI. This back end layer
- 9:06Speaker 2: is crucial. First security, it keeps your precious API key
- 9:11Speaker 2: safe hidden from the user's browser. Second control, you can
- 9:15Speaker 2: process the input before it goes to open AI or
- 9:18Speaker 2: clean up the output after it comes back. Plus it
- 9:20Speaker 2: lets you integrate other services, hand logins, all that stuff.
- 9:23Speaker 1: And for that back end, serverless options like Google Cloud
- 9:26Speaker 1: functions are pretty popular.
- 9:28Speaker 2: Very popular, yeah, because you don't have to manage servers.
- 9:30Speaker 2: It just scales automatically. You write your code, upload it,
- 9:34Speaker 2: and Google handles the rest. You set up an HTTP
- 9:37Speaker 2: trigger so it could be called like a web address.
- 9:39Speaker 2: Allow unauthenticated calls maybe for testing, but be careful in
- 9:43Speaker 2: production and define your entry point function.
- 9:46Speaker 1: And then for the front end the user interface. You
- 9:49Speaker 1: can use no code tools like Bubble, so anyone can
- 9:52Speaker 1: build the app part exactly.
- 9:54Speaker 2: Bubble lets you visually design your web app and connect
- 9:57Speaker 2: buttons and inputs directly to your back end cloud function.
- 10:01Speaker 2: It's incredibly empowering.
- 10:02Speaker 1: Let's walk through an example, like that email reply wrapper
- 10:05Speaker 1: from the book. You could do it in chat GPT, sure,
- 10:07Speaker 1: but building it yourself really teaches you the whole process.
- 10:10Speaker 1: So you start in the playground testing proms, get the
- 10:12Speaker 1: Python code, then you put that logic into a Google
- 10:15Speaker 1: Cloud function that's your back end. It takes the email
- 10:17Speaker 1: text as input, adds your API key. Secretly, you'd tell
- 10:20Speaker 1: it to use say GPT four, maybe a higher temperature
- 10:23Speaker 1: like one point four for creator replies, set N three
- 10:26Speaker 1: to get three options, maybe limit topens to five to one.
- 10:28Speaker 2: Right, and then you'd use Postman to test that cloud
- 10:31Speaker 2: function directly, make sure it actually returns three email replies
- 10:34Speaker 2: in the format you expect. Once that's working, you jump
- 10:36Speaker 2: into Bubble. You build the input box for the original email,
- 10:40Speaker 2: a button to generate replies, and maybe three textboxes to
- 10:42Speaker 2: display choice one, choice two, choice three. Use bubbles API
- 10:46Speaker 2: connector to link the button press to your cloud function
- 10:49Speaker 2: URL and display the return choices. And really understanding this
- 10:53Speaker 2: whole playground, Cloud function, Postman, Bubble. That's the fundamental pattern.
- 10:58Speaker 2: Master this and you can pretty much any intelligent app.
- 11:01Speaker 1: That's a great point. It's the core loop. What's a
- 11:04Speaker 1: common sticking point when people first try this? Getting the
- 11:06Speaker 1: data flow right often.
- 11:08Speaker 2: Yeah, getting the JSON right in the requests and responses,
- 11:12Speaker 2: making sure API keys are correct and secure, little syntax things.
- 11:15Speaker 2: Postwind really helps debug that before you even touch the frontend.
- 11:18Speaker 1: Okay, so that's a solid foundation. But let's get to
- 11:21Speaker 1: something really cool, something you can't just do in the
- 11:23Speaker 1: standard chat GPT interface easily. The multimodal travel itinerary app.
- 11:28Speaker 1: That sounds awesome.
- 11:30Speaker 2: It really shows the power of orchestrating multiple API calls.
- 11:33Speaker 2: The idea user toxicity gets back a detailed one day
- 11:38Speaker 2: plan morning, afternoon, evening activities and three AI generated images
- 11:42Speaker 2: matching those activities.
- 11:43Speaker 1: Wow, okay, how does that work behind the scenes in
- 11:46Speaker 1: the cloud function.
- 11:47Speaker 2: So first, because this involves multiple calls, including image generation,
- 11:51Speaker 2: which can be slow, you need to increase the cloud
- 11:53Speaker 2: function's timeout limit maybe to three hundred seconds five minutes,
- 11:57Speaker 2: just to be safe.
- 11:57Speaker 1: Good practical tip.
- 11:59Speaker 2: Then one uber one uses the chat api GPT four. Specifically,
- 12:03Speaker 2: it takes the city name. Crucially, you give it a
- 12:05Speaker 2: detailed chat log with examples what the book calls fu
- 12:08Speaker 2: shot prompting. You showed examples for Rome, Lisbon, et cetera.
- 12:11Speaker 2: Format it exactly how you want warning activity, afternoon activity,
- 12:15Speaker 2: evening activity. This force is GPT four to follow that
- 12:18Speaker 2: structure precisely. It stores the resulting itinerary text.
- 12:21Speaker 1: Got it. So the structure comes from good prompting and examples.
- 12:24Speaker 1: How do the images get generated?
- 12:25Speaker 2: That's call number two, also chat API, but this time
- 12:29Speaker 2: using GPT three point five Turbo one one oh six.
- 12:32Speaker 2: Its only job is to take the itinerary text from
- 12:34Speaker 2: call one and create three short descriptive prompts suitable for DELI.
- 12:40Speaker 2: Like if the itinerary mentioned the Colisseum, Vatican and Trevy Fountain,
- 12:44Speaker 2: it might output Colisseum and Rome, Vatican City Interior, Trevy
- 12:48Speaker 2: Fountain at night. Just the prompts separated by a pipe symbol.
- 12:51Speaker 1: Ah. And you use GPT three point five here because
- 12:53Speaker 1: it's cheaper and the task is simple. It doesn't need
- 12:55Speaker 1: GPT four's nuance exactly.
- 12:58Speaker 2: The user never sees this intermediate p output, only the
- 13:00Speaker 2: final images, so three point five is perfectly adequate and
- 13:03Speaker 2: much more cost effective for this specific step.
- 13:06Speaker 1: Smart resource use nice optimization. Okay, So now you have
- 13:08Speaker 1: the itinerary text and three image prompts.
- 13:10Speaker 2: Right, So call number three hits the images API using
- 13:13Speaker 2: DELI THII. Your code loops through the three prompts from
- 13:16Speaker 2: call too, making a separate API call for each one
- 13:19Speaker 2: to generated image. It collects the URLs of the three
- 13:21Speaker 2: generated images image rolls Finally, the cloud function bundles everything
- 13:24Speaker 2: up and returns a single Jason response containing the itinerary
- 13:27Speaker 2: text and the URLs for morning image, afternoon image, and
- 13:31Speaker 2: evening image.
- 13:31Speaker 1: And then in bubble you just connect those pieces input
- 13:34Speaker 1: for city button, a big text area for the itinerary,
- 13:37Speaker 1: and three image elements. You map the JSON fields from
- 13:40Speaker 1: the cloud function response directly to those elements. That's really slick,
- 13:44Speaker 1: combining text and custom images on the fly like that.
- 13:47Speaker 2: Very cool. Okay, let's switch tracks slightly. Building knowledge assistance
- 13:52Speaker 2: this is huge. Standard chat GPT is great, but its
- 13:56Speaker 2: knowledge is kind of frozen in time right, and it
- 13:58Speaker 2: can sometimes just make stuff up hallocin. You can't easily
- 14:00Speaker 2: to only use this specific document precisely.
- 14:03Speaker 1: That's where building your own assistant comes in, using the
- 14:06Speaker 1: API combined with your specific trusted knowledge source. A basic
- 14:10Speaker 1: way to do this covered in the book is PDF analysis.
- 14:13Speaker 1: Your app takes a PDF link and a question. The
- 14:15Speaker 1: cloud function fetches the pdf, uses a library like pipdf
- 14:19Speaker 1: two to scrabe all the text out of it. Then
- 14:21Speaker 1: it stuffs that entire text into the prompt along with
- 14:23Speaker 1: the user's question, and sends it off to GPT four
- 14:26Speaker 1: so it just crams the.
- 14:26Speaker 2: Whole PDF into the context window every single time. Yeah, coefficient,
- 14:30Speaker 2: it can be. It works, but yeah, limitations. It only
- 14:33Speaker 2: gets text, no images from the pdf. It struggles with
- 14:37Speaker 2: really huge documents, and the biggest issue is that context
- 14:40Speaker 2: window limit. If your PDF has more words then the
- 14:44Speaker 2: model can handle like those three thousand words for GPP
- 14:48Speaker 2: three point five or twenty four thousand for GPT four
- 14:50Speaker 2: thirty two. K. It just won't work properly, right.
- 14:53Speaker 1: But there's a better way now, isn't there with the
- 14:56Speaker 1: newer assistance API.
- 14:58Speaker 2: Oh yeah, the assistants APIs specifically with its built in
- 15:01Speaker 2: knowledge retrieval tool, is a total.
- 15:03Speaker 1: Game changer for this What makes it so different.
- 15:05Speaker 2: It's incredibly smart. When you upload your documents, PDFs, word docs, etc.
- 15:10Speaker 2: To an assistant with retrieval enabled, open AI automatically handles
- 15:13Speaker 2: the hard parts. It breaks the documents into manageable chunks,
- 15:17Speaker 2: creates embeddings for each chunk, those unique numerical fingerprints we
- 15:20Speaker 2: talked about, and stores them efficiently. Then when you ask
- 15:23Speaker 2: a question, it uses vector search to instantly find only
- 15:26Speaker 2: the most relevant chunks of texts from your documents related
- 15:29Speaker 2: to your question.
- 15:30Speaker 1: So It doesn't read the whole document every time, It
- 15:32Speaker 1: just finds the relevant paragraphs.
- 15:33Speaker 2: Exactly, which means there's effectively no context window limit for
- 15:38Speaker 2: your knowledge base. You can upload massive files or hundreds
- 15:42Speaker 2: of documents and the assistant intelligently retrieves only the necessary
- 15:46Speaker 2: snippets to answer the question. Incredibly efficient.
- 15:49Speaker 1: That sounds amazing. How do you set that up? Still?
- 15:51Speaker 2: Start in the playground, yep, The playground is great for
- 15:54Speaker 2: creating the assistant itself. You give it a name US
- 15:57Speaker 2: Constitution Expert Instructions answer questions based only on the provided
- 16:01Speaker 2: constitution document. Choose a model like GPT four to eleven
- 16:05Speaker 2: oh six Preview, which is good for this. Then the
- 16:07Speaker 2: crucial step you toggle on the retrieval tool and then
- 16:11Speaker 2: you upload your knowledge file like a PDF of the
- 16:13Speaker 2: US Constitution. Once it's created, you grab the unique assistant ID.
- 16:17Speaker 1: Okay, assistant created, knowledge uploaded. Then the cloud function code
- 16:21Speaker 1: uses this assistant ID.
- 16:22Speaker 2: Correct. The Python code for your cloud function becomes a
- 16:25Speaker 2: bit different using the assistants API. First, you create a thread.
- 16:30Speaker 2: Think of thread as a single conversation session. Then you
- 16:34Speaker 2: add the user's question as a message to that thread. Next,
- 16:38Speaker 2: you tell the assistant to run on that thread, providing
- 16:40Speaker 2: the assistant ID and the thread ID. Now here's a
- 16:43Speaker 2: key detail for the book's code. You need to wait
- 16:45Speaker 2: a bit. The assistant needs time to process, search the
- 16:49Speaker 2: knowledge and formulate the answer, so you might add a
- 16:52Speaker 2: time dot sleep or similar pause. After the pause, you
- 16:57Speaker 2: retrieve the list of messages from the thread and the
- 17:00Speaker 2: assistem's answer will be the newest message.
- 17:01Speaker 1: Okay, that pause is important. And the bubble front end
- 17:04Speaker 1: for this probably simpler.
- 17:07Speaker 2: Much simpler for this use case. Yeah, just an input
- 17:09Speaker 2: boxer the user's question, a button and a text box
- 17:12Speaker 2: to display the answer returned by the cloud function.
- 17:14Speaker 1: And the result is you can ask specific questions like
- 17:16Speaker 1: how many senators are there or what's the age requirement
- 17:19Speaker 1: for a senator and it pulls the answer directly from
- 17:22Speaker 1: that constitution pdf you uploaded exactly.
- 17:25Speaker 2: It grounds the AI in your specific source material. It's
- 17:28Speaker 2: incredibly powerful for legal teams, medical info, company knowledge bases,
- 17:34Speaker 2: educational tools, anywhere you need reliable answers from a defined
- 17:38Speaker 2: set of information.
- 17:39Speaker 1: Wow, we've covered a lot, from just understanding the API
- 17:43Speaker 1: basics to playing in the playground, making direct calls, adding
- 17:46Speaker 1: images and audio. Then building actual apps with back ends
- 17:50Speaker 1: and frontends, optimizing costs, and finally creating these powerful knowledgeable
- 17:55Speaker 1: assistance tied to specific documents. You've really gone from just
- 17:58Speaker 1: using chat GPT to understand how to build with its
- 18:01Speaker 1: underlying power. You're equipped now to actually create things.
- 18:05Speaker 2: Yeah, and it brings to mind something Paul Siegel, a
- 18:07Speaker 2: tech entrepreneur, wrote in the forward to Henry's book, You said, Essentially,
- 18:10Speaker 2: I strongly encourage you to use this knowledge to create
- 18:12Speaker 2: your next successful app or business, or simply to enrich
- 18:16Speaker 2: your thinking about how to innovate. Dream on it, then
- 18:19Speaker 2: fashion your dreams into a reality with the tools you've
- 18:21Speaker 2: gained here. I think that sums it up nicely.
- 18:24Speaker 1: Great final thoughts, So the message is clear, don't just
- 18:26Speaker 1: use AI, build with it, Go experiment, see what you
- 18:29Speaker 1: can create.