ERGS LLM AI Toolkit
The ERGS LLM Toolkit is a powerful integration layer for bringing Large Language Models (LLMs) into the physical escape room environment. It allows AI models to act as immersive NPCs (Non-Player Characters) that can "see" the game state through sensors and "act" upon the room via physical triggers.
Key Features
- Universal API Support: A single parser interface for Ollama (local), Groq (high-speed), Google Gemini, and OpenAI.
- Dynamic Context Injection: Real-time world data (variables, pressures, states) is automatically injected into the AI's "consciousness."
- Action System (Tools): The AI can trigger physical room events (opening doors, activating fog, locking systems) using native Function Calling or a RegEx fallback system.
- Story-Aware Guidance: Integrates with the ERGS Cue System to ensure the AI knows exactly what the players have achieved and what hints are currently relevant.
Component Architecture
1. LLM Model Node
The core processing unit. It handles the REST communication with the AI provider.
- Inputs:
Process(Action),History(Pointer). - Outputs:
Response(Text),Tool(Action Name),Processing(Boolean). - Supported Endpoints: Custom URLs for local Ollama instances or cloud providers.
2. LLM Chat History Node
Manages the conversation buffer.
- Configurable Buffer: Set the number of remembered messages (e.g., last 20 messages) to maintain performance and stay within token limits.
- Role Management: Separates
Userinput fromAssistantresponses.
3. LLM Property Node
Provides "Vision" to the AI. Connect any value from your ERGS graph to this node.
- Description Template: Uses standard formatting (e.g.,
"Current oxygen level is %s percent") to explain the data to the LLM. - Automatic Injection: Values are bundled into the
WORLD STATEsection of the system prompt.
4. LLM Tool Node
Provides "Hands" to the AI.
- Event Dispatcher: When the LLM decides to perform an action, the corresponding
LLM Toolnode fires anonEventaction in the ERGS graph. - Contextual Logic: Each tool has a description, telling the AI when and why it should be used.
Prompt Engineering & Structure
The toolkit uses a structured Multi-Block Prompt strategy to ensure the LLM follows instructions strictly while remaining in character:
- Persona: Defined in the Model Node
Infoproperty (Who is the AI?). - Story Progression (Cues): Injected from the ERGS Cue System (What is happening?).
- World State (Properties): Real-time telemetry from sensors (What does the AI see?).
- Interaction Interface (Tools): Available physical actions (What can the AI do?).
Setup & Configuration
For High-Speed Performance (Groq / Gemini)
- Set the
URLto the provider's completion endpoint. - Provide the
API Key. - Set the
Model Name(e.g.,llama-3.1-8b-instantorgemini-1.5-flash-8b). - The system automatically handles the
AuthorizationorX-goog-api-keyheaders.
For Local Privacy (Ollama)
- Run Ollama locally.
- Set
URLtohttp://localhost:11434/api/. - Ensure
tools supportedis toggled based on the local model's capabilities.
Safety & Best Practices
- Rate Limiting: The system includes a
processinglock to prevent multiple simultaneous requests to the API. - Timeout Handling: Default 45s timeout ensures the game doesn't hang during cloud latency spikes.
- Language Independence: While instructions are sent in English for better model adherence, the AI is instructed to always respond to players in the project's native language.