mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 00:46:22 +02:00
Knowledge core CLI (#368)
This commit is contained in:
parent
807c19fd22
commit
8080b54328
7 changed files with 330 additions and 0 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
41
trustgraph-base/trustgraph/api/knowledge.py
Normal file
41
trustgraph-base/trustgraph/api/knowledge.py
Normal 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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue