Knowledge core CLI (#368)

This commit is contained in:
cybermaggedon 2025-05-07 00:20:59 +01:00 committed by GitHub
parent 807c19fd22
commit 8080b54328
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 330 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import time
from . library import Library
from . flow import Flow
from . config import Config
from . knowledge import Knowledge
from . exceptions import *
from . types import *
@ -39,6 +40,9 @@ class Api:
def config(self):
return Config(api=self)
def knowledge(self):
return Knowledge(api=self)
def request(self, path, request):
url = f"{self.url}{path}"

View file

@ -0,0 +1,41 @@
import json
import base64
from .. knowledge import hash, Uri, Literal
from . types import Triple
def to_value(x):
if x["e"]: return Uri(x["v"])
return Literal(x["v"])
class Knowledge:
def __init__(self, api):
self.api = api
def request(self, request):
return self.api.request(f"knowledge", request)
def list_kg_cores(self, user="trustgraph"):
# The input consists of system and prompt strings
input = {
"operation": "list-kg-cores",
"user": user,
}
return self.request(request = input)["ids"]
def delete_kg_core(self, id, user="trustgraph"):
# The input consists of system and prompt strings
input = {
"operation": "delete-kg-core",
"user": user,
"id": id,
}
self.request(request = input)