README
¶
Agent UI Examples
This directory contains examples of using the Agent SDK with the built-in web UI interface.
Examples
1. Basic Agent with UI (basic_agent_with_ui.go)
A simple example showing how to create an agent with the web UI enabled.
export OPENAI_API_KEY="your-api-key"
go run basic_agent_with_ui.go
Then open http://localhost:8080 in your browser.
2. Advanced Agent with UI (advanced_agent_with_ui.go)
An advanced example featuring:
- Claude (Anthropic) LLM integration
- Custom UI configuration
- Dark theme
- Graceful shutdown handling
export ANTHROPIC_API_KEY="your-api-key"
# Or use OpenAI as fallback:
# export OPENAI_API_KEY="your-api-key"
# Optional: Enable development mode
export DEV_MODE=true
# Optional: Custom port
export PORT=3000
go run advanced_agent_with_ui.go
3. Agent with Redis Memory (agent_with_redis_memory.go)
An agent with Redis-backed persistent memory:
- Redis memory storage (persists across restarts)
- Conversation history browser
- Memory search functionality
- 24-hour conversation retention
- Falls back to local storage if Redis unavailable
export OPENAI_API_KEY="your-api-key"
# Start Redis (if not already running)
docker run -d -p 6379:6379 redis:alpine
# Optional: Custom Redis address
export REDIS_ADDR="localhost:6379"
go run agent_with_redis_memory.go
4. Agent with Buffer Memory (agent_with_buffer_memory.go)
An agent with conversation buffer memory (no Redis required):
- Remembers last 10 messages
- No external dependencies
- Perfect for development/testing
- Shows agent's actual memory in UI
export OPENAI_API_KEY="your-api-key"
go run agent_with_buffer_memory.go
Features
The UI provides:
- Chat Interface: Real-time streaming chat with the agent
- Agent Info Panel: View agent details, model, tools, and system prompt
- Sub-Agents: Manage and delegate to specialized sub-agents
- Memory Browser: View and search conversation history
- Settings: Configure theme and preferences
- API Access: Full REST API for programmatic access
API Endpoints
When the UI server is running, the following endpoints are available:
GET /- Web UI interfaceGET /health- Health checkPOST /api/v1/agent/run- Non-streaming chatPOST /api/v1/agent/stream- SSE streaming chatGET /api/v1/agent/metadata- Agent informationGET /api/v1/agent/config- Detailed configurationGET /api/v1/agent/subagents- List sub-agentsPOST /api/v1/agent/delegate- Delegate to sub-agentGET /api/v1/memory- Browse memoryGET /api/v1/memory/search- Search memoryGET /api/v1/tools- List available toolsWS /ws/chat- WebSocket for real-time chat
Building the UI
The UI is automatically embedded in the Go binary. To update the UI:
- Navigate to the UI directory:
cd pkg/microservice/ui
- Install dependencies:
npm install
- Build the UI:
npm run build
The built files will be embedded in the Go binary on the next go build.
Customization
You can customize the UI by modifying the UIConfig:
uiConfig := µservice.UIConfig{
Enabled: true,
DefaultPath: "/",
DevMode: false,
Theme: "dark", // or "light"
Features: microservice.UIFeatures{
Chat: true,
Memory: true,
AgentInfo: true,
Settings: true,
},
}
Environment Variables
OPENAI_API_KEY- OpenAI API keyANTHROPIC_API_KEY- Anthropic (Claude) API keyPORT- Server port (default: 8080)DEV_MODE- Enable development mode (hot reload)
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.