AI-powered expert assistant for TopicLab-CLI
An intelligent assistant designed for topiclab-cli --ask that provides instant, command-first answers.
Quick Start β’ Documentation β’ API Reference β’ Examples
TopicLab-Agent is an intelligent assistant designed to answer questions from topiclab-cli --ask. It provides direct, actionable topiclab commands based on TopicLab Skill documentation and source code analysis.
Perfect companion for TopicLab-CLI π€
- π― Single-turn Responses - Complete answers in one shot, no back-and-forth
- β‘ Command-first - Direct topiclab-cli commands, no fluff
- π Knowledge-powered - Based on Skill docs + TopicLab-CLI source code
- π Auto-updating - Refreshes Skill documentation every 3 hours
- π API-ready - RESTful & OpenAI-compatible endpoints
- π€ Agent-based - Built with LangChain & LangGraph
- πΎ Database Logging - Automatic request/response logging (SQLite by default)
- Python 3.12+
- API keys (automatically configured in environment)
Note: Database logging uses SQLite by default (stored in
data/topiclab.db). No additional setup required!
# Clone the repository
git clone https://github.com/TashanGKD/TopicLab-Agent.git
cd TopicLab-Agent
# Install dependencies
pip install -r requirements.txt# Method 1: Direct start
python src/main.py
# Method 2: Using script
./scripts/start_service.shService will be available at: http://localhost:8000
Note: Request logs are automatically stored in
data/topiclab.db(SQLite). No database setup required!
# Using curl
curl -X POST http://localhost:8000/run \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"type": "human", "content": "How to initialize topiclab-cli?"}
]
}'
# Using Python client
python scripts/api_client.py "How to initialize topiclab-cli?"- API Usage Guide - Complete API documentation
- Database Logging - Request logging and analytics
- TopicLab-CLI - Official CLI tool
| Endpoint | Method | Description |
|---|---|---|
/run |
POST | Synchronous call (recommended) |
/stream |
POST | Streaming call (SSE) |
/v1/chat/completions |
POST | OpenAI-compatible interface |
/logs |
GET | Retrieve request logs from database |
/docs |
GET | Interactive API documentation |
Python Example
from scripts.api_client import ask_question
# Ask a question
result = ask_question("How to initialize topiclab-cli?")
print(result["answer"])
# Output: topiclab session ensure --base-url https://world.tashan.chat --bind-key <YOUR_KEY> --jsonJavaScript/TypeScript Example
const response = await fetch('http://localhost:8000/run', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [{type: 'human', content: 'Show notifications'}]
})
});
const result = await response.json();
console.log(result.messages[result.messages.length - 1].content);
// Output: topiclab notifications list --jsoncURL Example
# Synchronous call
curl -X POST http://localhost:8000/run \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"type": "human", "content": "Check twin info"}
]
}'
# OpenAI-compatible interface
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "topiclab-agent",
"messages": [
{"role": "user", "content": "Start a discussion"}
],
"stream": false
}'TopicLab-Agent/
βββ config/ # Configuration files
β βββ agent_llm_config.json
βββ docs/ # Documentation
β βββ API_USAGE.md
βββ scripts/ # Utility scripts
β βββ api_client.py # Python client
β βββ test_api.py # Test script
β βββ start_service.sh # Startup script
βββ src/
β βββ agents/ # Agent implementation
β β βββ agent.py
β βββ tools/ # Custom tools
β β βββ topiclab_skill_tool.py
β βββ main.py # FastAPI server
βββ assets/ # Data and resources
βββ tests/ # Unit tests
βββ requirements.txt # Python dependencies
βββ README.md # This file
- Document Auto-Update: Automatically fetches the latest TopicLab Skill documentation every 3 hours
- Source Code Analysis: Understands topiclab-cli commands from GitHub source code
- Intelligent Retrieval: Uses keyword matching to find relevant information
- Command-First Output: Generates direct, executable topiclab commands
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone the repo
git clone https://github.com/TashanGKD/TopicLab-Agent.git
cd TopicLab-Agent
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run tests
python scripts/test_api.pyThis project is licensed under the MIT License - see the LICENSE file for details.
- TopicLab-CLI - The official CLI tool this agent assists with
- LangChain - Framework for building the agent
- FastAPI - Modern web framework for building APIs
Made with β€οΈ by TashanGKD