OpenAI Assistant API, getting started

Stephen Blum
Stephen Blum
19.1 هزار بار بازدید - 8 ماه پیش - We're going to make our
We're going to make our own AI assistant. OpenAI has put out a new API that lets us do exactly that. They even hinted that we could make some money off it further down the line, but that's not our main concern right now. Let's just start making one and see how it goes. We'll start with the basics. The OpenAI Assistance API really smooths over lots of the rough patches you might run into when you're using OpenAI with any other machine learning or AI model. The context size is too small, so we need to cut things up and then pick pieces of documents and sort by the relevance of vectors to see which documents match. Also, what are the basic instructions the AI should follow in giving answers? To get better results, we use a technique... What was it called again? Right, prompting. I thought it would have a fancier name. It's prompt engineering, typically a sequence of inputs and outputs. You ask a question and get an answer, and repeating that process can yield better results. The Assistance API also lets us introduce some custom functions that the AI will ask us to invoke. Keeping things simple is our goal today as we build our first AI assistant. I'm ready to create our first AI, our own custom assistant using OpenAI's new Assistance API. They've made it really intuitive to use their interface to make your own custom AI. Let's dive in. I'm going to create my first assistant. To keep things uncomplicated, it'll only be really good at one specific task. Let's make it an expert in PubNub MQTT. It'll be engineered to act like a software engineer. We'll program it to write code that we can paste into a Python script file that we can run locally on our own computer. We'll select the preview model, and also add a simple function for file retrieval. Now, we'll upload a text-based file which provides extra instructions to help it accomplish its objective. From our documentation page, I'll print and save a file. Now I just need to upload our PDF file. The file is uploaded and it has all the knowledge it needs. We're ready to roll. After saving and waiting for a bit, we have an AI assistant. Let's explore it. We are given an assistant ID that we can use to create new interactions with the assistant. Conveniently, we can instantly test the assistant using their inbuilt testing tool. OpenAI's tool made setting up our own assistant easy, and now let's test it out. They have a handy little "test" button that takes us to a playground with a standard user interface. I'd like to test out the MQTT function. The assistant gives two options: add or run. In this case, I don't need to add any more information, so I'm just going to hit "add and run". The assistant doesn't provide the typing effect we're used to seeing but they're working on adding that feature. The response was accurate and used instructions from the PDF file I provided. I can easily check this in the log input. The assistant used a retrieval tool and provided instructions on how to run the code on my local system. Once the install is complete and the file is copied, I can run the Python script. With a successful connection to the MQTT server, the assistant has performed its first task. This basic assistant helps answer questions and performs a task, writing Python code, very effectively. Additionally, it guided me to find my API keys in the dashboard for an easier MQTT broker connection. It's exciting to think of all the different potential applications for this approach. Various other features and capabilities like code interpretation and custom functions to retrieve more data or execute task-specific commands are available through the API. We can even pull data from other systems to create whole workflows. This really shows the power of the Assistance API and how it's making AI development more accessible.
8 ماه پیش در تاریخ 1402/08/17 منتشر شده است.
19,163 بـار بازدید شده
... بیشتر