Skip to main content

Getting Started

The quickest method of interacting with TrustGraph while running is the TrustGraph CLI. To install the CLI:

pip3 install trustgraph-cli==<desired-version>
note

It's best to match the TrustGraph CLI version to the TrustGraph version being deployed.

Below is a list of TrustGraph CLI commands:

  • tg-graph-show
  • tg-graph-to-turtle
  • tg-init-pulsar
  • tg-invoke-agent
  • tg-invoke-document-rag
  • tg-invoke-graph-rag
  • tg-invoke-llm
  • tg-invoke-prompt
  • tg-load-pdf
  • tg-load-text
  • tg-load-turtle
  • tg-processor-state

Pulsar Management​

tg-init-pulsar​

tg-init-pulsar --help
usage: tg-init-pulsar [-h] [-p PULSAR_ADMIN_URL]

Initialises Pulsar with Trustgraph tenant / namespaces & policy

options:
-h, --help show this help message and exit
-p PULSAR_ADMIN_URL, --pulsar-admin-url PULSAR_ADMIN_URL
Pulsar admin URL (default: http://pulsar:8080)

TrustGraph Services State​

tg-processor-state​

tg-processor-state --help
usage: tg-processor-state [-h] [-p PROMETHEUS_URL]

Dump out TrustGraph processor states.

options:
-h, --help show this help message and exit
-p PROMETHEUS_URL, --prometheus-url PROMETHEUS_URL
Prometheus URL (default: http://localhost:9090)

Document Loaders​

tg-load-pdf​

tg-load-pdf --help
usage: tg-load-pdf [-h] [-u URL] [-U USER] [-C COLLECTION] [--name NAME] [--description DESCRIPTION] [--copyright-notice COPYRIGHT_NOTICE]
[--copyright-holder COPYRIGHT_HOLDER] [--copyright-year COPYRIGHT_YEAR] [--license LICENSE]
[--publication-organization PUBLICATION_ORGANIZATION] [--publication-description PUBLICATION_DESCRIPTION]
[--publication-date PUBLICATION_DATE] [--document-url DOCUMENT_URL] [--keyword KEYWORD [KEYWORD ...]] [--identifier IDENTIFIER]
files [files ...]

Loads a PDF document into TrustGraph processing.

positional arguments:
files File to load

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)
--name NAME Document name
--description DESCRIPTION
Document description
--copyright-notice COPYRIGHT_NOTICE
Copyright notice
--copyright-holder COPYRIGHT_HOLDER
Copyright holder
--copyright-year COPYRIGHT_YEAR
Copyright year
--license LICENSE Copyright license
--publication-organization PUBLICATION_ORGANIZATION
Publication organization
--publication-description PUBLICATION_DESCRIPTION
Publication description
--publication-date PUBLICATION_DATE
Publication date
--document-url DOCUMENT_URL
Document URL
--keyword KEYWORD [KEYWORD ...]
Keyword
--identifier IDENTIFIER, --id IDENTIFIER
Document ID

tg-load-text​

tg-load-text --help
usage: tg-load-text [-h] [-u URL] [-U USER] [-C COLLECTION] [--name NAME] [--description DESCRIPTION] [--copyright-notice COPYRIGHT_NOTICE]
[--copyright-holder COPYRIGHT_HOLDER] [--copyright-year COPYRIGHT_YEAR] [--license LICENSE]
[--publication-organization PUBLICATION_ORGANIZATION] [--publication-description PUBLICATION_DESCRIPTION]
[--publication-date PUBLICATION_DATE] [--document-url DOCUMENT_URL] [--keyword KEYWORD [KEYWORD ...]] [--identifier IDENTIFIER]
files [files ...]

Loads a text document into TrustGraph processing.

positional arguments:
files File to load

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)
--name NAME Document name
--description DESCRIPTION
Document description
--copyright-notice COPYRIGHT_NOTICE
Copyright notice
--copyright-holder COPYRIGHT_HOLDER
Copyright holder
--copyright-year COPYRIGHT_YEAR
Copyright year
--license LICENSE Copyright license
--publication-organization PUBLICATION_ORGANIZATION
Publication organization
--publication-description PUBLICATION_DESCRIPTION
Publication description
--publication-date PUBLICATION_DATE
Publication date
--document-url DOCUMENT_URL
Document URL
--keyword KEYWORD [KEYWORD ...]
Keyword
--identifier IDENTIFIER, --id IDENTIFIER
Document ID

