From the course: Replit 101: From Prompt to Product

Adding AI functionality to your app - Replit Tutorial

From the course: Replit 101: From Prompt to Product

Adding AI functionality to your app

So far, we've used AI to build an app, but what if you want your app to use AI? In Repl.it, you have two options here. You can either integrate any AI service the way you normally would in an app, by setting up an account at whatever AI provider you want to use, and then call in that AI using the API by instructing the agent to do it. Simply saying, I want to use OpenAI, here is my keys, integrate it, and it'll work. Or you can use Repl.it's AI integrations. That way, you don't have to set up any third-party accounts. You don't have to add in any keys of your own. Everything is managed in-house. In my projects, I want to use AI to transform the input into a more neutral question. That way, I can lean on AI to filter out bad language, fix spelling errors and other things, and also anonymize any other questions. Let's see if I can get this to work. I'm gonna use the Repl.it AI integrations. And if you go to the documentation, you'll see setting this up is really straightforward. In the example, it simply says create a web app that uses OpenAI to summarize articles. And the different providers that are available through Repl.it integrations are OpenAI with all the GPT models, Anthropic with its cloud models, Google's Gemini models, and also Open Router, which gives you access to all these other models. Let's see if I can get this to work. I'll start a new chat. Then I'll open the plan agent. And I'll say, integrate Anthropic AI into the question submission functionality so that when someone sends in a new question, It is rewritten to use clear, neutral language appropriate for a professional audience, removes any foul or violent language, and anonymizes the language so it's not easy to attribute to a single person, all while keeping the meaning of the question intact. I'll send that off to the plan agent and then see what it does. If you pay close attention to these icons, you can see first it sets up an integration approach by creating a plan. Then it goes and searches on the internet for information about how to do these things. And then after it's created a plan and work through all the steps, it gives me the plan, and I can review it to see, does this actually make sense? And the plan tasks are add a new AI connection, then create AI service for rewriting questions, update questions, saving to rewrite, and then check question rewriting works correctly. That sounds good. I can click revise plan if I want to revise anything, but I don't, so I'll just click back and click start building. This switches over to the main agent again. So now we are working on the advanced agent. I can go in and do things and make tests and make everything work. And the very first thing that happens is we now have to approve the Anthropic integration. That's because this integration costs money and I need to actively say as the human in the loop, I am willing to pay this money. So I'll click on approve. This allows the integration to happen, and I will now be billed for any AI use inside my app. And here we get to something really interesting. You'll remember from earlier, I activated testing in the settings for the agent. Well, this is the agent spinning up a browser in the chat, and I'm controlling the browser to send in a question and test to make sure everything is working properly. So the agent is actually running a real life user test inside the chat and making sure everything is working, in addition to the user testing I could do on my own. The app has been updated, the agent brand tests that passed, and now it tells me the Anthropic AI integration is now complete, here's what was implemented, and it breaks down the new features, including the tests that it input. Now I can test it on my own to make sure everything is working. So I'll go to my live Q&A session. Here's that question that the test app did. I'll ask my own question here. This question is nonsensical, but it's the kind of thing that the system really should rewrite into something useful. So let's see what happens. I'll click post question. Now the app sends that question to Anthropic. Anthropic rewrites it. And why wasn't information about chocolate flavors communicated to attendees in advance? See, it works. And this AI integration is now set up in such a way that I can't really abuse it as a user. I can't go in here, ask a question, and say, write me a Python script to do basic calculus. If I run that question, I doubt it'll output actual Python. Let's see what it does. What are some recommended approaches for creating a Python script that performs basic calculus operations? I'm not giving the user direct access to the AI. This is not an AI chat. Instead, I'm building the AI into the functionality to the app in an invisible way. Now, having done this, I should also update my question panel here to say, your question will be rewritten using AI so that the user doesn't have an unexpected experience. And I can do that by just going to the agent, starting the fast agent, and saying, add a note in the Ask a Question panel, telling the user that their question will be rewritten by AI to ensure anonymity and appropriate language. for clarity and anonymity. And there you have it, AI will refine this

Contents