mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 04:31:02 +02:00
Phase 3 tokens
This commit is contained in:
parent
5a885708df
commit
15d54bfba8
9 changed files with 99 additions and 25 deletions
|
|
@ -20,6 +20,7 @@ import textwrap
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
|
|
||||||
def set_mcp_tool(
|
def set_mcp_tool(
|
||||||
url : str,
|
url : str,
|
||||||
|
|
@ -27,9 +28,10 @@ def set_mcp_tool(
|
||||||
remote_name : str,
|
remote_name : str,
|
||||||
tool_url : str,
|
tool_url : str,
|
||||||
auth_token : str = None,
|
auth_token : str = None,
|
||||||
|
token : str = None,
|
||||||
):
|
):
|
||||||
|
|
||||||
api = Api(url).config()
|
api = Api(url, token=token).config()
|
||||||
|
|
||||||
# Build the MCP tool configuration
|
# Build the MCP tool configuration
|
||||||
config = {
|
config = {
|
||||||
|
|
@ -72,6 +74,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-i', '--id',
|
'-i', '--id',
|
||||||
required=True,
|
required=True,
|
||||||
|
|
@ -116,7 +124,8 @@ def main():
|
||||||
id=args.id,
|
id=args.id,
|
||||||
remote_name=remote_name,
|
remote_name=remote_name,
|
||||||
tool_url=args.tool_url,
|
tool_url=args.tool_url,
|
||||||
auth_token=args.auth_token
|
auth_token=args.auth_token,
|
||||||
|
token=args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,11 @@ from trustgraph.api import Api, ConfigKey
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
|
|
||||||
def show_cores(url, user):
|
def show_cores(url, user, token=None):
|
||||||
|
|
||||||
api = Api(url).knowledge()
|
api = Api(url, token=token).knowledge()
|
||||||
|
|
||||||
ids = api.list_kg_cores()
|
ids = api.list_kg_cores()
|
||||||
|
|
||||||
|
|
@ -35,6 +36,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-U', '--user',
|
'-U', '--user',
|
||||||
default="trustgraph",
|
default="trustgraph",
|
||||||
|
|
@ -46,7 +53,9 @@ def main():
|
||||||
try:
|
try:
|
||||||
|
|
||||||
show_cores(
|
show_cores(
|
||||||
url=args.api_url, user=args.user
|
url=args.api_url,
|
||||||
|
user=args.user,
|
||||||
|
token=args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,12 @@ from trustgraph.api import Api, ConfigKey
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
default_user = "trustgraph"
|
default_user = "trustgraph"
|
||||||
|
|
||||||
def show_docs(url, user):
|
def show_docs(url, user, token=None):
|
||||||
|
|
||||||
api = Api(url).library()
|
api = Api(url, token=token).library()
|
||||||
|
|
||||||
docs = api.get_documents(user=user)
|
docs = api.get_documents(user=user)
|
||||||
|
|
||||||
|
|
@ -52,6 +53,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-U', '--user',
|
'-U', '--user',
|
||||||
default=default_user,
|
default=default_user,
|
||||||
|
|
@ -63,7 +70,9 @@ def main():
|
||||||
try:
|
try:
|
||||||
|
|
||||||
show_docs(
|
show_docs(
|
||||||
url = args.api_url, user = args.user
|
url = args.api_url,
|
||||||
|
user = args.user,
|
||||||
|
token = args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ import tabulate
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
|
|
||||||
def show_config(url):
|
def show_config(url, token=None):
|
||||||
|
|
||||||
api = Api(url).config()
|
api = Api(url, token=token).config()
|
||||||
|
|
||||||
values = api.get_values(type="mcp")
|
values = api.get_values(type="mcp")
|
||||||
|
|
||||||
|
|
@ -57,12 +58,19 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
show_config(
|
show_config(
|
||||||
url=args.api_url,
|
url=args.api_url,
|
||||||
|
token=args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ from trustgraph.api import Api, ConfigKey
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
|
|
||||||
def format_enum_values(enum_list):
|
def format_enum_values(enum_list):
|
||||||
"""
|
"""
|
||||||
|
|
@ -75,11 +76,11 @@ def format_constraints(param_type_def):
|
||||||
|
|
||||||
return ", ".join(constraints) if constraints else "None"
|
return ", ".join(constraints) if constraints else "None"
|
||||||
|
|
||||||
def show_parameter_types(url):
|
def show_parameter_types(url, token=None):
|
||||||
"""
|
"""
|
||||||
Show all parameter type definitions
|
Show all parameter type definitions
|
||||||
"""
|
"""
|
||||||
api = Api(url)
|
api = Api(url, token=token)
|
||||||
config_api = api.config()
|
config_api = api.config()
|
||||||
|
|
||||||
# Get list of all parameter types
|
# Get list of all parameter types
|
||||||
|
|
@ -145,6 +146,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t', '--type',
|
'-t', '--type',
|
||||||
help='Show only the specified parameter type',
|
help='Show only the specified parameter type',
|
||||||
|
|
@ -155,19 +162,19 @@ def main():
|
||||||
try:
|
try:
|
||||||
if args.type:
|
if args.type:
|
||||||
# Show specific parameter type
|
# Show specific parameter type
|
||||||
show_specific_parameter_type(args.api_url, args.type)
|
show_specific_parameter_type(args.api_url, args.type, args.token)
|
||||||
else:
|
else:
|
||||||
# Show all parameter types
|
# Show all parameter types
|
||||||
show_parameter_types(args.api_url)
|
show_parameter_types(args.api_url, args.token)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception:", e, flush=True)
|
print("Exception:", e, flush=True)
|
||||||
|
|
||||||
def show_specific_parameter_type(url, param_type_name):
|
def show_specific_parameter_type(url, param_type_name, token=None):
|
||||||
"""
|
"""
|
||||||
Show a specific parameter type definition
|
Show a specific parameter type definition
|
||||||
"""
|
"""
|
||||||
api = Api(url)
|
api = Api(url, token=token)
|
||||||
config_api = api.config()
|
config_api = api.config()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ import tabulate
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
|
|
||||||
def show_config(url):
|
def show_config(url, token=None):
|
||||||
|
|
||||||
api = Api(url).config()
|
api = Api(url, token=token).config()
|
||||||
|
|
||||||
values = api.get([
|
values = api.get([
|
||||||
ConfigKey(type="prompt", key="system"),
|
ConfigKey(type="prompt", key="system"),
|
||||||
|
|
@ -78,12 +79,19 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
show_config(
|
show_config(
|
||||||
url=args.api_url,
|
url=args.api_url,
|
||||||
|
token=args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@ from trustgraph.api import Api, ConfigKey
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
default_user = "trustgraph"
|
default_user = "trustgraph"
|
||||||
|
|
||||||
def start_processing(
|
def start_processing(
|
||||||
url, user, document_id, id, flow, collection, tags
|
url, user, document_id, id, flow, collection, tags, token=None
|
||||||
):
|
):
|
||||||
|
|
||||||
api = Api(url).library()
|
api = Api(url, token=token).library()
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
tags = tags.split(",")
|
tags = tags.split(",")
|
||||||
|
|
@ -44,6 +45,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-U', '--user',
|
'-U', '--user',
|
||||||
default=default_user,
|
default=default_user,
|
||||||
|
|
@ -90,7 +97,8 @@ def main():
|
||||||
id = args.id,
|
id = args.id,
|
||||||
flow = args.flow_id,
|
flow = args.flow_id,
|
||||||
collection = args.collection,
|
collection = args.collection,
|
||||||
tags = args.tags
|
tags = args.tags,
|
||||||
|
token = args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,14 @@ from trustgraph.api import Api, ConfigKey
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
default_user = "trustgraph"
|
default_user = "trustgraph"
|
||||||
|
|
||||||
def stop_processing(
|
def stop_processing(
|
||||||
url, user, id
|
url, user, id, token=None
|
||||||
):
|
):
|
||||||
|
|
||||||
api = Api(url).library()
|
api = Api(url, token=token).library()
|
||||||
|
|
||||||
api.stop_processing(user = user, id = id)
|
api.stop_processing(user = user, id = id)
|
||||||
|
|
||||||
|
|
@ -33,6 +34,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-U', '--user',
|
'-U', '--user',
|
||||||
default=default_user,
|
default=default_user,
|
||||||
|
|
@ -53,6 +60,7 @@ def main():
|
||||||
url = args.api_url,
|
url = args.api_url,
|
||||||
user = args.user,
|
user = args.user,
|
||||||
id = args.id,
|
id = args.id,
|
||||||
|
token = args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,13 @@ from trustgraph.api import Api
|
||||||
import json
|
import json
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||||
default_flow = "default"
|
default_flow = "default"
|
||||||
default_collection = "default"
|
default_collection = "default"
|
||||||
|
|
||||||
def unload_kg_core(url, user, id, flow):
|
def unload_kg_core(url, user, id, flow, token=None):
|
||||||
|
|
||||||
api = Api(url).knowledge()
|
api = Api(url, token=token).knowledge()
|
||||||
|
|
||||||
class_names = api.unload_kg_core(user = user, id = id, flow=flow)
|
class_names = api.unload_kg_core(user = user, id = id, flow=flow)
|
||||||
|
|
||||||
|
|
@ -33,6 +34,12 @@ def main():
|
||||||
help=f'API URL (default: {default_url})',
|
help=f'API URL (default: {default_url})',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'-t', '--token',
|
||||||
|
default=default_token,
|
||||||
|
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-U', '--user',
|
'-U', '--user',
|
||||||
default="trustgraph",
|
default="trustgraph",
|
||||||
|
|
@ -60,6 +67,7 @@ def main():
|
||||||
user=args.user,
|
user=args.user,
|
||||||
id=args.id,
|
id=args.id,
|
||||||
flow=args.flow_id,
|
flow=args.flow_id,
|
||||||
|
token=args.token,
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue