trustgraph-base 0.23.1__tar.gz → 1.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/PKG-INFO +7 -7
- trustgraph_base-1.6.4/pyproject.toml +29 -0
- trustgraph_base-1.6.4/trustgraph/api/api.py +74 -0
- trustgraph_base-1.6.4/trustgraph/api/collection.py +98 -0
- trustgraph_base-1.6.4/trustgraph/api/config.py +114 -0
- trustgraph_base-1.6.4/trustgraph/api/exceptions.py +6 -0
- trustgraph_base-1.6.4/trustgraph/api/flow.py +642 -0
- trustgraph_base-1.6.4/trustgraph/api/knowledge.py +67 -0
- trustgraph_base-1.6.4/trustgraph/api/library.py +274 -0
- trustgraph_base-1.6.4/trustgraph/api/types.py +53 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/__init__.py +7 -2
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/agent_client.py +8 -10
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/agent_service.py +6 -2
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/async_processor.py +36 -14
- trustgraph_base-1.6.4/trustgraph/base/cassandra_config.py +134 -0
- trustgraph_base-1.6.4/trustgraph/base/chunking_service.py +62 -0
- trustgraph_base-1.6.4/trustgraph/base/consumer.py +238 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/consumer_spec.py +4 -2
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/document_embeddings_client.py +7 -2
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/document_embeddings_query_service.py +12 -7
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/document_embeddings_store_service.py +6 -1
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/embeddings_service.py +33 -8
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/flow.py +2 -2
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/flow_processor.py +13 -8
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/graph_embeddings_client.py +6 -1
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/graph_embeddings_query_service.py +10 -5
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/graph_embeddings_store_service.py +6 -1
- trustgraph_base-1.6.4/trustgraph/base/llm_service.py +228 -0
- trustgraph-base-0.23.1/trustgraph/base/setting_spec.py → trustgraph_base-1.6.4/trustgraph/base/parameter_spec.py +5 -3
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/producer.py +15 -6
- trustgraph_base-1.6.4/trustgraph/base/prompt_client.py +171 -0
- trustgraph_base-1.6.4/trustgraph/base/publisher.py +123 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/pubsub.py +7 -7
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/request_response_spec.py +13 -7
- trustgraph_base-1.6.4/trustgraph/base/structured_query_client.py +35 -0
- trustgraph_base-1.6.4/trustgraph/base/subscriber.py +286 -0
- trustgraph_base-1.6.4/trustgraph/base/text_completion_client.py +57 -0
- trustgraph_base-1.6.4/trustgraph/base/tool_client.py +40 -0
- trustgraph_base-1.6.4/trustgraph/base/tool_service.py +125 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/triples_query_service.py +10 -5
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/triples_store_service.py +7 -1
- trustgraph_base-1.6.4/trustgraph/base_version.py +1 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/document_embeddings_client.py +1 -1
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/embeddings_client.py +0 -8
- trustgraph_base-1.6.4/trustgraph/clients/llm_client.py +105 -0
- trustgraph_base-1.6.4/trustgraph/messaging/__init__.py +147 -0
- trustgraph_base-1.6.4/trustgraph/messaging/registry.py +51 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/__init__.py +21 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/agent.py +70 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/base.py +43 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/collection.py +114 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/config.py +101 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/diagnosis.py +67 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/document_loading.py +191 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/embeddings.py +33 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/embeddings_query.py +94 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/flow.py +64 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/knowledge.py +183 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/library.py +124 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/metadata.py +81 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/nlp_query.py +47 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/objects_query.py +79 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/primitives.py +140 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/prompt.py +57 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/retrieval.py +125 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/structured_query.py +60 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/text_completion.py +45 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/tool.py +51 -0
- trustgraph_base-1.6.4/trustgraph/messaging/translators/triples.py +60 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/rdf.py +1 -0
- trustgraph_base-1.6.4/trustgraph/schema/__init__.py +10 -0
- trustgraph_base-1.6.4/trustgraph/schema/core/__init__.py +3 -0
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/core}/metadata.py +1 -1
- trustgraph-base-0.23.1/trustgraph/schema/types.py → trustgraph_base-1.6.4/trustgraph/schema/core/primitives.py +5 -1
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/__init__.py +8 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/document.py +29 -0
- trustgraph-base-0.23.1/trustgraph/schema/graph.py → trustgraph_base-1.6.4/trustgraph/schema/knowledge/embeddings.py +26 -41
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/graph.py +28 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/knowledge.py +61 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/nlp.py +26 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/object.py +17 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/rows.py +16 -0
- trustgraph_base-1.6.4/trustgraph/schema/knowledge/structured.py +17 -0
- trustgraph_base-1.6.4/trustgraph/schema/services/__init__.py +15 -0
- trustgraph_base-1.6.4/trustgraph/schema/services/agent.py +40 -0
- trustgraph_base-1.6.4/trustgraph/schema/services/collection.py +59 -0
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/services}/config.py +2 -2
- trustgraph_base-1.6.4/trustgraph/schema/services/diagnosis.py +33 -0
- trustgraph-base-0.23.1/trustgraph/schema/flows.py → trustgraph_base-1.6.4/trustgraph/schema/services/flow.py +8 -2
- trustgraph_base-1.6.4/trustgraph/schema/services/library.py +125 -0
- trustgraph-base-0.23.1/trustgraph/schema/models.py → trustgraph_base-1.6.4/trustgraph/schema/services/llm.py +24 -3
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/services}/lookup.py +3 -3
- trustgraph_base-1.6.4/trustgraph/schema/services/nlp_query.py +21 -0
- trustgraph_base-1.6.4/trustgraph/schema/services/objects_query.py +28 -0
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/services}/prompt.py +9 -24
- trustgraph_base-1.6.4/trustgraph/schema/services/query.py +55 -0
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/services}/retrieval.py +8 -2
- trustgraph_base-1.6.4/trustgraph/schema/services/storage.py +42 -0
- trustgraph_base-1.6.4/trustgraph/schema/services/structured_query.py +20 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph_base.egg-info/PKG-INFO +7 -7
- trustgraph_base-1.6.4/trustgraph_base.egg-info/SOURCES.txt +133 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph_base.egg-info/requires.txt +2 -1
- trustgraph-base-0.23.1/setup.py +0 -42
- trustgraph-base-0.23.1/trustgraph/api/api.py +0 -794
- trustgraph-base-0.23.1/trustgraph/base/consumer.py +0 -197
- trustgraph-base-0.23.1/trustgraph/base/llm_service.py +0 -114
- trustgraph-base-0.23.1/trustgraph/base/prompt_client.py +0 -93
- trustgraph-base-0.23.1/trustgraph/base/publisher.py +0 -65
- trustgraph-base-0.23.1/trustgraph/base/subscriber.py +0 -156
- trustgraph-base-0.23.1/trustgraph/base/text_completion_client.py +0 -30
- trustgraph-base-0.23.1/trustgraph/base_version.py +0 -1
- trustgraph-base-0.23.1/trustgraph/clients/llm_client.py +0 -44
- trustgraph-base-0.23.1/trustgraph/schema/__init__.py +0 -16
- trustgraph-base-0.23.1/trustgraph/schema/agent.py +0 -30
- trustgraph-base-0.23.1/trustgraph/schema/documents.py +0 -56
- trustgraph-base-0.23.1/trustgraph/schema/library.py +0 -74
- trustgraph-base-0.23.1/trustgraph/schema/object.py +0 -31
- trustgraph-base-0.23.1/trustgraph_base.egg-info/SOURCES.txt +0 -82
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/README.md +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/setup.cfg +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/api/__init__.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/metrics.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/spec.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/base/triples_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/__init__.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/agent_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/base.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/config_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/prompt_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/exceptions.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/document.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/log_level.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/objects/__init__.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/objects/field.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph/objects/object.py +0 -0
- {trustgraph-base-0.23.1/trustgraph/schema → trustgraph_base-1.6.4/trustgraph/schema/core}/topic.py +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph-base-0.23.1 → trustgraph_base-1.6.4}/trustgraph_base.egg-info/top_level.txt +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-base
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.6.4
|
|
4
4
|
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Author: trustgraph.ai
|
|
8
|
-
Author-email: security@trustgraph.ai
|
|
5
|
+
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
|
6
|
+
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
|
9
7
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
8
|
Classifier: Operating System :: OS Independent
|
|
12
9
|
Requires-Python: >=3.8
|
|
13
10
|
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: pulsar-client
|
|
12
|
+
Requires-Dist: prometheus-client
|
|
13
|
+
Requires-Dist: requests
|
|
14
14
|
|
|
15
15
|
See https://trustgraph.ai/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "trustgraph-base"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
authors = [{name = "trustgraph.ai", email = "security@trustgraph.ai"}]
|
|
9
|
+
description = "TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline."
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"pulsar-client",
|
|
14
|
+
"prometheus-client",
|
|
15
|
+
"requests",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/trustgraph-ai/trustgraph"
|
|
24
|
+
|
|
25
|
+
[tool.setuptools.packages.find]
|
|
26
|
+
include = ["trustgraph*"]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.dynamic]
|
|
29
|
+
version = {attr = "trustgraph.base_version.__version__"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import requests
|
|
3
|
+
import json
|
|
4
|
+
import base64
|
|
5
|
+
import time
|
|
6
|
+
|
|
7
|
+
from . library import Library
|
|
8
|
+
from . flow import Flow
|
|
9
|
+
from . config import Config
|
|
10
|
+
from . knowledge import Knowledge
|
|
11
|
+
from . collection import Collection
|
|
12
|
+
from . exceptions import *
|
|
13
|
+
from . types import *
|
|
14
|
+
|
|
15
|
+
def check_error(response):
|
|
16
|
+
|
|
17
|
+
if "error" in response:
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
msg = response["error"]["message"]
|
|
21
|
+
tp = response["error"]["type"]
|
|
22
|
+
except:
|
|
23
|
+
raise ApplicationException(response["error"])
|
|
24
|
+
|
|
25
|
+
raise ApplicationException(f"{tp}: {msg}")
|
|
26
|
+
|
|
27
|
+
class Api:
|
|
28
|
+
|
|
29
|
+
def __init__(self, url="http://localhost:8088/", timeout=60):
|
|
30
|
+
|
|
31
|
+
self.url = url
|
|
32
|
+
|
|
33
|
+
if not url.endswith("/"):
|
|
34
|
+
self.url += "/"
|
|
35
|
+
|
|
36
|
+
self.url += "api/v1/"
|
|
37
|
+
|
|
38
|
+
self.timeout = timeout
|
|
39
|
+
|
|
40
|
+
def flow(self):
|
|
41
|
+
return Flow(api=self)
|
|
42
|
+
|
|
43
|
+
def config(self):
|
|
44
|
+
return Config(api=self)
|
|
45
|
+
|
|
46
|
+
def knowledge(self):
|
|
47
|
+
return Knowledge(api=self)
|
|
48
|
+
|
|
49
|
+
def request(self, path, request):
|
|
50
|
+
|
|
51
|
+
url = f"{self.url}{path}"
|
|
52
|
+
|
|
53
|
+
# Invoke the API, input is passed as JSON
|
|
54
|
+
resp = requests.post(url, json=request, timeout=self.timeout)
|
|
55
|
+
|
|
56
|
+
# Should be a 200 status code
|
|
57
|
+
if resp.status_code != 200:
|
|
58
|
+
raise ProtocolException(f"Status code {resp.status_code}")
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
# Parse the response as JSON
|
|
62
|
+
object = resp.json()
|
|
63
|
+
except:
|
|
64
|
+
raise ProtocolException(f"Expected JSON response")
|
|
65
|
+
|
|
66
|
+
check_error(object)
|
|
67
|
+
|
|
68
|
+
return object
|
|
69
|
+
|
|
70
|
+
def library(self):
|
|
71
|
+
return Library(self)
|
|
72
|
+
|
|
73
|
+
def collection(self):
|
|
74
|
+
return Collection(self)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from . types import CollectionMetadata
|
|
5
|
+
from . exceptions import *
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class Collection:
|
|
10
|
+
|
|
11
|
+
def __init__(self, api):
|
|
12
|
+
self.api = api
|
|
13
|
+
|
|
14
|
+
def request(self, request):
|
|
15
|
+
return self.api.request(f"collection-management", request)
|
|
16
|
+
|
|
17
|
+
def list_collections(self, user, tag_filter=None):
|
|
18
|
+
|
|
19
|
+
input = {
|
|
20
|
+
"operation": "list-collections",
|
|
21
|
+
"user": user,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if tag_filter:
|
|
25
|
+
input["tag_filter"] = tag_filter
|
|
26
|
+
|
|
27
|
+
object = self.request(input)
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
# Handle case where collections might be None or missing
|
|
31
|
+
if object is None or "collections" not in object:
|
|
32
|
+
return []
|
|
33
|
+
|
|
34
|
+
collections = object.get("collections", [])
|
|
35
|
+
if collections is None:
|
|
36
|
+
return []
|
|
37
|
+
|
|
38
|
+
return [
|
|
39
|
+
CollectionMetadata(
|
|
40
|
+
user = v["user"],
|
|
41
|
+
collection = v["collection"],
|
|
42
|
+
name = v["name"],
|
|
43
|
+
description = v["description"],
|
|
44
|
+
tags = v["tags"],
|
|
45
|
+
created_at = v["created_at"],
|
|
46
|
+
updated_at = v["updated_at"]
|
|
47
|
+
)
|
|
48
|
+
for v in collections
|
|
49
|
+
]
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logger.error("Failed to parse collection list response", exc_info=True)
|
|
52
|
+
raise ProtocolException(f"Response not formatted correctly")
|
|
53
|
+
|
|
54
|
+
def update_collection(self, user, collection, name=None, description=None, tags=None):
|
|
55
|
+
|
|
56
|
+
input = {
|
|
57
|
+
"operation": "update-collection",
|
|
58
|
+
"user": user,
|
|
59
|
+
"collection": collection,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if name is not None:
|
|
63
|
+
input["name"] = name
|
|
64
|
+
if description is not None:
|
|
65
|
+
input["description"] = description
|
|
66
|
+
if tags is not None:
|
|
67
|
+
input["tags"] = tags
|
|
68
|
+
|
|
69
|
+
object = self.request(input)
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
if "collections" in object and object["collections"]:
|
|
73
|
+
v = object["collections"][0]
|
|
74
|
+
return CollectionMetadata(
|
|
75
|
+
user = v["user"],
|
|
76
|
+
collection = v["collection"],
|
|
77
|
+
name = v["name"],
|
|
78
|
+
description = v["description"],
|
|
79
|
+
tags = v["tags"],
|
|
80
|
+
created_at = v["created_at"],
|
|
81
|
+
updated_at = v["updated_at"]
|
|
82
|
+
)
|
|
83
|
+
return None
|
|
84
|
+
except Exception as e:
|
|
85
|
+
logger.error("Failed to parse collection update response", exc_info=True)
|
|
86
|
+
raise ProtocolException(f"Response not formatted correctly")
|
|
87
|
+
|
|
88
|
+
def delete_collection(self, user, collection):
|
|
89
|
+
|
|
90
|
+
input = {
|
|
91
|
+
"operation": "delete-collection",
|
|
92
|
+
"user": user,
|
|
93
|
+
"collection": collection,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
object = self.request(input)
|
|
97
|
+
|
|
98
|
+
return {}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from . exceptions import *
|
|
5
|
+
from . types import ConfigValue
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
class Config:
|
|
10
|
+
|
|
11
|
+
def __init__(self, api):
|
|
12
|
+
self.api = api
|
|
13
|
+
|
|
14
|
+
def request(self, request):
|
|
15
|
+
return self.api.request("config", request)
|
|
16
|
+
|
|
17
|
+
def get(self, keys):
|
|
18
|
+
|
|
19
|
+
# The input consists of system and prompt strings
|
|
20
|
+
input = {
|
|
21
|
+
"operation": "get",
|
|
22
|
+
"keys": [
|
|
23
|
+
{ "type": k.type, "key": k.key }
|
|
24
|
+
for k in keys
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
object = self.request(input)
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
return [
|
|
32
|
+
ConfigValue(
|
|
33
|
+
type = v["type"],
|
|
34
|
+
key = v["key"],
|
|
35
|
+
value = v["value"]
|
|
36
|
+
)
|
|
37
|
+
for v in object["values"]
|
|
38
|
+
]
|
|
39
|
+
except Exception as e:
|
|
40
|
+
logger.error("Failed to parse config get response", exc_info=True)
|
|
41
|
+
raise ProtocolException("Response not formatted correctly")
|
|
42
|
+
|
|
43
|
+
def put(self, values):
|
|
44
|
+
|
|
45
|
+
# The input consists of system and prompt strings
|
|
46
|
+
input = {
|
|
47
|
+
"operation": "put",
|
|
48
|
+
"values": [
|
|
49
|
+
{ "type": v.type, "key": v.key, "value": v.value }
|
|
50
|
+
for v in values
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
self.request(input)
|
|
55
|
+
|
|
56
|
+
def delete(self, keys):
|
|
57
|
+
|
|
58
|
+
# The input consists of system and prompt strings
|
|
59
|
+
input = {
|
|
60
|
+
"operation": "delete",
|
|
61
|
+
"keys": [
|
|
62
|
+
{ "type": v.type, "key": v.key }
|
|
63
|
+
for v in keys
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
self.request(input)
|
|
68
|
+
|
|
69
|
+
def list(self, type):
|
|
70
|
+
|
|
71
|
+
# The input consists of system and prompt strings
|
|
72
|
+
input = {
|
|
73
|
+
"operation": "list",
|
|
74
|
+
"type": type,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return self.request(input)["directory"]
|
|
78
|
+
|
|
79
|
+
def get_values(self, type):
|
|
80
|
+
|
|
81
|
+
# The input consists of system and prompt strings
|
|
82
|
+
input = {
|
|
83
|
+
"operation": "getvalues",
|
|
84
|
+
"type": type,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
object = self.request(input)
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
return [
|
|
91
|
+
ConfigValue(
|
|
92
|
+
type = v["type"],
|
|
93
|
+
key = v["key"],
|
|
94
|
+
value = v["value"]
|
|
95
|
+
)
|
|
96
|
+
for v in object["values"]
|
|
97
|
+
]
|
|
98
|
+
except:
|
|
99
|
+
raise ProtocolException(f"Response not formatted correctly")
|
|
100
|
+
|
|
101
|
+
def all(self):
|
|
102
|
+
|
|
103
|
+
# The input consists of system and prompt strings
|
|
104
|
+
input = {
|
|
105
|
+
"operation": "config"
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
object = self.request(input)
|
|
109
|
+
|
|
110
|
+
try:
|
|
111
|
+
return object["config"], object["version"]
|
|
112
|
+
except:
|
|
113
|
+
raise ProtocolException(f"Response not formatted correctly")
|
|
114
|
+
|