CoolFace
Apppublic

NaimalcreativityAI/physical-ai-chatbot-api

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

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

bash
GET /api/health

Chat

bash
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/apikey
  • โ€”QDRANT_URL - Qdrant Cloud cluster URL
  • โ€”QDRANT_API_KEY - Qdrant Cloud API key
  • โ€”CORS_ORIGINS - Allowed CORS origins (e.g., https://yoursite.com)

Local Development

bash
# 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.py

Frontend 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.