NaimalcreativityAI/physical-ai-chatbot-api
0
Physical AI Chatbot API ๐ค
RAG-based chatbot for the Physical AI & Humanoid Robotics textbook.
Features
- โ Answer questions from textbook content exclusively
- โ Text selection queries - Ask about highlighted text
- โ Navigation guidance - Get links to relevant lessons
- โ Study companion - Recommendations for learning path
- โ Streaming responses via Server-Sent Events (SSE)
- โ Source citations - Every answer includes chapter/lesson references
Technology Stack
- Framework: FastAPI
- LLM: Google Gemini 1.5 Flash (free tier)
- Embeddings: Qdrant FastEmbed (BAAI/bge-small-en-v1.5)
- Vector DB: Qdrant Cloud (free tier)
- Streaming: SSE (Server-Sent Events)
API Endpoints
Health Check
GET /api/healthChat
POST /api/chat
Content-Type: application/json
{
"message": "What is embodied intelligence?",
"selected_text": null,
"current_page": null,
"conversation_history": []
}Interactive API Documentation
- Swagger UI:
/docs - ReDoc:
/redoc
Environment Variables
Required secrets (configure in Hugging Face Space settings):
GEMINI_API_KEY- Get from https://aistudio.google.com/app/apikeyQDRANT_URL- Qdrant Cloud cluster URLQDRANT_API_KEY- Qdrant Cloud API keyCORS_ORIGINS- Allowed CORS origins (e.g.,https://yoursite.com)
Local Development
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export GEMINI_API_KEY=your_key
export QDRANT_URL=your_qdrant_url
export QDRANT_API_KEY=your_qdrant_key
# Run server
python app.pyFrontend Integration
This API is designed to work with the Physical AI textbook frontend:
- Frontend: https://naimalarain13.github.io/physical-ai-and-humaniod-robotics/
- Repository: https://github.com/NaimalArain13/physical-ai-and-humaniod-robotics
Cost
๐ฐ Total Cost: $0/month
- Gemini API: Free tier (15 requests/minute)
- Qdrant FastEmbed: Local, free
- Qdrant Cloud: Free tier (1GB storage)
License
MIT License
Support
For issues and questions, please visit the GitHub repository.
