chat
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v13View latest version
A simple AI chat application built on Val Town using the OpenAI API.
- Real-time chat interface with an AI assistant
- Powered by OpenAI's GPT models
- Modern, responsive design with Tailwind CSS
- TypeScript for type safety and better developer experience
- Markdown-like formatting for code blocks and other elements
├── backend/
│ └── index.ts # Backend API with Hono and OpenAI integration
├── frontend/
│ ├── index.html # Main HTML template
│ └── index.ts # Frontend TypeScript
└── README.md
- The frontend provides a chat interface where users can type messages
- Messages are sent to the backend API endpoint
- The backend uses the OpenAI API to generate responses
- Responses are formatted and displayed in the chat interface
- TypeScript: For type safety and better code organization
- Tailwind CSS: For styling without custom CSS files
- Hono: Lightweight web framework for the backend
- OpenAI API: For generating AI responses
This app requires an OpenAI API key to be set as an environment variable in Val Town.
- Fork this project in Val Town
- Add your OpenAI API key as an environment variable named
OPENAI_API_KEY
- Run the project
You can customize the app by:
- Changing the OpenAI model in the backend (currently using gpt-4o-mini)
- Adjusting the max tokens parameter for longer or shorter responses
- Modifying the Tailwind classes to change the appearance
- Adding additional features like message history or user authentication