CLI Commands¶
The AI Imaging Agent provides a command-line interface for starting the application and managing the software catalog.
Available Commands¶
ai_agent chat¶
Launch the chat-based user interface.
What it does:
- Performs startup catalog synchronization
- Loads the FAISS index
- Initializes the retrieval and agent pipelines
- Launches the Gradio web interface on
http://127.0.0.1:7860 - Starts background catalog refresh (if configured)
Options: None (all configuration via .env and config.yaml)
Example:
$ ai_agent chat
[startup-sync] 150 → dataset/catalog.jsonl
[startup-refresh] catalog unchanged; keeping existing FAISS index
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Background Refresh:
If SYNC_EVERY_HOURS is set in .env, the catalog will auto-refresh in the background:
ai_agent sync¶
Manually synchronize the software catalog and rebuild the index.
What it does:
- Queries the GraphDB SPARQL endpoint (
GRAPHDB_URL) using the configured query file - Saves the raw JSON-LD response to
OUTPUT_JSONLD - Converts JSON-LD to JSONL and saves to
OUTPUT_JSONL - Detects catalog changes via SHA-1 hash
- If changed: embeds all tool descriptions and rebuilds the FAISS index
- Saves index artifacts to
RAG_INDEX_DIR(artifacts/rag_index/by default)
Required environment variables:
GRAPHDB_URL=https://graphdb.example.com/repositories/imaging
GRAPHDB_GRAPH=https://example.org/graph/imaging-tools
GRAPHDB_QUERY_FILE=get_relevant_software.rq
When to use:
- To pull the latest catalog from GraphDB
- To force index rebuild from the remote source
- After graph database updates
Skip freshness check (force sync even if catalog is recent):
Command Aliases¶
Both commands are available with either ai_agent or ai-agent:
Common Usage Patterns¶
Development Workflow¶
<!-- ### Production Deployment
# In your deployment script:
ai_agent sync # Ensure index is built
nohup ai_agent chat & # Run in background
Or use environment variable control:
export SYNC_EVERY_HOURS=0 # Disable auto-refresh in production
ai_agent chat
``` -->
### Testing & Development
```bash
# Enable debug logging
export LOGLEVEL_CONSOLE=DEBUG
export LOG_PROMPTS=1
ai_agent chat
Environment Variables¶
All configuration is via environment variables (see Environment Variables Reference).
Exit Codes¶
- 0: Success
- 1: General error (see logs)
Troubleshooting¶
Command Not Found¶
If you see command not found: ai_agent:
# Ensure package is installed
pip install -e .
# Check installation
pip list | grep ai-agent
# Try with python -m
python -m ai_agent.cli chat
Port Already in Use¶
If port 7860 is occupied:
Catalog Load Error¶
If catalog fails to load:
# Verify catalog exists
ls -lh dataset/catalog.jsonl
# Verify JSONL syntax
python -c "import json; [json.loads(l) for l in open('dataset/catalog.jsonl')]"
# Check environment variable
echo $SOFTWARE_CATALOG
Index Build Error¶
If FAISS index building fails:
# Check artifacts directory
ls -lh artifacts/rag_index/
# Rebuild manually
rm -rf artifacts/rag_index/
ai_agent sync
Next Steps¶
- Configure Environment Variables
- Review the Changelog
- Return to Getting Started