SvelteKit ChatGPT

Description

ChatGPT app built with SvelteKit.

Features

  • Streaming responses with auto scroll (scroll up to stop, scroll down to continue)
  • Stop response mid-stream
  • Remembers previous messages
  • Supports code blocks with syntax highlighting

Built With

To do

  • Improve regex and/or code for catching code blocks
  • Improve on TypeScript code

Getting Started

Installing

  1. Clone the repo:
git clone git@github.com:baresi687/sveltekit-chatgpt.git
  1. Install the dependencies:
npm install
  1. Sign up with OpenAI and create an API key.
  • Create a file called .env.production in project root with the contents of VITE_CHATGPT_KEY=YOUR_API_KEY

Running

To run the app, run the following commands:

npm run build
npm run preview

Testing

Unit tests

The processTextAndCodeblocks function has the following tests:

  • Return array with text object and property text
  • Return array with text object and property text updated
  • Return array with code object and property code updated
  • Return array with text and code objects

To run the unit tests:

npm run test

Contact

My LinkedIn page

Top categories

Loading Svelte Themes