Knowledge Graph Store​

tg-graph-show​

tg-graph-show --help
usage: tg-graph-show [-h] [-u API_URL] [-U USER] [-C COLLECTION]

Connects to the graph query service and dumps all graph edges.

options:
-h, --help show this help message and exit
-u API_URL, --api-url API_URL
API URL (default: http://localhost:8088/)
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)

tg-graph-to-turtle​

tg-graph-to-turtle --help
usage: tg-graph-to-turtle [-h] [-u API_URL] [-U USER] [-C COLLECTION]

Connects to the graph query service and dumps all graph edges in Turtle format.

options:
-h, --help show this help message and exit
-u API_URL, --api-url API_URL
API URL (default: http://localhost:8088/)
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)

tg-load-turtle​

tg-load-turtle --help
usage: tg-load-turtle [-h] [-p PULSAR_HOST] [-o OUTPUT_QUEUE] [-u USER] [-c COLLECTION] [-l {debug,info,warn,error}] files [files ...]

Loads Graph embeddings into TrustGraph processing.

positional arguments:
files Turtle files to load

options:
-h, --help show this help message and exit
-p PULSAR_HOST, --pulsar-host PULSAR_HOST
Pulsar host (default: pulsar://localhost:6650)
-o OUTPUT_QUEUE, --output-queue OUTPUT_QUEUE
Output queue (default: persistent://tg/flow/triples-store)
-u USER, --user USER User ID (default: trustgraph)
-c COLLECTION, --collection COLLECTION
Collection ID (default: default)
-l {debug,info,warn,error}, --log-level {debug,info,warn,error}
Output queue (default: info)

Prompt Services​

tg-invoke-llm​

tg-invoke-llm --help
usage: tg-invoke-llm [-h] [-u URL] system prompt

Invokes the text completion service by specifying an LLM system prompt and user prompt. Both arguments are required.

positional arguments:
system LLM system prompt e.g. You are a helpful assistant
prompt LLM prompt e.g. What is 2 + 2?

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)

tg-invoke-prompt​

tg-invoke-prompt --help
usage: tg-invoke-prompt [-h] [-u URL] template-id [variable=value ...]

Invokes the LLM prompt service by specifying the prompt template to use and values for the variables in the prompt template. The prompt template is
identified by its template identifier e.g. question, extract-definitions. Template variable values are specified using key=value arguments on the
command line, and these replace {{key}} placeholders in the template.

positional arguments:
template-id Prompt identifier e.g. question, extract-definitions
variable=value Prompt template terms of the form variable=value, can be specified multiple times

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)

RAG Queries​

tg-invoke-document-rag​

tg-invoke-document-rag --help
usage: tg-invoke-document-rag [-h] [-u URL] -q QUESTION [-U USER] [-C COLLECTION]

Uses the GraphRAG service to answer a question

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)
-q QUESTION, --question QUESTION
Question to answer
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)

tg-invoke-graph-rag​

tg-invoke-graph-rag --help
usage: tg-invoke-graph-rag [-h] [-u URL] -q QUESTION [-U USER] [-C COLLECTION]

Uses the GraphRAG service to answer a question

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: http://localhost:8088/)
-q QUESTION, --question QUESTION
Question to answer
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)

Agent Flow​

tg-invoke-agent​

tg-invoke-agent --help
usage: tg-invoke-agent [-h] [-u URL] -q QUESTION [-U USER] [-C COLLECTION] [-l PLAN] [-s STATE] [-v]

Uses the GraphRAG service to answer a question

options:
-h, --help show this help message and exit
-u URL, --url URL API URL (default: ws://localhost:8088/)
-q QUESTION, --question QUESTION
Question to answer
-U USER, --user USER User ID (default: trustgraph)
-C COLLECTION, --collection COLLECTION
Collection ID (default: default)
-l PLAN, --plan PLAN Agent plan (default: unspecified)
-s STATE, --state STATE
Agent initial state (default: unspecified)
-v, --verbose Output thinking/observations