From the course: AI-Powered Development with the Anthropic API
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Creating an interactive chat - Claude Tutorial
From the course: AI-Powered Development with the Anthropic API
Creating an interactive chat
- Let's see what it takes to modify our application so that we can send messages back and forth to the Anthropic API. I'll start off by getting rid of this user message, and what I want to do is create an array of messages so that I can have more than one message. I'm going to create a loop here, and this loop is going to allow me to go through the back and forth conversation between me and the chat bot. I'll go ahead and create a label for the message that we'll be typing into the chat bot, and if this user message happens to be quit, then I want to go ahead and break the application, which means it will exit it and take me back to the terminal. Then, I want to take that message and append it to the array of messages with the role of user, as well as the content of the message that I just typed into the terminal. Now here, I'll create a variable called response, and in that variable, I want to pass all of my model information like before. I'll copy this right here, and instead of a…