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
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
|
||||
def set_mcp_tool(
|
||||
url : str,
|
||||
|
|
@ -27,9 +28,10 @@ def set_mcp_tool(
|
|||
remote_name : str,
|
||||
tool_url : str,
|
||||
auth_token : str = None,
|
||||
token : str = None,
|
||||
):
|
||||
|
||||
api = Api(url).config()
|
||||
api = Api(url, token=token).config()
|
||||
|
||||
# Build the MCP tool configuration
|
||||
config = {
|
||||
|
|
@ -72,6 +74,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-i', '--id',
|
||||
required=True,
|
||||
|
|
@ -116,7 +124,8 @@ def main():
|
|||
id=args.id,
|
||||
remote_name=remote_name,
|
||||
tool_url=args.tool_url,
|
||||
auth_token=args.auth_token
|
||||
auth_token=args.auth_token,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ from trustgraph.api import Api, ConfigKey
|
|||
import json
|
||||
|
||||
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()
|
||||
|
||||
|
|
@ -35,6 +36,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-U', '--user',
|
||||
default="trustgraph",
|
||||
|
|
@ -46,7 +53,9 @@ def main():
|
|||
try:
|
||||
|
||||
show_cores(
|
||||
url=args.api_url, user=args.user
|
||||
url=args.api_url,
|
||||
user=args.user,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ from trustgraph.api import Api, ConfigKey
|
|||
import json
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
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)
|
||||
|
||||
|
|
@ -52,6 +53,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-U', '--user',
|
||||
default=default_user,
|
||||
|
|
@ -63,7 +70,9 @@ def main():
|
|||
try:
|
||||
|
||||
show_docs(
|
||||
url = args.api_url, user = args.user
|
||||
url = args.api_url,
|
||||
user = args.user,
|
||||
token = args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ import tabulate
|
|||
import textwrap
|
||||
|
||||
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")
|
||||
|
||||
|
|
@ -57,12 +58,19 @@ def main():
|
|||
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()
|
||||
|
||||
try:
|
||||
|
||||
show_config(
|
||||
url=args.api_url,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from trustgraph.api import Api, ConfigKey
|
|||
import json
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
|
||||
def format_enum_values(enum_list):
|
||||
"""
|
||||
|
|
@ -75,11 +76,11 @@ def format_constraints(param_type_def):
|
|||
|
||||
return ", ".join(constraints) if constraints else "None"
|
||||
|
||||
def show_parameter_types(url):
|
||||
def show_parameter_types(url, token=None):
|
||||
"""
|
||||
Show all parameter type definitions
|
||||
"""
|
||||
api = Api(url)
|
||||
api = Api(url, token=token)
|
||||
config_api = api.config()
|
||||
|
||||
# Get list of all parameter types
|
||||
|
|
@ -145,6 +146,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--type',
|
||||
help='Show only the specified parameter type',
|
||||
|
|
@ -155,19 +162,19 @@ def main():
|
|||
try:
|
||||
if args.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:
|
||||
# Show all parameter types
|
||||
show_parameter_types(args.api_url)
|
||||
show_parameter_types(args.api_url, args.token)
|
||||
|
||||
except Exception as e:
|
||||
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
|
||||
"""
|
||||
api = Api(url)
|
||||
api = Api(url, token=token)
|
||||
config_api = api.config()
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ import tabulate
|
|||
import textwrap
|
||||
|
||||
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([
|
||||
ConfigKey(type="prompt", key="system"),
|
||||
|
|
@ -78,12 +79,19 @@ def main():
|
|||
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()
|
||||
|
||||
try:
|
||||
|
||||
show_config(
|
||||
url=args.api_url,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -9,13 +9,14 @@ from trustgraph.api import Api, ConfigKey
|
|||
import json
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
default_user = "trustgraph"
|
||||
|
||||
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:
|
||||
tags = tags.split(",")
|
||||
|
|
@ -44,6 +45,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-U', '--user',
|
||||
default=default_user,
|
||||
|
|
@ -90,7 +97,8 @@ def main():
|
|||
id = args.id,
|
||||
flow = args.flow_id,
|
||||
collection = args.collection,
|
||||
tags = args.tags
|
||||
tags = args.tags,
|
||||
token = args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ from trustgraph.api import Api, ConfigKey
|
|||
import json
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
default_user = "trustgraph"
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -33,6 +34,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-U', '--user',
|
||||
default=default_user,
|
||||
|
|
@ -53,6 +60,7 @@ def main():
|
|||
url = args.api_url,
|
||||
user = args.user,
|
||||
id = args.id,
|
||||
token = args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -11,12 +11,13 @@ from trustgraph.api import Api
|
|||
import json
|
||||
|
||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||
default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
|
||||
default_flow = "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)
|
||||
|
||||
|
|
@ -33,6 +34,12 @@ def main():
|
|||
help=f'API URL (default: {default_url})',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--token',
|
||||
default=default_token,
|
||||
help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'-U', '--user',
|
||||
default="trustgraph",
|
||||
|
|
@ -60,6 +67,7 @@ def main():
|
|||
user=args.user,
|
||||
id=args.id,
|
||||
flow=args.flow_id,
|
||||
token=args.token,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue