trustgraph-base 0.12.5__tar.gz → 0.13.1__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.
Files changed (49) hide show
  1. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/PKG-INFO +2 -2
  2. trustgraph-base-0.13.1/trustgraph/base_version.py +1 -0
  3. trustgraph-base-0.13.1/trustgraph/knowledge/__init__.py +6 -0
  4. trustgraph-base-0.13.1/trustgraph/knowledge/defs.py +25 -0
  5. trustgraph-base-0.13.1/trustgraph/knowledge/document.py +119 -0
  6. trustgraph-base-0.13.1/trustgraph/knowledge/identifier.py +23 -0
  7. trustgraph-base-0.13.1/trustgraph/knowledge/organization.py +40 -0
  8. trustgraph-base-0.13.1/trustgraph/knowledge/publication.py +70 -0
  9. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/rdf.py +1 -0
  10. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/__init__.py +0 -2
  11. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/graph.py +3 -5
  12. trustgraph-base-0.13.1/trustgraph/schema/metadata.py +16 -0
  13. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/types.py +5 -0
  14. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph_base.egg-info/PKG-INFO +2 -2
  15. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph_base.egg-info/SOURCES.txt +6 -0
  16. trustgraph-base-0.12.5/trustgraph/base_version.py +0 -1
  17. trustgraph-base-0.12.5/trustgraph/schema/metadata.py +0 -10
  18. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/README.md +0 -0
  19. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/setup.cfg +0 -0
  20. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/setup.py +0 -0
  21. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/base/__init__.py +0 -0
  22. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/base/base_processor.py +0 -0
  23. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/base/consumer.py +0 -0
  24. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/base/consumer_producer.py +0 -0
  25. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/base/producer.py +0 -0
  26. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/__init__.py +0 -0
  27. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/base.py +0 -0
  28. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/document_embeddings_client.py +0 -0
  29. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/document_rag_client.py +0 -0
  30. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/embeddings_client.py +0 -0
  31. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/graph_embeddings_client.py +0 -0
  32. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/graph_rag_client.py +0 -0
  33. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/llm_client.py +0 -0
  34. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/prompt_client.py +0 -0
  35. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/clients/triples_query_client.py +0 -0
  36. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/exceptions.py +0 -0
  37. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/log_level.py +0 -0
  38. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/objects/__init__.py +0 -0
  39. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/objects/field.py +0 -0
  40. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/objects/object.py +0 -0
  41. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/documents.py +0 -0
  42. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/models.py +0 -0
  43. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/object.py +0 -0
  44. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/prompt.py +0 -0
  45. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/retrieval.py +0 -0
  46. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph/schema/topic.py +0 -0
  47. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  48. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph_base.egg-info/requires.txt +0 -0
  49. {trustgraph-base-0.12.5 → trustgraph-base-0.13.1}/trustgraph_base.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.12.5
3
+ Version: 0.13.1
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
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
6
  Author: trustgraph.ai
7
7
  Author-email: security@trustgraph.ai
8
8
  License: UNKNOWN
