kodexa 7.4.418571405824__tar.gz → 7.4.418596506326__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.
Potentially problematic release.
This version of kodexa might be problematic. Click here for more details.
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/PKG-INFO +1 -1
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/dataclasses/__init__.py +2 -3
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/model.py +13 -7
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/persistence.py +64 -3
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/pyproject.toml +1 -1
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/LICENSE +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/README.md +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/assistant/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/assistant/assistant.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/connectors/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/connectors/connectors.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/dataclasses/templates/llm_data_class.j2 +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/base.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/check_response.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/product.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/product_group.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/product_subscription.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/objects.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/utils.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/pipeline/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/pipeline/pipeline.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/platform/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/platform/client.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/platform/interaction.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/platform/kodexa.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/platform/manifest.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/ast.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/core.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/lexrules.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/lextab.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/lextab.pyi +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/parserules.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/parserules.pyi +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/parsetab.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/selectors/parsetab.pyi +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/spatial/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/spatial/azure_models.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/spatial/bbox_common.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/spatial/table_form_common.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/steps/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/steps/common.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/testing/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/testing/test_components.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/testing/test_utils.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/training/__init__.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/training/train_utils.py +0 -0
- {kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/utils/__init__.py +0 -0
|
@@ -7,7 +7,7 @@ import jinja2
|
|
|
7
7
|
from kodexa import ContentNode
|
|
8
8
|
from kodexa.model.model import Tag, Document
|
|
9
9
|
from kodexa.model.objects import ContentException, Taxon, Taxonomy, Assistant
|
|
10
|
-
from pydantic import BaseModel
|
|
10
|
+
from pydantic import BaseModel, ConfigDict
|
|
11
11
|
|
|
12
12
|
from kodexa.utils import snake_to_camel, to_snake, taxon_to_property_name, taxon_to_class_name, taxon_to_group_path
|
|
13
13
|
|
|
@@ -110,8 +110,7 @@ class LLMDataObject(BaseModel):
|
|
|
110
110
|
cell_index: int = 0
|
|
111
111
|
exceptions: Optional[list[ContentException]] = None
|
|
112
112
|
|
|
113
|
-
|
|
114
|
-
arbitrary_types_allowed = True
|
|
113
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
115
114
|
|
|
116
115
|
def process_exceptions(self, document: "KodexaDocumentLLMWrapper"):
|
|
117
116
|
# Lets make sure we add all the content exceptions
|
|
@@ -12,9 +12,9 @@ from typing import Any, List, Optional
|
|
|
12
12
|
from addict import Dict
|
|
13
13
|
import deepdiff
|
|
14
14
|
import msgpack
|
|
15
|
-
from pydantic import BaseModel, ConfigDict, Field
|
|
15
|
+
from pydantic import BaseModel, ConfigDict, Field, model_serializer
|
|
16
16
|
|
|
17
|
-
from kodexa.model.objects import ContentObject, FeatureSet, DocumentTaxonValidation
|
|
17
|
+
from kodexa.model.objects import ContentObject, FeatureSet, DocumentTaxonValidation, KnowledgeItem
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class Ref:
|
|
@@ -2435,11 +2435,11 @@ class ProcessingStep(BaseModel):
|
|
|
2435
2435
|
merged_step.parents.append(step)
|
|
2436
2436
|
return merged_step
|
|
2437
2437
|
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2438
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
2439
|
+
|
|
2440
|
+
@model_serializer(mode='plain')
|
|
2441
|
+
def _serialize(self):
|
|
2442
|
+
return self.to_dict()
|
|
2443
2443
|
|
|
2444
2444
|
def to_dict(self, seen=None):
|
|
2445
2445
|
if seen is None:
|
|
@@ -2503,6 +2503,12 @@ class Document(object):
|
|
|
2503
2503
|
def set_steps(self, steps: list[ProcessingStep]):
|
|
2504
2504
|
self._persistence_layer.set_steps(steps)
|
|
2505
2505
|
|
|
2506
|
+
def get_knowledge(self) -> list[KnowledgeItem]:
|
|
2507
|
+
return self._persistence_layer.get_knowledge()
|
|
2508
|
+
|
|
2509
|
+
def set_knowledge(self, knowledge: list[KnowledgeItem]):
|
|
2510
|
+
self._persistence_layer.set_knowledge(knowledge)
|
|
2511
|
+
|
|
2506
2512
|
def replace_exceptions(self, exceptions: List[ContentException]):
|
|
2507
2513
|
self._persistence_layer.replace_exceptions(exceptions)
|
|
2508
2514
|
|
|
@@ -626,7 +626,7 @@ class SqliteDocumentPersistence(object):
|
|
|
626
626
|
|
|
627
627
|
self.uuid = metadata.get("uuid")
|
|
628
628
|
|
|
629
|
-
import
|
|
629
|
+
from semver import Version
|
|
630
630
|
|
|
631
631
|
root_node = self.cursor.execute(
|
|
632
632
|
"select id, pid, nt, idx from cn where pid is null"
|
|
@@ -634,7 +634,7 @@ class SqliteDocumentPersistence(object):
|
|
|
634
634
|
if root_node:
|
|
635
635
|
self.document.content_node = self.__build_node(root_node)
|
|
636
636
|
|
|
637
|
-
if
|
|
637
|
+
if Version.parse(self.document.version) < Version.parse("4.0.1"):
|
|
638
638
|
# We need to migrate this to a 4.0.1 document
|
|
639
639
|
self.cursor.execute(
|
|
640
640
|
"""CREATE TABLE ft
|
|
@@ -679,7 +679,7 @@ class SqliteDocumentPersistence(object):
|
|
|
679
679
|
)"""
|
|
680
680
|
)
|
|
681
681
|
|
|
682
|
-
if
|
|
682
|
+
if Version.parse(self.document.version) < Version.parse("6.0.0"):
|
|
683
683
|
from sqlite3 import OperationalError
|
|
684
684
|
|
|
685
685
|
try:
|
|
@@ -1369,6 +1369,51 @@ class SqliteDocumentPersistence(object):
|
|
|
1369
1369
|
return [ProcessingStep(**step) for step in unpacked_data]
|
|
1370
1370
|
return []
|
|
1371
1371
|
|
|
1372
|
+
def __ensure_knowledge_table_exists(self):
|
|
1373
|
+
"""
|
|
1374
|
+
Ensure the 'knowledge' table exists in the database.
|
|
1375
|
+
Creates the table if it does not exist.
|
|
1376
|
+
"""
|
|
1377
|
+
self.cursor.execute("""
|
|
1378
|
+
CREATE TABLE IF NOT EXISTS knowledge (
|
|
1379
|
+
obj BLOB
|
|
1380
|
+
)
|
|
1381
|
+
""")
|
|
1382
|
+
|
|
1383
|
+
# Check if the table has any rows, if not, insert an initial empty row
|
|
1384
|
+
result = self.cursor.execute("SELECT COUNT(*) FROM knowledge").fetchone()
|
|
1385
|
+
if result[0] == 0:
|
|
1386
|
+
self.cursor.execute("INSERT INTO knowledge (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb([]))])
|
|
1387
|
+
|
|
1388
|
+
def set_knowledge(self, knowledge: List):
|
|
1389
|
+
"""
|
|
1390
|
+
Sets the knowledge items for the document.
|
|
1391
|
+
|
|
1392
|
+
Args:
|
|
1393
|
+
knowledge (List): A list of KnowledgeItem objects to store.
|
|
1394
|
+
"""
|
|
1395
|
+
from kodexa.model.objects import KnowledgeItem
|
|
1396
|
+
self.__ensure_knowledge_table_exists()
|
|
1397
|
+
serialized_knowledge = [item.model_dump(by_alias=True) for item in knowledge]
|
|
1398
|
+
packed_data = sqlite3.Binary(msgpack.packb(serialized_knowledge))
|
|
1399
|
+
self.cursor.execute("UPDATE knowledge SET obj = ? WHERE rowid = 1", [packed_data])
|
|
1400
|
+
self.connection.commit()
|
|
1401
|
+
|
|
1402
|
+
def get_knowledge(self) -> List:
|
|
1403
|
+
"""
|
|
1404
|
+
Gets the knowledge items associated with this document.
|
|
1405
|
+
|
|
1406
|
+
Returns:
|
|
1407
|
+
List: A list of KnowledgeItem objects.
|
|
1408
|
+
"""
|
|
1409
|
+
from kodexa.model.objects import KnowledgeItem
|
|
1410
|
+
self.__ensure_knowledge_table_exists()
|
|
1411
|
+
result = self.cursor.execute("SELECT obj FROM knowledge WHERE rowid = 1").fetchone()
|
|
1412
|
+
if result and result[0]:
|
|
1413
|
+
unpacked_data = msgpack.unpackb(result[0])
|
|
1414
|
+
return [KnowledgeItem(**item) for item in unpacked_data]
|
|
1415
|
+
return []
|
|
1416
|
+
|
|
1372
1417
|
|
|
1373
1418
|
class SimpleObjectCache(object):
|
|
1374
1419
|
"""
|
|
@@ -1518,6 +1563,22 @@ class PersistenceManager(object):
|
|
|
1518
1563
|
def set_steps(self, steps: list[ProcessingStep]):
|
|
1519
1564
|
self._underlying_persistence.set_steps(steps)
|
|
1520
1565
|
|
|
1566
|
+
def get_knowledge(self) -> list:
|
|
1567
|
+
"""
|
|
1568
|
+
Gets the knowledge items for this document
|
|
1569
|
+
|
|
1570
|
+
:return: list of KnowledgeItem objects
|
|
1571
|
+
"""
|
|
1572
|
+
return self._underlying_persistence.get_knowledge()
|
|
1573
|
+
|
|
1574
|
+
def set_knowledge(self, knowledge: list):
|
|
1575
|
+
"""
|
|
1576
|
+
Sets the knowledge items for this document
|
|
1577
|
+
|
|
1578
|
+
:param knowledge: list of KnowledgeItem objects
|
|
1579
|
+
"""
|
|
1580
|
+
self._underlying_persistence.set_knowledge(knowledge)
|
|
1581
|
+
|
|
1521
1582
|
def set_validations(self, validations: list[DocumentTaxonValidation]):
|
|
1522
1583
|
self._underlying_persistence.set_validations(validations)
|
|
1523
1584
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "kodexa"
|
|
3
|
-
version = "7.4.
|
|
3
|
+
version = "7.4.418596506326"
|
|
4
4
|
description = "Python SDK for the Kodexa Platform"
|
|
5
5
|
authors = ["Austin Redenbaugh <austin@kodexa.com>", "Philip Dodds <philip@kodexa.com>", "Romar Cablao <rcablao@kodexa.com>", "Amadea Paula Dodds <amadeapaula@kodexa.com>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/dataclasses/templates/llm_data_class.j2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kodexa-7.4.418571405824 → kodexa-7.4.418596506326}/kodexa/model/entities/product_subscription.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|