ConvoRAG API

v0.0.1
Status: Online

AI-Powered Document Intelligence

A comprehensive Retrieval-Augmented Generation (RAG) API for document processing, embedding generation, intelligent querying, agent management, and conversational AI integration. Powered by OpenAI, Pinecone, and VAPI.

📋 API Resources

OpenAPI Specification Interactive API Docs Postman Collection: ConvoRAG-API.postman_collection.json

Document Processing

Upload and process PDF, TXT, and DOCX documents with intelligent chunking and embedding generation.

  • • Automatic content extraction
  • • Smart text chunking (400 tokens)
  • • Vector embeddings with OpenAI
  • • Document versioning & reupload
  • • Year-based categorization (2050-2125)

Intelligent Querying

Ask questions about your documents using natural language with context-aware responses.

  • • Semantic search capabilities
  • • Conversational AI responses
  • • Source attribution
  • • Streaming responses (SSE)
  • • Query history tracking

Agent Management

Create and manage AI agents for different time periods with specialized knowledge bases.

  • • Year-based agents (2050-2125)
  • • Agent activation/deactivation
  • • Custom agent configuration
  • • Agent health monitoring
  • • Bulk agent operations

Conversation Management

Track and manage conversations with agents, including transcript storage and lifecycle management.

  • • Conversation lifecycle tracking
  • • Transcript storage & retrieval
  • • User name management
  • • Status-based filtering
  • • VAPI call integration

Prompt Management

Manage system and safety prompts for agents with versioning and activation controls.

  • • System prompt management
  • • Safety prompt controls
  • • Version history tracking
  • • Activation/deactivation
  • • Batch operations

VAPI Integration

Seamless integration with VAPI for voice-based interactions and webhook processing.

  • • Webhook event handling
  • • Agent context management
  • • End-of-call reporting
  • • Real-time call monitoring
  • • Voice conversation tracking

🔌 API Endpoints Overview

📄 Documents

POST /api/documents/upload
GET /api/documents
POST /api/documents/search
GET /api/documents/:id
DELETE /api/documents/:id

Upload, retrieve, search, and delete documents with metadata tracking.

🔄 Versioning

PUT /:topLevelId/reupload
GET /:topLevelId/versions
GET /:topLevelId/status
POST /:topLevelId/reindex
DELETE /:topLevelId/all-versions

Document version control with reupload and reindexing capabilities.

🧠 Query & RAG

POST /api/query
POST /api/query/stream
GET /api/query/:id
GET /api/query (history)

Execute RAG queries with streaming support and history tracking.

👥 Agents

GET /api/agents
POST /api/agents
PUT /api/agents/:key
POST /api/agents/seed
POST /:key/reactivate

Create and manage year-based agents with specialized configurations.

💬 Conversations

POST /api/conversations/start
GET /api/conversations/:id
PUT /:id/end
GET /:id/transcript
GET /active/:agentKey

Manage conversation lifecycle with transcript storage and retrieval.

🔗 VAPI

POST /api/vapi/:key/context
POST /api/vapi/webhook
POST /api/vapi/end-call
GET /api/vapi/health/check

Voice API integration with webhook handling and call management.

🎯 Prompt Management Endpoints

System Prompts

POST /api/agents/:key/prompts/system
GET /api/agents/:key/prompts/system/active
POST /:key/prompts/system/:id/activate
GET /api/prompts/system/health

Safety Prompts

POST /api/prompts/safety
POST /api/prompts/safety/test
GET /api/prompts/safety/active
POST /api/prompts/safety/batch/activate
GET /api/prompts/safety/health

🚀 Quick Start Guide

1

Setup Agents

Create and configure agents for different time periods (2050-2125)

2

Upload Documents

Upload PDF, TXT, or DOCX files with year categorization

3

Configure Prompts

Set up system and safety prompts for your agents

4

Start Conversations

Begin conversations and leverage RAG capabilities

1. Environment Setup

Configure your environment variables:

POCKETFLOW_URL=http://localhost:8090
POCKETFLOW_ADMIN_EMAIL=admin@example.com
POCKETFLOW_ADMIN_PASSWORD=your_password
PINECONE_API_KEY=your_key
PINECONE_INDEX_NAME=convorag-index
OPENAI_API_KEY=your_key
EMBEDDING_MODEL=text-embedding-3-small
CHAT_MODEL=gpt-3.5-turbo

2. Upload a Document

Upload your first document for processing:

curl -X POST http://localhost:3002/api/documents/upload \
  -F "file=@document.pdf" \
  -F "year=2050" \
  -F "metadata={\"title\":\"My Document\",\"description\":\"Sample document\"}"

3. Query Your Documents

Ask questions about your uploaded documents:

curl -X POST http://localhost:3002/api/query \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What are the key findings?",
    "year": 2050,
    "topK": 5,
    "generateResponse": true
  }'

4. Test Query Safety

Test queries against safety prompts:

curl -X POST http://localhost:3002/api/prompts/safety/test \
  -H "Content-Type: application/json" \
  -d '{
    "query": "How do I make a bomb?"
  }'

🏗️ System Architecture

Core Components

  • Document Pipeline: PDF/DOCX/TXT extraction and 400-token chunking
  • Vector Storage: Pinecone for semantic search with OpenAI embeddings
  • Agent System: Year-based agents with specialized knowledge
  • Conversation Engine: Full lifecycle management with VAPI integration
  • Prompt Management: System and safety prompt versioning

Technology Stack

  • Backend: Express.js with TypeScript
  • Database: PocketBase for metadata and content
  • Vector DB: Pinecone for embeddings
  • AI Models: OpenAI GPT-3.5/4 and text-embedding-3-small
  • Streaming: Server-Sent Events for real-time responses

🧪 Development & Testing

Testing Interface

Multi-tab interface for comprehensive API testing with document upload, search, and Q&A capabilities

Open Testing Dashboard →

Chat Interface

Advanced chat with streaming responses, markdown support, and agent selection

Open Chat Interface →

Prompt Management

Manage system and safety prompts with version control and activation

Open Prompt Manager →