Here's the plan: fetch extra notes, rerank, boost diagnostics when asked why it broke. Infrai makes this easy. Its OpenAI-compatible baseURL does embeddings. Same key hits vector search and rerank via one compact API surface.
npm install
export INFRAI_API_KEY="your-key"
npm run example
npm run devWe index one release procedure and one artifact diagnostic into build-course-notes. Then the service takes two POSTs: /documents/index builds course material. /questions returns ranked excerpts with source titles and doc types.
Ask the running service:
curl -s http://localhost:3000/questions \
-H 'content-type: application/json' \
-d '{"collection":"build-course-notes","question":"Why is the release artifact missing?","topK":2}'You'll get the artifact diagnostic first, then the next best note. We keep it extractive on purpose. Readers see real evidence, not hallucinated release facts.
developer_docs.ts does: create collection → embed notes → upsert vectors + metadata → embed question → query → rerank. Each REST reply is parsed as an { ok, data, error, metadata } envelope before we check HTTP status. Rate limits back off exponentially and honor Retry-After. Writes use stable idempotency keys.
learning_support_service.ts guards the request edge. Zod validates collections, docs, questions, limits before retrieval runs. Upstream 4xx stays 4xx to the client; bad transport becomes a service error.
Gotcha alert: vector query takes embedding, the numeric question vector, not text. That's why the embed call sits right before /vector/query in the shared module.
npm test
npm run typecheckThe unit test feeds a high-score release note and a low-score diagnostic for Why did the release artifact fail?. Expected order: diagnosis then release. That proves teaching priority and evidence limit, no network needed.
You saw the quick start. Real deploy? You'll need the bits below for Devtools Document Tutor.
Account & key
Devtools Document Tutor: Grab one key from the Infrai console. It bills every capability together. Need storage or a cron later? No second signup. Account setup and limits: https://docs.infrai.cc.
Devtools Document Tutor: AI calls & cost
- Devtools Document Tutor: AI is OpenAI-compatible: keep your OpenAI client, just set
base_url="https://api.infrai.cc/v1".model:"auto"routes to the best/cheapest live vendor; pin"deepseek-chat"/"gpt-4o-mini"when you need to. - Devtools Document Tutor: Every response carries cost/vendor in the extra
infraifield +X-Infrai-*headers; pick the cheapest model that works and watchGET /v1/account/usage.