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:
- Loads the software catalog from
SOFTWARE_CATALOGpath - Embeds all tool descriptions using BGE-M3
- Builds FAISS vector index
- Extracts vocabulary for query expansion
- Saves artifacts to
artifacts/rag_index/
When to use:
- After editing
catalog.jsonl - After adding new tools
- To force index rebuild
- For testing catalog changes
Example:
$ ai_agent sync
[sync] 150 → dataset/catalog.jsonl
[sync] Embedding 150 tools... (5.2s)
[sync] Building FAISS index...
[sync] Saved to artifacts/rag_index/
[sync] Sync complete.
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