How snoeyink/myai works
myAI is a configurable chatbot with a Next.js chat UI, intent-based response routing, and document-grounded answers using Pinecone. The main workflow runs from a user message through the chat API and intention detection; questions additionally retrieve document context before generation, while hostile and casual messages use separate response prompts. Responses stream back to the UI with loading indicators and citation links. Sampled files establish the chat, routing, and streaming paths; the retrieval helper and intention detector are represented by their exact tree paths, but their internal implementations were not sampled.
Main entry points: use-app.ts Chat state · streaming.ts Stream dispatch · page.tsx Chat page · response.ts Response routing
Components 18
Chat interface
- Chat page
app/page.tsx - Chat state
hooks/use-app.ts - Messages and input
components/chat/messages.tsx - Chat input
components/chat/input.tsx - Browser storage
API routing
- Chat endpoint
app/api/chat/route.ts - Intent detection
modules/intention.ts - Intent prompt
prompts.ts - Response routing
modules/response.ts
Question retrieval
- Chat and retrieval helpers
utilities/chat.ts - Pinecone index
Response generation
- Response prompts
prompts.ts - Stream dispatch
actions/streaming.ts - Streamed response
actions/streaming.ts
Other components
- User
- OpenAI
- Anthropic
- Fireworks
Connections 21
- User → Chat page: uses
- Chat page → Chat state: uses state
- Chat page → Messages and input: renders
- Chat page → Chat input: renders
- Chat input → Chat state: submits input
- Chat state → Browser storage: reads and writes
- Chat state → Chat endpoint: posts chat
- Chat endpoint → Intent detection: detects intent
- Intent detection → Intent prompt: uses prompt
- Intent detection → OpenAI: classifies with
- Chat endpoint → Response routing: dispatches by intent
- Response routing → Chat and retrieval helpers: prepares question context
- Chat and retrieval helpers → Pinecone index: searches index
- Response routing → Response prompts: uses response prompt
- Response routing → Stream dispatch: queues generation
- Stream dispatch → OpenAI: streams from
- Stream dispatch → Anthropic: streams from
- Stream dispatch → Fireworks: streams from
- Stream dispatch → Streamed response: enqueues chunks
- Streamed response → Chat state: returns stream
- Chat state → Messages and input: updates messages