9
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.12.5.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.13.1.tar.gz
10
10
  Platform: UNKNOWN
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -0,0 +1 @@
1
+ __version__ = "0.13.1"
@@ -0,0 +1,6 @@
1
+
2
+ from . identifier import *
3
+ from . publication import *
4
+ from . document import *
5
+ from . organization import *
6
+
@@ -0,0 +1,25 @@
1
+
2
+ IS_A = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
3
+ LABEL = 'http://www.w3.org/2000/01/rdf-schema#label'
4
+
5
+ DIGITAL_DOCUMENT = 'https://schema.org/DigitalDocument'
6
+ PUBLICATION_EVENT = 'https://schema.org/PublicationEvent'
7
+ ORGANIZATION = 'https://schema.org/Organization'
8
+
9
+ NAME = 'https://schema.org/name'
10
+ DESCRIPTION = 'https://schema.org/description'
11
+ COPYRIGHT_NOTICE = 'https://schema.org/copyrightNotice'
12
+ COPYRIGHT_HOLDER = 'https://schema.org/copyrightHolder'
13
+ COPYRIGHT_YEAR = 'https://schema.org/copyrightYear'
14
+ LICENSE = 'https://schema.org/license'
15
+ PUBLICATION = 'https://schema.org/publication'
16
+ START_DATE = 'https://schema.org/startDate'
17
+ END_DATE = 'https://schema.org/endDate'
18
+ PUBLISHED_BY = 'https://schema.org/publishedBy'
19
+ DATE_PUBLISHED = 'https://schema.org/datePublished'
20
+ PUBLICATION = 'https://schema.org/publication'
21
+ DATE_PUBLISHED = 'https://schema.org/datePublished'
22
+ URL = 'https://schema.org/url'
23
+ IDENTIFIER = 'https://schema.org/identifier'
24
+ KEYWORD = 'https://schema.org/keywords'
25
+
@@ -0,0 +1,119 @@
1
+
2
+ from . defs import *
3
+ from .. schema import Triple, Value
4
+
5
+ class DigitalDocument:
6
+ def __init__(
7
+ self, id, name=None, description=None, copyright_notice=None,
8
+ copyright_holder=None, copyright_year=None, license=None,
9
+ identifier=None,
10
+ publication=None, url=None, keywords=[]
11
+ ):
12
+ self.id = id
13
+ self.name = name
14
+ self.description = description
15
+ self.copyright_notice = copyright_notice
16
+ self.copyright_holder = copyright_holder
17
+ self.copyright_year = copyright_year
18
+ self.license = license
19
+ self.publication = publication
20
+ self.url = url
21
+ self.identifier = identifier
22
+ self.keywords = keywords
23
+
24
+ def emit(self, emit):
25
+
26
+ emit(Triple(
27
+ s=Value(value=self.id, is_uri=True),
28
+ p=Value(value=IS_A, is_uri=True),
29
+ o=Value(value=DIGITAL_DOCUMENT, is_uri=True)
30
+ ))
31
+
32
+ if self.name:
33
+
34
+ emit(Triple(
35
+ s=Value(value=self.id, is_uri=True),
36
+ p=Value(value=LABEL, is_uri=True),
37
+ o=Value(value=self.name, is_uri=False)
38
+ ))
39
+
40
+ emit(Triple(
41
+ s=Value(value=self.id, is_uri=True),
42
+ p=Value(value=NAME, is_uri=True),
43
+ o=Value(value=self.name, is_uri=False)
44
+ ))
45
+
46
+ if self.identifier:
47
+
48
+ emit(Triple(
49
+ s=Value(value=id, is_uri=True),
50
+ p=Value(value=IDENTIFIER, is_uri=True),
51
+ o=Value(value=self.identifier, is_uri=False)
52
+ ))
53
+
54
+ if self.description:
55
+
56
+ emit(Triple(
57
+ s=Value(value=self.id, is_uri=True),
58
+ p=Value(value=DESCRIPTION, is_uri=True),
59
+ o=Value(value=self.description, is_uri=False)
60
+ ))
61
+
62
+ if self.copyright_notice:
63
+
64
+ emit(Triple(
65
+ s=Value(value=self.id, is_uri=True),
66
+ p=Value(value=COPYRIGHT_NOTICE, is_uri=True),
67
+ o=Value(value=self.copyright_notice, is_uri=False)
68
+ ))
69
+
70
+ if self.copyright_holder:
71
+
72
+ emit(Triple(
73
+ s=Value(value=self.id, is_uri=True),
74
+ p=Value(value=COPYRIGHT_HOLDER, is_uri=True),
75
+ o=Value(value=self.copyright_holder, is_uri=False)
76
+ ))
77
+
78
+ if self.copyright_year:
79
+
80
+ emit(Triple(
81
+ s=Value(value=self.id, is_uri=True),
82
+ p=Value(value=COPYRIGHT_YEAR, is_uri=True),
83
+ o=Value(value=self.copyright_year, is_uri=False)
84
+ ))
85
+
86
+ if self.license:
87
+
88
+ emit(Triple(
89
+ s=Value(value=self.id, is_uri=True),
90
+ p=Value(value=LICENSE, is_uri=True),
91
+ o=Value(value=self.license, is_uri=False)
92
+ ))
93
+
94
+ if self.keywords:
95
+ for k in self.keywords:
96
+ emit(Triple(
97
+ s=Value(value=self.id, is_uri=True),
98
+ p=Value(value=KEYWORD, is_uri=True),
99
+ o=Value(value=k, is_uri=False)
100
+ ))
101
+
102
+ if self.publication:
103
+
104
+ emit(Triple(
105
+ s=Value(value=self.id, is_uri=True),
106
+ p=Value(value=PUBLICATION, is_uri=True),
107
+ o=Value(value=self.publication.id, is_uri=True)
108
+ ))
109
+
110
+ self.publication.emit(emit)
111
+
112
+ if self.url:
113
+
114
+ emit(Triple(
115
+ s=Value(value=self.id, is_uri=True),
116
+ p=Value(value=URL, is_uri=True),
117
+ o=Value(value=self.url, is_uri=True)
118
+ ))
119
+
@@ -0,0 +1,23 @@
1
+
2
+ import uuid
3
+ import hashlib
4
+
5
+ def hash(data):
6
+
7
+ if isinstance(data, str):
8
+ data = data.encode("utf-8")
9
+
10
+ # Create a SHA256 hash from the data
11
+ id = hashlib.sha256(data).hexdigest()
12
+
13
+ # Convert into a UUID, 64-byte hash becomes 32-byte UUID
14
+ id = str(uuid.UUID(id[::2]))
15
+
16
+ return id
17
+
18
+ def to_uri(pref, id):
19
+ return f"https://trustgraph.ai/{pref}/{id}"
20
+
21
+ PREF_PUBEV = "pubev"
22
+ PREF_ORG = "org"
23
+ PREF_DOC = "doc"
@@ -0,0 +1,40 @@
1
+
2
+ from . defs import *
3
+ from .. schema import Triple, Value
4
+
5
+ class Organization:
6
+ def __init__(self, id, name=None, description=None):
7
+ self.id = id
8
+ self.name = name
9
+ self.description = description
10
+
11
+ def emit(self, emit):
12
+
13
+ emit(Triple(
14
+ s=Value(value=self.id, is_uri=True),
15
+ p=Value(value=IS_A, is_uri=True),
16
+ o=Value(value=ORGANIZATION, is_uri=True)
17
+ ))
18
+
19
+ if self.name:
20
+
21
+ emit(Triple(
22
+ s=Value(value=self.id, is_uri=True),
23
+ p=Value(value=LABEL, is_uri=True),
24
+ o=Value(value=self.name, is_uri=False)
25
+ ))
26
+
27
+ emit(Triple(
28
+ s=Value(value=self.id, is_uri=True),
29
+ p=Value(value=NAME, is_uri=True),
30
+ o=Value(value=self.name, is_uri=False)
31
+ ))
32
+
33
+ if self.description:
34
+
35
+ emit(Triple(
36
+ s=Value(value=self.id, is_uri=True),
37
+ p=Value(value=DESCRIPTION, is_uri=True),
38
+ o=Value(value=self.description, is_uri=False)
39
+ ))
40
+
@@ -0,0 +1,70 @@
1
+
2
+ from . defs import *
3
+ from .. schema import Triple, Value
4
+
5
+ class PublicationEvent:
6
+ def __init__(
7
+ self, id, organization=None, name=None, description=None,
8
+ start_date=None, end_date=None,
9
+ ):
10
+ self.id = id
11
+ self.organization = organization
12
+ self.name = name
13
+ self.description = description
14
+ self.start_date = start_date
15
+ self.end_date = end_date
16
+
17
+ def emit(self, emit):
18
+
19
+ emit(Triple(
20
+ s=Value(value=self.id, is_uri=True),
21
+ p=Value(value=IS_A, is_uri=True),
22
+ o=Value(value=PUBLICATION_EVENT, is_uri=True)))
23
+
24
+ if self.name:
25
+
26
+ emit(Triple(
27
+ s=Value(value=self.id, is_uri=True),
28
+ p=Value(value=LABEL, is_uri=True),
29
+ o=Value(value=self.name, is_uri=False)
30
+ ))
31
+
32
+ emit(Triple(
33
+ s=Value(value=self.id, is_uri=True),
34
+ p=Value(value=NAME, is_uri=True),
35
+ o=Value(value=self.name, is_uri=False)
36
+ ))
37
+
38
+ if self.description:
39
+
40
+ emit(Triple(
41
+ s=Value(value=self.id, is_uri=True),
42
+ p=Value(value=DESCRIPTION, is_uri=True),
43
+ o=Value(value=self.description, is_uri=False)
44
+ ))
45
+
46
+ if self.organization:
47
+
48
+ emit(Triple(
49
+ s=Value(value=self.id, is_uri=True),
50
+ p=Value(value=PUBLISHED_BY, is_uri=True),
51
+ o=Value(value=self.organization.id, is_uri=True)
52
+ ))
53
+
54
+ self.organization.emit(emit)
55
+
56
+ if self.start_date:
57
+
58
+ emit(Triple(
59
+ s=Value(value=self.id, is_uri=True),
60
+ p=Value(value=START_DATE, is_uri=True),
61
+ o=Value(value=self.start_date, is_uri=False)
62
+ ))
63
+
64
+ if self.end_date:
65
+
66
+ emit(Triple(
67
+ s=Value(value=self.id, is_uri=True),
68
+ p=Value(value=END_DATE, is_uri=True),
69
+ o=Value(value=self.end_date, is_uri=False)))
70
+
@@ -1,6 +1,7 @@
1
1
 
