Simple AI
repository·main·Indexed 20 days ago
https://github.com/alwurts/simple-aiA monorepo providing scaffolding tools and documentation for building AI-integrated applications. It includes the create-simple-ai CLI for generating full-stack projects with Next.js, Hono, Tailwind CSS, Shadcn/ui, Drizzle ORM, and Better Auth. The ecosystem offers UI components, app blocks, and AI agent workflows integrated with Vercel AI SDK and React Flow.
What's inside simple-ai
- Simple AI is a monorepo containing tools for scaffolding AI-powered projects and a documentation site. The core ecosystem consists of a CLI for project generation and a documentation/component registry site.
Use the Chat Message component
mainTheChat Messagecomponent is a composable UI element designed for displaying chat messages. It supports features such as timestamps, action buttons, threading, and avatars (either icons or images).Explore simple-ai features and components
mainThe
simple-ailibrary provides three main categories of resources for building AI applications:- UI Components: Low-level building blocks like chat interfaces, markdown rendering, and model selectors.
- App Blocks: High-level, complete chat applications and generative UI examples.
- AI Agent Workflows: Visual workflow builders for designing AI agent systems.
Technical specifications:
- Styling: Built on
shadcn/uiwithTailwind CSS(Dark mode ready). - Logic: Integrated with
Vercel AI SDKandReact Flow(for workflows). - Type Safety: Full
TypeScriptsupport.
Prerequisites for using Blocks
mainThe Blocks components are built on top of the Vercel AI SDK. To use them effectively, your project should be prepared to use:
useChathook for client-side chat state management.streamTextfor server-side streaming responses.- An AI provider, such as
@ai-sdk/openaifor accessing models like GPT-4.
Check Vercel AI SDK compatibility
mainThe simple-ai components are designed to work seamlessly with the Vercel AI SDK. They provide a UI layer specifically for AI-powered applications, handling:
- Streaming responses
- Loading states
- Complex chat interactions
Understand the project structure
mainThe project is organized into the following directory structure to separate concerns between the frontend, backend, and database:
src/app/: Contains the Next.js App Router pages and routing logic.src/hono/: Contains the HonoJS backend routes and RPC definitions.src/db/: Contains the Drizzle ORM database schema and database services.src/components/: Contains reusable UI components (built with shadcn/ui).src/lib/: Contains shared utility functions and configuration files.
Configure JSX Renderer states
mainThe
stateprop controls the visual appearance and interactivity of the renderer. Use these states to match the lifecycle of your UI (e.g., during AI generation or when a component is disabled).interactive: (Default) Full interactivity.disabled: Reduces opacity and disables pointer events.read-only: Disables pointer events but maintains full visibility.streaming: Shows a pulsing animation with reduced opacity (useful for AI text/UI streaming).error: Adds a red border to indicate a rendering error.
Understand the simple-ai component philosophy
mainsimple-ai follows a 'copy and paste' philosophy similar to shadcn/ui. Instead of being installed as a rigid dependency, components are intended to be copied directly into your project. This approach provides:
- Full Ownership: You have complete control over the component code, allowing for deep customization of styles and logic.
- Ease of Customization: Start with battle-tested defaults and modify them to fit your specific UI/UX needs.
- Performance: Components are optimized for chat interfaces, ensuring they remain performant even with large message histories.
How Chat Message Area auto-scrolling works
mainThe
ChatMessageAreauses a sophisticated auto-scrolling system built onuse-stick-to-bottomto handle streaming content and user interaction:- Smart Auto-scroll: Automatically scrolls to new messages only if the user is already at the bottom.
- Interaction Awareness: Auto-scroll is automatically disabled when a user scrolls up to read previous messages.
- Re-engagement: Auto-scroll re-enables automatically when the user manually scrolls back to the bottom.
- Mobile Optimization: On touch devices, auto-scroll pauses while the user's finger is on the screen.
- Navigation: A
ChatMessageAreaScrollButtonis provided to allow users to quickly jump back to the bottom when they are not currently scrolled there.
Use the Tool Invocation component
mainThe
Tool Invocationcomponent is designed to display tool calls from an AI model with visual indicators for different execution states. It provides collapsible sections to inspect the input arguments passed to the tool and the resulting output.Supported states include:
- Streaming/Loading: Visual feedback while the tool is being executed.
- Available/Completed: Displays the tool call along with its input arguments and the final output results.
- Error: Displays an error state if the tool execution fails.
Install the JSX Renderer
mainYou can install the
jsx-renderercomponent using the shadcn CLI or by manual installation.Using shadcn CLI
npx shadcn@latest add jsx-rendererManual Installation
- Install the required dependencies:
npm install react-jsx-parser react-error-boundary- Copy the
jsx-renderer.tsxsource code into your project. - Update the import paths within the file to match your project's directory structure.
npx shadcn@latest add jsx-rendererTest create-simple-ai using npm link
mainTo test the package as a globally installed tool, use
npm link. This allows you to run thecreate-simple-aicommand from any directory on your system.# From the create-simple-ai directory npm link # Now test from anywhere create-simple-ai my-test-app --database postgres --yes # Unlink when done npm unlink -g create-simple-ai