Skip to content

Repository files navigation

Chronos - AI Business Assistant Platform

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).

Next.js Supabase Gemini Vercel AI SDK

🚀 Key Features

  • RAG-Powered Knowledge Base: Ingests and embeds PDF policy documents using unpdf and 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).

🛠️ Technical Deep Dive & Challenges Overcome

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:

1. Robust PDF Ingestion in Edge Runtimes

  • Challenge: Traditional libraries like pdf-parse rely heavily on Node.js fs module, which breaks in Next.js Edge/Serverless environments and modern Turbopack builds.
  • Solution: Migrated to unpdf, a platform-agnostic PDF parser. We implemented custom Uint8Array handling to ensure consistent binary data processing across the browser upload and server-side processing pipeline.

2. AI SDK Protocol Synchronization

  • Challenge: The Vercel AI SDK (ai) recently underwent a major breaking change (v4 -> v6). Integrating @ai-sdk/google initially caused processDataProtocolResponse errors on the client because the server was streaming a data protocol incompatible with the client's useChat hook version.
  • Solution: We performed a strict dependency alignment, pinning ai to 4.1.2 and accompanying packages to their stable v3/v1 counterparts. This ensured ensuring that the streamText/toDataStreamResponse protocol on the server matched the client's expectations perfectly.

3. Silent Tool Execution Failures (Debugged)

  • 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.json had referenced a non-existent zod v4. The AI SDK relies on zod v3 for schema validation. This caused a silent runtime crash during tool parameter validation. Downgrading to zod@3.23.8 resolved the crash.
    • Environment Transparency: Implemented direct process.stdout.write logging (bypassing console buffering) to prove that NEXT_PUBLIC_SUPABASE_URL and keys were accessible at runtime.

4. Gemini Model Versioning & Availability

  • Challenge: The google provider allows various model IDs, but account-tier availability varies wildly between v1 and v1beta endpoints. gemini-1.5-flash was "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.

🏗️ Architecture Stack

  • 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

🏃‍♂️ Getting Started

Prerequisites

  • Node.js 18+
  • Supabase Account
  • Google AI Studio API Key

Installation

  1. Clone the repo

    git clone https://github.com/omer-here/chronos.git
    cd chronos
  2. Install dependencies

    npm install
  3. Environment Setup Create a .env.local file:

    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
  4. Run Development Server

    npm run dev

🤝 Contributing

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

About

An advance RAG pipeline including metric evals, ingestions, tools calling & agentic workflow. Not only that, it is built in a way that every aspects seems so smooth that you can setup your unique AI in 5 minutes.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages