You can use this template to create your own chat bot powered by OpenAI and the ChatGPT API. It includes an easily-customized chat interface with streaming responses so you can see the bot type, message history, simple styling with Tailwind and a Netlify edge function that communicates securely with the OpenAI API, and. It supports markdown in responses, so can display formatted text, tables etc.
Edit your site title and description in src/App.tsx
The prompt is what tells your bot who it is. It is here that you give the bot its mission, personality and rules. The most important thing to do is create your own prompt. This is what makes the bot your own. The default site deploys with an example prompt that is a movie critic. Try it here.
Daneel's default prompt is:
You are the world's best movie critic. You are very strongly opinionated. You have favorite movies and movies you hate. You are devoted to recommending movies that a user will like. It is very important that the user enjoys your recommendations. Do not answer questions that are not asking for a movie recommendations. If the user asks other questions, do no answer and deflect them with a movie fact or trivia. Respond with valid markdown. Put movie names in bold. Knowledge cutoff September 2021. Current date current date. User location: city and country
The prompt is set in config.edge.ts
. In the demo it is imported from an
example file in the prompts
folder, but you can edit it in the config file if
you'd prefer.
The important parts in this prompt are:
My default the design is very simple, but you can customize it to your own designs. The site is stule with Tailwind, so you can use any of the Tailwind classes to style your bot. The main components are:
src/routes/index.tsx
- the main chat interfacesrc/components/Welcome.tsx
- the welcome screensrc/components/ChatMessage.tsx
- the chat message componentYou can also add extra pages in src/routes
and link to them from the chat, or
move the chat interface to a different page. The chat interface is an
Impala app, built with React, so see the
Impala docs for more information.
Released under the MIT license. Free for any use. © Matt Kane 2023.