Basic frontend
This commit is contained in:
parent
050ea8df70
commit
f8964f6efc
21 changed files with 7764 additions and 0 deletions
36
app/backend/Dockerfile
Normal file
36
app/backend/Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV UV_COMPILE_BYTECODE=1 \
|
||||||
|
UV_LINK_MODE=copy
|
||||||
|
|
||||||
|
# Install haiku.rag-slim from workspace
|
||||||
|
COPY pyproject.toml uv.lock ./
|
||||||
|
COPY haiku_rag_slim/pyproject.toml haiku_rag_slim/README.md haiku_rag_slim/LICENSE haiku_rag_slim/
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv sync --frozen --no-install-project --no-dev --package haiku.rag-slim
|
||||||
|
|
||||||
|
COPY haiku_rag_slim haiku_rag_slim/
|
||||||
|
COPY README.md LICENSE ./
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv sync --frozen --no-editable --no-dev --package haiku.rag-slim
|
||||||
|
|
||||||
|
# Install app backend dependencies
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
||||||
|
uv pip install starlette uvicorn[standard] anthropic watchfiles
|
||||||
|
|
||||||
|
# Final layer
|
||||||
|
FROM python:3.13-slim
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /app/.venv /app/.venv
|
||||||
|
COPY app/backend/*.py ./
|
||||||
|
|
||||||
|
RUN mkdir -p /data
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
|
|
@ -176,11 +176,40 @@ async def list_documents(_: Request) -> JSONResponse:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def db_info(_: Request) -> JSONResponse:
|
||||||
|
"""Get database info and statistics."""
|
||||||
|
if not db_path.exists():
|
||||||
|
return JSONResponse(
|
||||||
|
{
|
||||||
|
"exists": False,
|
||||||
|
"path": str(db_path),
|
||||||
|
"documents": 0,
|
||||||
|
"chunks": 0,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
client = get_client(db_path)
|
||||||
|
stats = client.store.get_stats()
|
||||||
|
|
||||||
|
return JSONResponse(
|
||||||
|
{
|
||||||
|
"exists": True,
|
||||||
|
"path": str(db_path),
|
||||||
|
"documents": stats.get("documents", {}).get("num_rows", 0),
|
||||||
|
"chunks": stats.get("chunks", {}).get("num_rows", 0),
|
||||||
|
"documents_bytes": stats.get("documents", {}).get("total_bytes", 0),
|
||||||
|
"chunks_bytes": stats.get("chunks", {}).get("total_bytes", 0),
|
||||||
|
"has_vector_index": stats.get("chunks", {}).get("has_vector_index", False),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Create Starlette app
|
# Create Starlette app
|
||||||
app = Starlette(
|
app = Starlette(
|
||||||
routes=[
|
routes=[
|
||||||
Route("/v1/chat/stream", stream_chat, methods=["POST"]),
|
Route("/v1/chat/stream", stream_chat, methods=["POST"]),
|
||||||
Route("/api/documents", list_documents, methods=["GET"]),
|
Route("/api/documents", list_documents, methods=["GET"]),
|
||||||
|
Route("/api/info", db_info, methods=["GET"]),
|
||||||
Route("/health", health_check, methods=["GET"]),
|
Route("/health", health_check, methods=["GET"]),
|
||||||
],
|
],
|
||||||
middleware=[
|
middleware=[
|
||||||
|
|
|
||||||
41
app/docker-compose.dev.yml
Normal file
41
app/docker-compose.dev.yml
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# Local development with hot reloading
|
||||||
|
# Usage: docker compose -f docker-compose.dev.yml up --build
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: app/backend/Dockerfile
|
||||||
|
command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||||
|
working_dir: /app/src
|
||||||
|
ports:
|
||||||
|
- "8001:8000"
|
||||||
|
environment:
|
||||||
|
- DB_PATH=/data
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||||
|
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
|
||||||
|
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
|
||||||
|
volumes:
|
||||||
|
- ${DB_PATH:-./data/haiku.rag.lancedb}:/data
|
||||||
|
- ./backend:/app/src:ro
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
target: base
|
||||||
|
command: sh -c "pnpm install && pnpm dev"
|
||||||
|
working_dir: /app
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- BACKEND_URL=http://backend:8000
|
||||||
|
volumes:
|
||||||
|
- ./frontend:/app
|
||||||
|
- frontend_node_modules:/app/node_modules
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
frontend_node_modules:
|
||||||
27
app/docker-compose.yml
Normal file
27
app/docker-compose.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: app/backend/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "8001:8000"
|
||||||
|
environment:
|
||||||
|
- DB_PATH=/data
|
||||||
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||||
|
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
|
||||||
|
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
|
||||||
|
volumes:
|
||||||
|
- ${DB_PATH:-./data/haiku.rag.lancedb}:/data
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: frontend
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
- BACKEND_URL=http://backend:8000
|
||||||
|
depends_on:
|
||||||
|
- backend
|
||||||
4
app/frontend/.dockerignore
Normal file
4
app/frontend/.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
.git
|
||||||
|
*.log
|
||||||
30
app/frontend/.gitignore
vendored
Normal file
30
app/frontend/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
|
# Next.js build
|
||||||
|
.next/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Production
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Env files
|
||||||
|
.env*.local
|
||||||
|
|
||||||
|
# Vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# TypeScript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
35
app/frontend/Dockerfile
Normal file
35
app/frontend/Dockerfile
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
FROM base AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
FROM base AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
RUN addgroup --system --gid 1001 nodejs && \
|
||||||
|
adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
27
app/frontend/app/api/copilotkit/route.ts
Normal file
27
app/frontend/app/api/copilotkit/route.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { HttpAgent } from "@ag-ui/client";
|
||||||
|
import {
|
||||||
|
CopilotRuntime,
|
||||||
|
copilotRuntimeNextJSAppRouterEndpoint,
|
||||||
|
ExperimentalEmptyAdapter,
|
||||||
|
} from "@copilotkit/runtime";
|
||||||
|
import type { NextRequest } from "next/server";
|
||||||
|
|
||||||
|
const runtime = new CopilotRuntime({
|
||||||
|
agents: {
|
||||||
|
chat_agent: new HttpAgent({
|
||||||
|
url: `${process.env.BACKEND_URL || "http://backend:8000"}/v1/chat/stream`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const serviceAdapter = new ExperimentalEmptyAdapter();
|
||||||
|
|
||||||
|
export async function POST(request: NextRequest) {
|
||||||
|
const { handleRequest } = copilotRuntimeNextJSAppRouterEndpoint({
|
||||||
|
runtime,
|
||||||
|
serviceAdapter,
|
||||||
|
endpoint: "/api/copilotkit",
|
||||||
|
});
|
||||||
|
|
||||||
|
return handleRequest(request);
|
||||||
|
}
|
||||||
16
app/frontend/app/api/info/route.ts
Normal file
16
app/frontend/app/api/info/route.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const backendUrl = process.env.BACKEND_URL || "http://backend:8000";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${backendUrl}/api/info`);
|
||||||
|
const data = await response.json();
|
||||||
|
return NextResponse.json(data);
|
||||||
|
} catch {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ exists: false, error: "Backend unavailable" },
|
||||||
|
{ status: 503 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/frontend/app/globals.css
Normal file
24
app/frontend/app/globals.css
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow-x: hidden;
|
||||||
|
font-family:
|
||||||
|
system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||||
|
"Helvetica Neue", Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
19
app/frontend/app/layout.tsx
Normal file
19
app/frontend/app/layout.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import type { Metadata } from "next";
|
||||||
|
import "./globals.css";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "haiku.rag Chat",
|
||||||
|
description: "Conversational RAG powered by haiku.rag and AG-UI",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) {
|
||||||
|
return (
|
||||||
|
<html lang="en">
|
||||||
|
<body>{children}</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
5
app/frontend/app/page.tsx
Normal file
5
app/frontend/app/page.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import Chat from "@/components/Chat";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return <Chat />;
|
||||||
|
}
|
||||||
34
app/frontend/biome.json
Normal file
34
app/frontend/biome.json
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": false,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": false
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignoreUnknown": false
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "tab"
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"javascript": {
|
||||||
|
"formatter": {
|
||||||
|
"quoteStyle": "double"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assist": {
|
||||||
|
"enabled": true,
|
||||||
|
"actions": {
|
||||||
|
"source": {
|
||||||
|
"organizeImports": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
app/frontend/components/Chat.tsx
Normal file
70
app/frontend/components/Chat.tsx
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { CopilotKit, useCoAgent } from "@copilotkit/react-core";
|
||||||
|
import { CopilotChat } from "@copilotkit/react-ui";
|
||||||
|
import "@copilotkit/react-ui/styles.css";
|
||||||
|
import DbInfo from "./DbInfo";
|
||||||
|
|
||||||
|
interface ChatSessionState {
|
||||||
|
session_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChatContent() {
|
||||||
|
useCoAgent<ChatSessionState>({
|
||||||
|
name: "chat_agent",
|
||||||
|
initialState: {
|
||||||
|
session_id: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<style>{`
|
||||||
|
.chat-wrapper {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
.chat-container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 800px;
|
||||||
|
height: 90vh;
|
||||||
|
border-radius: 12px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||||
|
background: white;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.chat-content {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
<div className="chat-wrapper">
|
||||||
|
<div className="chat-container">
|
||||||
|
<DbInfo />
|
||||||
|
<div className="chat-content">
|
||||||
|
<CopilotChat
|
||||||
|
labels={{
|
||||||
|
title: "haiku.rag Chat",
|
||||||
|
initial:
|
||||||
|
"Hello! I can help you search and answer questions from your knowledge base. Ask me anything!",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Chat() {
|
||||||
|
return (
|
||||||
|
<CopilotKit runtimeUrl="/api/copilotkit" agent="chat_agent">
|
||||||
|
<ChatContent />
|
||||||
|
</CopilotKit>
|
||||||
|
);
|
||||||
|
}
|
||||||
135
app/frontend/components/DbInfo.tsx
Normal file
135
app/frontend/components/DbInfo.tsx
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
interface DbInfoData {
|
||||||
|
exists: boolean;
|
||||||
|
path: string;
|
||||||
|
documents: number;
|
||||||
|
chunks: number;
|
||||||
|
documents_bytes: number;
|
||||||
|
chunks_bytes: number;
|
||||||
|
has_vector_index: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatBytes(bytes: number): string {
|
||||||
|
if (bytes === 0) return "0 B";
|
||||||
|
const k = 1024;
|
||||||
|
const sizes = ["B", "KB", "MB", "GB"];
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
|
return `${Number.parseFloat((bytes / k ** i).toFixed(1))} ${sizes[i]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function DbInfo() {
|
||||||
|
const [info, setInfo] = useState<DbInfoData | null>(null);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || "";
|
||||||
|
fetch(`${backendUrl}/api/info`)
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then(setInfo)
|
||||||
|
.catch((err) => setError(err.message));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<div className="db-info db-info-error">
|
||||||
|
<span>Database unavailable</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
return (
|
||||||
|
<div className="db-info db-info-loading">
|
||||||
|
<span>Loading...</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!info.exists) {
|
||||||
|
return (
|
||||||
|
<div className="db-info db-info-empty">
|
||||||
|
<span>No database found</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<style>{`
|
||||||
|
.db-info {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #64748b;
|
||||||
|
background: #f8fafc;
|
||||||
|
border-bottom: 1px solid #e2e8f0;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.db-info-error {
|
||||||
|
color: #dc2626;
|
||||||
|
background: #fef2f2;
|
||||||
|
}
|
||||||
|
.db-info-loading {
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
.db-info-empty {
|
||||||
|
color: #f59e0b;
|
||||||
|
background: #fffbeb;
|
||||||
|
}
|
||||||
|
.db-stat {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
}
|
||||||
|
.db-stat-value {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #334155;
|
||||||
|
}
|
||||||
|
.db-stat-label {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
.db-index-badge {
|
||||||
|
padding: 0.125rem 0.375rem;
|
||||||
|
border-radius: 9999px;
|
||||||
|
font-size: 0.625rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.db-index-badge.indexed {
|
||||||
|
background: #dcfce7;
|
||||||
|
color: #166534;
|
||||||
|
}
|
||||||
|
.db-index-badge.not-indexed {
|
||||||
|
background: #fef3c7;
|
||||||
|
color: #92400e;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
<div className="db-info">
|
||||||
|
<div className="db-stat">
|
||||||
|
<span className="db-stat-value">{info.documents}</span>
|
||||||
|
<span className="db-stat-label">documents</span>
|
||||||
|
</div>
|
||||||
|
<div className="db-stat">
|
||||||
|
<span className="db-stat-value">{info.chunks}</span>
|
||||||
|
<span className="db-stat-label">chunks</span>
|
||||||
|
</div>
|
||||||
|
<div className="db-stat">
|
||||||
|
<span className="db-stat-value">
|
||||||
|
{formatBytes(info.documents_bytes + info.chunks_bytes)}
|
||||||
|
</span>
|
||||||
|
<span className="db-stat-label">total</span>
|
||||||
|
</div>
|
||||||
|
<div className="db-stat">
|
||||||
|
<span
|
||||||
|
className={`db-index-badge ${info.has_vector_index ? "indexed" : "not-indexed"}`}
|
||||||
|
>
|
||||||
|
{info.has_vector_index ? "indexed" : "no index"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
7
app/frontend/next.config.ts
Normal file
7
app/frontend/next.config.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const nextConfig: NextConfig = {
|
||||||
|
output: "standalone",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default nextConfig;
|
||||||
29
app/frontend/package.json
Normal file
29
app/frontend/package.json
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "haiku-rag-app",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "next lint",
|
||||||
|
"check": "biome check app components",
|
||||||
|
"format": "biome check --write app components"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@ag-ui/client": "^0.0.42",
|
||||||
|
"@copilotkit/react-core": "^1.50.0",
|
||||||
|
"@copilotkit/react-ui": "^1.50.0",
|
||||||
|
"@copilotkit/runtime": "^1.50.0",
|
||||||
|
"next": "^16.1.1",
|
||||||
|
"react": "^19.0.0",
|
||||||
|
"react-dom": "^19.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "2.2.6",
|
||||||
|
"@types/node": "^22",
|
||||||
|
"@types/react": "^19",
|
||||||
|
"@types/react-dom": "^19",
|
||||||
|
"typescript": "^5"
|
||||||
|
}
|
||||||
|
}
|
||||||
7116
app/frontend/pnpm-lock.yaml
Normal file
7116
app/frontend/pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load diff
0
app/frontend/public/.gitkeep
Normal file
0
app/frontend/public/.gitkeep
Normal file
41
app/frontend/tsconfig.json
Normal file
41
app/frontend/tsconfig.json
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"incremental": true,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
39
app/haiku.rag.yaml.example
Normal file
39
app/haiku.rag.yaml.example
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# haiku.rag configuration for the chat app
|
||||||
|
# Copy to haiku.rag.yaml and customize as needed
|
||||||
|
|
||||||
|
# QA model configuration
|
||||||
|
qa:
|
||||||
|
model:
|
||||||
|
provider: ollama
|
||||||
|
name: gpt-oss
|
||||||
|
# For Anthropic:
|
||||||
|
# provider: anthropic
|
||||||
|
# name: claude-sonnet-4-20250514
|
||||||
|
# For OpenAI:
|
||||||
|
# provider: openai
|
||||||
|
# name: gpt-4o
|
||||||
|
|
||||||
|
# Embedding configuration
|
||||||
|
embeddings:
|
||||||
|
model:
|
||||||
|
provider: ollama
|
||||||
|
name: nomic-embed-text
|
||||||
|
# For OpenAI:
|
||||||
|
# provider: openai
|
||||||
|
# name: text-embedding-3-small
|
||||||
|
|
||||||
|
# Optional reranking
|
||||||
|
# reranking:
|
||||||
|
# model:
|
||||||
|
# provider: cohere
|
||||||
|
# name: rerank-v3.5
|
||||||
|
|
||||||
|
# Search settings
|
||||||
|
search:
|
||||||
|
limit: 10
|
||||||
|
context_radius: 1
|
||||||
|
|
||||||
|
# Provider settings
|
||||||
|
providers:
|
||||||
|
ollama:
|
||||||
|
base_url: http://localhost:11434
|
||||||
Loading…
Reference in a new issue