Base Module Overview
The Base Module provides the primary interface layer for ARKOS, including a FastAPI server with OpenAI-compatible endpoints and an interactive CLI for testing.Core Components
FastAPI Server
OpenAI-compatible
/v1/chat/completions endpoint with streaming supportCLI Interface
Interactive command-line interface for testing and development
OAuth Authentication
Google OAuth integration for per-user tool authentication
Health Monitoring
Health check endpoint for system status
Architecture
FastAPI Server (app.py)
Starting the Server
Endpoints
POST /v1/chat/completions
OpenAI-compatible chat completions endpoint:GET /health
Health check endpoint:Streaming Responses
Startup Initialization
CLI Interface (main_interface.py)
Starting the CLI
Features
- Interactive conversation loop
- Type messages and press Enter to send
- Type
exitorquitto stop - Rich terminal output support (main_interface_rich.py)
Basic Usage
OAuth Authentication (auth.py)
Routes for per-user OAuth authentication:Google Calendar OAuth Flow
- User calls
/auth/google/login?user_id=alice - Redirects to Google OAuth consent screen
- Google redirects to
/auth/google/callback - Token stored in
UserTokenStore - User can now use Google Calendar tools
Configuration
Environment Variables
YAML Configuration
Using the API
Python Client
cURL
Tool System Prompt
Tools are formatted for the system prompt:Error Handling
The server handles common error cases:- Missing LLM server: Health check reports
llm_server: "not_running" - Database errors: Logged with traceback
- Tool auth required: Returns structured error for frontend handling
Deployment
Development
Production with Uvicorn
Shared Server Considerations
On shared servers like MIT SIPB:- Check if LLM server is already running on port 30000
- Use unique ports if running multiple instances
- Coordinate with team on port assignments
Troubleshooting
Connection refused on port 1111
Connection refused on port 1111
Ensure the server is running:
LLM server not responding
LLM server not responding
Check if SGLang is running:
Tool authentication errors
Tool authentication errors
Verify user has connected the service:
Port already in use
Port already in use
Find and kill the process: