Spaces:
Sleeping
Sleeping
metadata
title: Humanoids
emoji: π¨
colorFrom: gray
colorTo: purple
sdk: docker
pinned: false
SpecKit-Plus Backend (Humanoids)
This is the AI-powered backend for the Physical AI & Humanoid Robotics interactive textbook. It provides Retrieval-Augmented Generation (RAG) capabilities, allowing students to query textbook content and get context-aware explanations.
Directory Structure
backend/
βββ main.py # Main FastAPI application entry point
βββ configs/
β βββ config.py # Configuration and model settings
βββ services/
β βββ rag.py # RAG (Retrieval Augmented Generation) service
β βββ indexer.py # Document indexing for Qdrant vector database
β βββ chatkit_service.py # ChatKit server with RAG capabilities
βββ data/
β βββ vector_store.py # Qdrant vector database operations
β βββ embeddings.py # Embedding service using FastEmbed
βββ simple_agents/
β βββ aagents.py # Triage Agent definition
βββ agents/
β βββ Runner.py # Agent runner
βββ tests/
β βββ test_keys.py # Configuration tests
β βββ test_rag.py # RAG functionality tests
βββ history/ # History of prompts and decisions
βββ prompts/ # Prompt History Records (PHRs)
βββ adr/ # Architecture Decision Records (ADRs)
What Has Been Done
1. Code Organization & Structure
- Organized backend files into logical directories (configs, services, data, simple_agents, agents, tests)
- Fixed import paths across all files to work with new directory structure
- Centralized model configuration in
configs/config.py
2. Qdrant Integration & RAG System
- Implemented document indexing system in
services/indexer.pyto upload documents fromfrontend/docsto Qdrant - Fixed Qdrant ID validation issues by changing from file paths to UUIDs
- Created RAG service in
services/rag.pyfor contextual query processing - Connected the main Agent in
main.pyto use Qdrant context before responding - Updated default collection name to "Humanoids" across all components
3. Agent Integration
- Connected the Triage Agent to use RAG context from Qdrant for more informed responses
- Updated API endpoints (
/api/queryand/api/selection) to incorporate RAG context
4. Configuration & Security
- Centralized configuration management with proper environment variable handling
- Fixed undefined variable issues in services
What Is Left
1. Testing & Verification
- Test complete RAG flow to verify Agent uses Qdrant context properly
- Verify responses include context from uploaded documents
- Confirm sources field is populated with document references
2. Documentation & History
- Create PHR for RAG integration work
- Finalize commit with all changes
API Endpoints
GET /- Health check endpointPOST /api/query- General chat queries with RAG contextPOST /api/selection- Queries based on selected text with RAG context
Setup
- Install dependencies:
uv pip install -r requirements.txt - Set up environment variables in
.env:QDRANT_URL=your_qdrant_url QDRANT_API_KEY=your_qdrant_api_key EXTERNAL_API_KEY=your_external_api_key - Index documents:
python services/indexer.py - Start server:
uv run --no-dev uvicorn main:app --reload --port=8000