A system that generates personalized scenario-based simulations using AI, featuring:
- Scenario generation using LLMs (Groq or Google Gemini)
- Video generation via HuggingFace fal-ai provider
- Audio narration through HuggingFace Dia-TTS
- Interactive 5-turn simulation flow
- FastAPI Backend: RESTful API with WebSocket support for real-time updates
- Interactive Web UI: Simple frontend for interacting with simulations
- 5-Turn Simulation: Complete simulation flow with state management
- Media Generation: Integration with HuggingFace fal-ai for video and Dia-TTS for audio
- Multiple LLM Support: Works with Groq models and Google Gemini 2.5 Flash
- Diverse Scenarios: Absurd world-threatening crises including humans, animals, and abstract concepts
- Conclusive Endings: Special scenario generation for satisfying final turns
sim-local/
├── api/ # API implementation
│ ├── app.py # FastAPI application
│ └── routes.py # API endpoints
├── models/ # Data models
│ └── simulation.py # Simulation state models
├── services/ # Service layer
│ ├── llm_service.py # LLM interactions
│ ├── media_service.py # Media generation
│ ├── simulation_service.py # Simulation orchestration
│ └── state_service.py # State management
├── prompts/ # Prompt templates
│ └── scenario_generation_prompt.py # Scenario generation prompts
├── ui/ # Frontend
│ └── public/ # Static files
│ └── index.html # Main UI
├── tests/ # Tests
├── .env.example # Environment variables template
├── main.py # Application entry point
├── requirements.txt # Dependencies
└── README.md # This file
-
Clone the repository:
git clone https://github.com/CuriosityQuantified/sim-local.git cd sim-local -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
For the HuggingFace fal-ai text-to-video integration, make sure you have the latest huggingface_hub with all required dependencies:
pip install "huggingface_hub[inference,cli]>=0.21.0" -
Create a
.envfile from the template:cp .env.example .env
-
Update the
.envfile with your API keys:GROQ_API_KEY: Your Groq API key for LLM accessHUGGINGFACE_API_KEY: Your HuggingFace API key for video generation and text-to-speech narrationGOOGLE_API_KEY: Your Google API key for Gemini models (optional)
Start the application with:
python main.pyThe server will start at http://localhost:8000, and you can access the web UI by opening that URL in your browser.
To test the HuggingFace text-to-video integration:
- Ensure your
HUGGINGFACE_API_KEYis set in your.envfile - Run the test script:
python scripts/test_huggingface.py
- Or provide a custom prompt:
python scripts/test_huggingface.py "Generate a video of: A serene beach at sunset with waves gently washing ashore."
To test the HuggingFace fal-ai text-to-video provider with the Wan2.1-T2V-14B model:
- Ensure your
HUGGINGFACE_API_KEYis set in your.envfile - Run the fal-ai test script:
python scripts/test_huggingface_fal.py
- Or provide a custom prompt:
python scripts/test_huggingface_fal.py "Generate a video of: A serene beach at sunset with waves gently washing ashore."
This integration uses the Wan-AI/Wan2.1-T2V-14B model through the fal-ai provider.
To test the HuggingFace Dia-TTS text-to-speech integration:
- Ensure your
HUGGINGFACE_API_KEYis set in your.envfile - Run the test script:
python scripts/test_huggingface_tts.py
- Or provide a custom prompt:
python scripts/test_huggingface_tts.py "Welcome to the interactive simulation. Let's explore a fascinating scenario together!"
POST /api/simulations: Create a new simulationGET /api/simulations/{simulation_id}: Get a simulation by IDPOST /api/simulations/{simulation_id}/respond: Submit a user responseGET /api/simulations: List all simulationsDELETE /api/simulations/{simulation_id}: Delete a simulationWebSocket /api/ws/simulations/{simulation_id}: Real-time updates for a simulation
For development mode with auto-reload:
uvicorn api.app:app --reload --host 0.0.0.0 --port 8000Run tests with:
pytest- Developer mode to display LLM inputs/outputs
- Persistent storage with Redis
- Production deployment to Vercel
- Media storage with Cloudflare R2
- Enhanced critique capabilities for scenario selection
- User authentication and saved simulations
The application supports multiple LLM providers:
By default, the application uses Groq's "qwen-qwq-32b" model. To use Groq:
- Ensure
GROQ_API_KEYis set in your.envfile
The application also supports Google's Gemini 2.5 Flash model. To use Gemini:
- Set
GOOGLE_API_KEYin your.envfile - When the Google API key is provided, Gemini becomes the primary LLM
- If Gemini API calls fail, the application automatically falls back to Groq
For advanced agent capabilities using Google Gemini:
-
Install the Google ADK package:
pip install google-adk
-
Run the Gemini test script:
python tests/test_gemini.py
-
To test with Agent Development Kit integration:
python tests/test_gemini.py --gadk