2
2
  RDF_LABEL = "http://www.w3.org/2000/01/rdf-schema#label"
3
3
  DEFINITION = "http://www.w3.org/2004/02/skos/core#definition"
4
+ SUBJECT_OF = "https://schema.org/subjectOf"
4
5
 
5
6
  TRUSTGRAPH_ENTITIES = "http://trustgraph.ai/e/"
6
7
 
@@ -9,5 +9,3 @@ from . graph import *
9
9
  from . retrieval import *
10
10
  from . metadata import *
11
11
 
12
-
13
-
@@ -1,7 +1,7 @@
1
1
 
2
2
  from pulsar.schema import Record, Bytes, String, Boolean, Integer, Array, Double
3
3
 
4
- from . types import Error, Value
4
+ from . types import Error, Value, Triple
5
5
  from . topic import topic
6
6
  from . metadata import Metadata
7
7
 
@@ -41,11 +41,9 @@ graph_embeddings_response_queue = topic(
41
41
 
42
42
  # Graph triples
43
43
 
44
- class Triple(Record):
44
+ class Triples(Record):
45
45
  metadata = Metadata()
46
- s = Value()
47
- p = Value()
48
- o = Value()
46
+ triples = Array(Triple())
49
47
 
50
48
  triples_store_queue = topic('triples-store')
51
49
 
@@ -0,0 +1,16 @@
1
+
2
+ from pulsar.schema import Record, String, Array
3
+ from . types import Triple
4
+
5
+ class Metadata(Record):
6
+
7
+ # Source identifier
8
+ id = String()
9
+
10
+ # Subgraph
11
+ metadata = Array(Triple())
12
+
13
+ # Collection management
14
+ user = String()
15
+ collection = String()
16
+
@@ -10,6 +10,11 @@ class Value(Record):
10
10
  is_uri = Boolean()
11
11
  type = String()
12
12
 
13
+ class Triple(Record):
14
+ s = Value()
15
+ p = Value()
16
+ o = Value()
17
+
13
18
  class Field(Record):
14
19
  name = String()
15
20
  # int, string, long, bool, float, double
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.12.5
3
+ Version: 0.13.1
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
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
6
  Author: trustgraph.ai
7
7
  Author-email: security@trustgraph.ai
8
8
  License: UNKNOWN
9
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.12.5.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.13.1.tar.gz
10
10
  Platform: UNKNOWN
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -19,6 +19,12 @@ trustgraph/clients/graph_rag_client.py
19
19
  trustgraph/clients/llm_client.py
20
20
  trustgraph/clients/prompt_client.py
21
21
  trustgraph/clients/triples_query_client.py
22
+ trustgraph/knowledge/__init__.py
23
+ trustgraph/knowledge/defs.py
24
+ trustgraph/knowledge/document.py
25
+ trustgraph/knowledge/identifier.py
26
+ trustgraph/knowledge/organization.py
27
+ trustgraph/knowledge/publication.py
22
28
  trustgraph/objects/__init__.py
23
29
  trustgraph/objects/field.py
24
30
  trustgraph/objects/object.py
@@ -1 +0,0 @@
1
- __version__ = "0.12.5"
@@ -1,10 +0,0 @@
1
-
2
- from pulsar.schema import Record, String
3
-
4
- class Metadata(Record):
5
- source = String()
6
- id = String()
7
- title = String()
8
- user = String()
9
- collection = String()
10
-