Chronos is a sophisticated AI-powered SaaS platform designed to empower businesses with intelligent, context-aware assistants. It leverages Retrieval-Augmented Generation (RAG) and dynamic tool calling to provide accurate, business-specific answers derived from internal documents (PDFs) and real-time attributes (Hours, Status, Wifi).
- RAG-Powered Knowledge Base: Ingests and embeds PDF policy documents using
unpdfand Gemini Text Embeddings (004). - Dynamic Tool Calling: Real-time attribute retrieval (e.g., "Is the wifi on?") via function calling.
- Hybrid Intelligence: Seamlessly switches between static knowledge (RAG) and dynamic data.
- Streaming Interface: High-performance, low-latency chat interface using the Vercel AI SDK (v4 stable).
Building this MVP involved navigating the bleeding edge of AI SDKs and Next.js server components. Here are the specific engineering challenges resolved during development:
- Challenge: Traditional libraries like
pdf-parserely heavily on Node.jsfsmodule, which breaks in Next.js Edge/Serverless environments and modern Turbopack builds. - Solution: Migrated to
unpdf, a platform-agnostic PDF parser. We implemented customUint8Arrayhandling to ensure consistent binary data processing across the browser upload and server-side processing pipeline.
- Challenge: The Vercel AI SDK (
ai) recently underwent a major breaking change (v4 -> v6). Integrating@ai-sdk/googleinitially causedprocessDataProtocolResponseerrors on the client because the server was streaming a data protocol incompatible with the client'suseChathook version. - Solution: We performed a strict dependency alignment, pinning
aito4.1.2and accompanying packages to their stable v3/v1 counterparts. This ensured ensuring that thestreamText/toDataStreamResponseprotocol on the server matched the client's expectations perfectly.
- Challenge: The AI would occasionally respond with a generic "An error occurred" or refuse to call tools despite valid prompts. Logs were swallowed by the Next.js dev server.
- Solution:
- Zod Version mismatch: Discovered
package.jsonhad referenced a non-existentzodv4. The AI SDK relies onzodv3 for schema validation. This caused a silent runtime crash during tool parameter validation. Downgrading tozod@3.23.8resolved the crash. - Environment Transparency: Implemented direct
process.stdout.writelogging (bypassing console buffering) to prove thatNEXT_PUBLIC_SUPABASE_URLand keys were accessible at runtime.
- Zod Version mismatch: Discovered
- Challenge: The
googleprovider allows various model IDs, but account-tier availability varies wildly betweenv1andv1betaendpoints.gemini-1.5-flashwas "not found" on specific endpoints, causing 500 errors. - Solution: We validated model availability using raw API probes and locked the implementation to
gemini-flash-latest, ensuring consistent access to the Flash tier for tool calling without hitting 404/429 errors.
- Framework: Next.js 16+ (App Router, Server Actions)
- Database: Supabase (PostgreSQL + pgvector)
- AI Provider: Google Gemini (via
@ai-sdk/google) - Orchestration: Vercel AI SDK (Stream Protocol)
- Styling: Tailwind CSS + Shadcn UI
- Node.js 18+
- Supabase Account
- Google AI Studio API Key
-
Clone the repo
git clone https://github.com/omer-here/chronos.git cd chronos -
Install dependencies
npm install
-
Environment Setup Create a
.env.localfile:NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_key GOOGLE_GENERATIVE_AI_API_KEY=your_gemini_key OPENAI_API_KEY=your_openai_key # Optional switches. Defaults keep the old Gemini behavior. AI_CHAT_PROVIDER=google # google | openai AI_EMBEDDING_PROVIDER=google # google | openai GOOGLE_CHAT_MODEL=gemini-flash-latest GOOGLE_EMBEDDING_MODEL=gemini-embedding-001 OPENAI_CHAT_MODEL=gpt-4o-mini OPENAI_EMBEDDING_MODEL=text-embedding-3-small OPENAI_EMBEDDING_DIMENSIONS=768
-
Run Development Server
npm run dev
I welcome contributions! Please specifically look at the /src/lib/ai directory if you're interested in improving the prompt engineering or tool definitions.
Built with ❤️ by the Chronos Team