This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
This project now includes a streaming ChatGPT-like interface powered by the OpenAI API.
Create (or edit) .env.local and set:
OPENAI_API_KEY=sk-...Restart dev server after changing env variables.
pnpm dev
# or npm run dev / yarn devOpen http://localhost:3000 — the root page is the chat UI.
The landing page now shows a questionnaire for FHI (Fakulta Hospodárskej informatiky) students. After submitting:
- The app builds a structured system prompt containing the anonymized profile.
- Automatically triggers an initial request recommending 3–5 thesis topics (with descriptions, methods, rationale, risks).
- The chat continues allowing follow-up refinement (e.g., "rozviň tému 2" or "navrhni variant pre AI").
Questions captured: prior study, experienced areas (limit 3), strengths, weaknesses, interest areas (limit 3), preferred topic type, practice linkage, optional supervisor, one-sentence ideal topic.
To adapt rules (format, number of topics) edit buildSystemPrompt() inside app/page.tsx.
You can enrich recommendations with official subject information PDFs (e.g., course syllabi, info sheets). The system will pull the most relevant chunks and append them to the system prompt.
-
Place your PDF files (max a few MB total) in:
data/pdfs/ -
Index them to create embeddings (ensure ts-node installed, already added in devDependencies):
pnpm ts-node scripts/index-pdfs.tsThis produces data/subject_chunks.json containing chunk text + embeddings.
- Start the dev server (if not already):
pnpm dev-
On first questionnaire submission, the API route (
app/api/chat/route.ts) will:- Take the last user message or the initial prompt.
- Retrieve top 3 similar chunks (vector similarity cosine).
- Append them under "Doplňujúci kontext z informačných listov predmetov" inside the system prompt.
-
To tweak retrieval:
- Change
topKinretrieveSubjectContext(query, 3)(filelib/pdfIndex.ts). - Adjust chunk size / overlap in
scripts/index-pdfs.ts(CHUNK_SIZE,CHUNK_OVERLAP). - Swap embedding model (e.g.
text-embedding-3-large).
- Change
-
Re-index whenever PDFs change:
pnpm ts-node scripts/index-pdfs.ts-
If no
subject_chunks.jsonis present, the chatbot silently skips enrichment. -
For production: run the indexing step in build pipeline or pre-generate the JSON and commit it (if allowed), or store embeddings in a vector DB (Pinecone, PgVector, etc.).
Security note: Keep PDFs out of public/ if they contain internal data; current path is server-side only.
- System prompt text area at the top lets you define behavior (instructions in Slovak or any language).
- Type a message and press Enter or click Odoslať.
- Responses stream token-by-token for a smoother experience.
- Click "Vyčistiť chat" to reset conversation.
- Frontend:
app/page.tsx - API route:
app/api/chat/route.ts(streams OpenAI response)
Edit app/api/chat/route.ts and adjust:
model: "gpt-4o-mini",
temperature: 0.7,- Ensure
OPENAI_API_KEYis added to hosting provider environment variables. - Streaming uses a readable stream; supported on most modern platforms (Vercel, etc.).
- 500 Missing OPENAI_API_KEY: set env var and restart.
- Slow/no stream: verify network & model availability.
- Tailwind class warning: updated to new v4 naming (
bg-linear-to-br).
Enjoy building with your new chatbot! 🚀