Skip to content

Course 2: Building with MIFY — Chapter 2

Build a document Q&A system that answers questions using your own files.

  • How to create a knowledge base
  • How to ingest documents
  • How to query with semantic search

Retrieval-Augmented Generation means: before asking the AI a question, first search your documents for relevant context, then give that context to the AI along with the question. The AI’s answer is grounded in your data, not just its training.

User asks question
→ Search knowledge base for relevant chunks
→ Give chunks + question to AI
→ AI answers using your documents as context

MIFY Knowledge Bases

In the UI: go to /knowledge → Create Knowledge Base. Via API:

Terminal window
curl -X POST \
-H "Authorization: Bearer mify_xxx" \
-H "Content-Type: application/json" \
-d '{"name": "Company Docs", "description": "Internal documentation"}' \
https://your-instance/api/knowledge-bases

Upload files (PDF, Word, HTML, CSV, Markdown, JSON, Text):

Terminal window
curl -X POST \
-H "Authorization: Bearer mify_xxx" \
-F "file=@./document.pdf" \
https://your-instance/api/knowledge-bases/{id}/ingest

MIFY automatically:

  1. Splits the document into chunks (512 tokens each)
  2. Creates embeddings using your configured model
  3. Stores vectors in pgvector for semantic search
Terminal window
curl -X POST \
-H "Authorization: Bearer mify_xxx" \
-H "Content-Type: application/json" \
-d '{"query": "What is our return policy?", "topK": 5}' \
https://your-instance/api/knowledge-bases/{id}/search

Returns the top 5 most relevant document chunks.

On the canvas, build:

Manual Trigger → Retrieve Node (searches KB) → Chat Node (answers with context)

The Retrieve node searches your knowledge base. The Chat node receives the retrieved chunks as context and generates an answer.

  1. Create a knowledge base at /knowledge
  2. Upload 3-5 documents (PDFs, text files, etc.)
  3. Build the RAG workflow on the canvas
  4. Ask questions and verify the AI answers from your documents
  5. Try the same via API

Previous: Chapter 1 — API Basics | Next: Chapter 3 — Content Generation