TrustGraph CLI Documentation
The TrustGraph Command Line Interface (CLI) provides comprehensive command-line access to all TrustGraph services. These tools wrap the REST and WebSocket APIs to provide convenient, scriptable access to TrustGraph functionality.
Installation
The CLI tools are installed as part of the trustgraph-cli
package:
pip install trustgraph-cli
[!NOTE] The CLI version should match the version of TrustGraph being deployed.
Global Options
Most CLI commands support these common options:
-u, --api-url URL
: TrustGraph API URL (default:$TRUSTGRAPH_URL
orhttp://localhost:8088/
)-U, --user USER
: User identifier (default:trustgraph
)-C, --collection COLLECTION
: Collection identifier (default:default
)-f, --flow-id FLOW
: Flow identifier (default:default
)
Command Categories
System Administration & Configuration
System Setup:
tg-init-trustgraph
- Initialize Pulsar with TrustGraph configurationtg-init-pulsar-manager
- Initialize Pulsar manager setuptg-show-config
- Display current system configuration
Token Management:
tg-set-token-costs
- Configure model token coststg-show-token-costs
- Display token cost configurationtg-show-token-rate
- Show token usage rates
Prompt Management:
tg-set-prompt
- Configure prompt templates and system promptstg-show-prompts
- Display configured prompt templates
Flow Management
Flow Operations:
tg-start-flow
- Start a processing flowtg-stop-flow
- Stop a running flowtg-show-flows
- List all configured flowstg-show-flow-state
- Show current flow states
Flow Class Management:
tg-put-flow-class
- Upload/update flow class definitiontg-get-flow-class
- Retrieve flow class definitiontg-delete-flow-class
- Remove flow class definitiontg-show-flow-classes
- List available flow classes
Knowledge Graph Management
Knowledge Core Operations:
tg-load-kg-core
- Load knowledge core into processingtg-put-kg-core
- Store knowledge core in systemtg-get-kg-core
- Retrieve knowledge coretg-delete-kg-core
- Remove knowledge coretg-unload-kg-core
- Unload knowledge core from processingtg-show-kg-cores
- List available knowledge cores
Graph Data Operations:
tg-show-graph
- Display graph triples/edgestg-graph-to-turtle
- Export graph to Turtle formattg-load-turtle
- Import RDF triples from Turtle files
Document Processing & Library Management
Document Loading:
tg-load-pdf
- Load PDF documents into processingtg-load-text
- Load text documents into processingtg-load-sample-documents
- Load sample documents for testing
Library Management:
tg-add-library-document
- Add documents to librarytg-show-library-documents
- List documents in librarytg-remove-library-document
- Remove documents from librarytg-start-library-processing
- Start processing library documentstg-stop-library-processing
- Stop library document processingtg-show-library-processing
- Show library processing status
Document Embeddings:
tg-load-doc-embeds
- Load document embeddingstg-save-doc-embeds
- Save document embeddings
AI Services & Agent Interaction
Query & Interaction:
tg-invoke-agent
- Interactive agent Q&A via WebSockettg-invoke-llm
- Direct LLM text completiontg-invoke-prompt
- Use configured prompt templatestg-invoke-document-rag
- Document-based RAG queriestg-invoke-graph-rag
- Graph-based RAG queries
Tool & Prompt Management:
tg-show-tools
- List available agent toolstg-set-prompt
- Configure prompt templatestg-show-prompts
- List configured prompts
System Monitoring & Debugging
System Status:
tg-show-processor-state
- Show processing component states
Debugging:
tg-dump-msgpack
- Dump MessagePack data for debugging
Quick Start Examples
Basic Document Processing
# Start a flow
tg-start-flow --flow-id my-flow --class-name document-processing
# Load a document
tg-load-text --flow-id my-flow --text "Your document content" --title "Test Document"
# Query the knowledge
tg-invoke-graph-rag --flow-id my-flow --query "What is the document about?"
Knowledge Management
# List available knowledge cores
tg-show-kg-cores
# Load a knowledge core into a flow
tg-load-kg-core --flow-id my-flow --kg-core-id my-knowledge
# Query the knowledge graph
tg-show-graph --limit 100
Flow Management
# Show available flow classes
tg-show-flow-classes
# Show running flows
tg-show-flows
# Stop a flow
tg-stop-flow --flow-id my-flow
Environment Variables
TRUSTGRAPH_URL
: Default API URL for all commandsTRUSTGRAPH_USER
: Default user identifierTRUSTGRAPH_COLLECTION
: Default collection identifier
Authentication
CLI commands inherit authentication from the environment or API configuration. See the main TrustGraph documentation for authentication setup.
Error Handling
All CLI commands provide:
- Consistent error reporting
- Exit codes (0 for success, non-zero for errors)
- Detailed error messages for troubleshooting
- Retry logic for network operations where appropriate
Related Documentation
Table of contents
- tg-add-library-document
- tg-delete-flow-class
- tg-delete-kg-core
- tg-dump-msgpack
- tg-get-flow-class
- tg-get-kg-core
- tg-graph-to-turtle
- tg-init-pulsar-manager
- tg-init-trustgraph
- tg-invoke-agent
- tg-invoke-document-rag
- tg-invoke-graph-rag
- tg-invoke-llm
- tg-invoke-prompt
- tg-load-doc-embeds
- tg-load-kg-core
- tg-load-pdf
- tg-load-sample-documents
- tg-load-text
- tg-load-turtle
- tg-put-flow-class
- tg-put-kg-core
- tg-remove-library-document
- tg-save-doc-embeds
- tg-set-prompt
- tg-set-token-costs
- tg-show-config
- tg-show-flow-classes
- tg-show-flow-state
- tg-show-flows
- tg-show-graph
- tg-show-kg-cores
- tg-show-library-documents
- tg-show-library-processing
- tg-show-processor-state
- tg-show-prompts
- tg-show-token-costs
- tg-show-token-rate
- tg-show-tools
- tg-start-flow
- tg-start-library-processing
- tg-stop-flow
- tg-stop-library-processing
- tg-unload-kg-core