kodexa 7.4.416789395760__py3-none-any.whl → 7.4.416807352183__py3-none-any.whl

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.
kodexa/model/objects.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from decimal import Decimal
3
4
  from enum import Enum
4
5
  from typing import Optional, List, Dict, Any, Set
5
6
  from typing import Union
@@ -4873,6 +4874,27 @@ class ModelUsage(BaseModel):
4873
4874
  interactions: Optional[List[ModelInteraction]] = None
4874
4875
 
4875
4876
 
4877
+ class AggregatedModelCost(BaseModel):
4878
+ """
4879
+ Represents an aggregated view of model costs grouped by modelId.
4880
+ This class holds the sum of various token counts and other metrics.
4881
+ """
4882
+ model_config = ConfigDict(
4883
+ populate_by_name=True,
4884
+ use_enum_values=True,
4885
+ arbitrary_types_allowed=True,
4886
+ protected_namespaces=("model_config",),
4887
+ )
4888
+
4889
+ model_id: Optional[str] = Field(None, alias="modelId")
4890
+ total_input_tokens: Optional[int] = Field(None, alias="totalInputTokens")
4891
+ total_output_tokens: Optional[int] = Field(None, alias="totalOutputTokens")
4892
+ total_thinking_tokens: Optional[int] = Field(None, alias="totalThinkingTokens")
4893
+ total_cached_tokens: Optional[int] = Field(None, alias="totalCachedTokens")
4894
+ total_duration: Optional[int] = Field(None, alias="totalDuration")
4895
+ total_cost: Optional[Decimal] = Field(None, alias="totalCost")
4896
+
4897
+
4876
4898
  class ExecutionEvent(BaseModel):
4877
4899
  """
4878
4900
 
kodexa/platform/client.py CHANGED
@@ -25,6 +25,7 @@ from pydantic_yaml import to_yaml_str
25
25
  from kodexa.model import Document
26
26
  from kodexa.model.model import Ref
27
27
  from kodexa.model.objects import (
28
+ AggregatedModelCost,
28
29
  PageUser,
29
30
  PageMembership,
30
31
  PageExecution,
@@ -3253,7 +3254,7 @@ class ProjectsEndpoint(EntitiesEndpoint):
3253
3254
  ).set_client(self.client)
3254
3255
  return None
3255
3256
 
3256
- def stream_query(self, query: str = "*", sort=None, limit=None):
3257
+ def stream_query(self, query: str = "*", sort=None, limit=None, starting_offset = 0):
3257
3258
  """
3258
3259
  Stream the query for the project endpoints.
3259
3260
 
@@ -3266,7 +3267,7 @@ class ProjectsEndpoint(EntitiesEndpoint):
3266
3267
  ProjectEndpoint: A generator of the project endpoints.
3267
3268
  """
3268
3269
  page_size = 5
3269
- page = 1
3270
+ page = starting_offset // page_size + 1
3270
3271
  counter = 0
3271
3272
 
3272
3273
  if not sort:
@@ -5969,7 +5970,7 @@ class DocumentStoreEndpoint(StoreEndpoint):
5969
5970
  page += 1
5970
5971
 
5971
5972
  def filter(
5972
- self, filter_string: str = "", page: int = 1, page_size: int = 100, sort=None, starting_offset: int = 0
5973
+ self, filter_string: str = "", page: int = 1, page_size: int = 100, sort=None
5973
5974
  ) -> PageDocumentFamilyEndpoint:
5974
5975
  """
5975
5976
  Filter the document family.
@@ -5979,11 +5980,9 @@ class DocumentStoreEndpoint(StoreEndpoint):
5979
5980
  page (int, optional): The page number to get. Defaults to 1.
5980
5981
  page_size (int, optional): The number of items per page. Defaults to 100.
5981
5982
  sort (str, optional): Sorting order of the query. Defaults to None.
5982
- starting_offset (int, optional): The starting offset for the filter (offset is 0-indexed, and over-rides the page parameter)
5983
5983
  Returns:
5984
5984
  PageDocumentFamilyEndpoint: The page of document families.
5985
5985
  """
5986
- page = starting_offset // page_size + 1
5987
5986
  params = {"page": page, "pageSize": page_size, "filter": filter_string}
5988
5987
 
5989
5988
  if sort is not None:
@@ -6761,6 +6760,38 @@ class ExtractionEngineEndpoint:
6761
6760
  return response.text
6762
6761
 
6763
6762
 
6763
+ class ModelCostsEndpoint:
6764
+ """
6765
+ Provides endpoint access to the model costs.
6766
+
6767
+ Attributes:
6768
+ client (KodexaClient): The client to interact with the model costs.
6769
+ """
6770
+
6771
+ def __init__(self, client: "KodexaClient"):
6772
+ self.client = client
6773
+
6774
+ def get_model_costs(self, filters: Optional[List[str]] = None) -> List[AggregatedModelCost]:
6775
+ """
6776
+ Get aggregated model costs filtered by the provided query context.
6777
+ This endpoint aggregates the model costs by modelId.
6778
+
6779
+ Args:
6780
+ filters (Optional[List[str]]): The filters to apply to the model costs.
6781
+
6782
+ Returns:
6783
+ List[AggregatedModelCost]: A list of aggregated model costs.
6784
+ """
6785
+ params = {}
6786
+ if filters is not None:
6787
+ params["filter"] = filters
6788
+
6789
+ response = self.client.get("/api/modelCosts", params=params)
6790
+ return [
6791
+ AggregatedModelCost.model_validate(item)
6792
+ for item in response.json()
6793
+ ]
6794
+
6764
6795
  class KodexaClient:
6765
6796
  """
6766
6797
  A class to represent a Kodexa client.
@@ -6816,6 +6847,7 @@ class KodexaClient:
6816
6847
  self.workspaces = WorkspacesEndpoint(self)
6817
6848
  self.data_exceptions = DataExceptionsEndpoint(self)
6818
6849
  self.notes = NotesEndpoint(self)
6850
+ self.model_costs = ModelCostsEndpoint(self)
6819
6851
 
6820
6852
  @staticmethod
6821
6853
  def login(url, token):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kodexa
3
- Version: 7.4.416789395760
3
+ Version: 7.4.416807352183
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -13,13 +13,13 @@ kodexa/model/entities/product.py,sha256=StUhTEeLXmc05cj6XnZppQfeJsqCPbX1jdhsysHH
13
13
  kodexa/model/entities/product_group.py,sha256=540fRGyUf34h1BzAN1DiWu6rGgvaj3xDFhZ2k-RvSFY,3617
14
14
  kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
15
15
  kodexa/model/model.py,sha256=o93SDgw8mj28LWbwJB78PF_Oim8qeCTH1a9x_GDc7yg,120895
16
- kodexa/model/objects.py,sha256=ohdZxUztBujnEK9Vn7t8xnO_YFZPuLEUqB_jOMsK4fY,204018
16
+ kodexa/model/objects.py,sha256=dcnsvijSDFEHghfib1Cx4xOtLMQe0It8GbLxZ_Pd1ic,204947
17
17
  kodexa/model/persistence.py,sha256=jUgQ8xwsAFIoZ_bEynxCDEWhUII42eN0e0Mum0dkQPg,72043
18
18
  kodexa/model/utils.py,sha256=YEG3f8YzBil06D0P3_dfx2S9GnHREzyrjnlWwQ7oPlU,3038
19
19
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
20
20
  kodexa/pipeline/pipeline.py,sha256=zyNEpA7KlGhPs_l-vgV6m-OCb16dbxQhl8QezeylugA,25540
21
21
  kodexa/platform/__init__.py,sha256=1O3oiWMg292NPL_NacKDnK1T3_R6cMorrPRue_9e-O4,216
22
- kodexa/platform/client.py,sha256=hfSD87kbtLXf3oho_MULQbnaQGJYmxqISjfAc_MJkjY,237773
22
+ kodexa/platform/client.py,sha256=dnl2grl7nv1lEMV-QwosDUcW4Ll-FTAxVWT1nq4YjgM,238703
23
23
  kodexa/platform/interaction.py,sha256=6zpcwXKNZstUGNS6m4JsoRXAqCZPJHWI-ZN3co8nnF0,1055
24
24
  kodexa/platform/kodexa.py,sha256=2s7Ez7_o-ywpNwbTRhtOUaQKtB9hKsDC_oJHaskXw-I,35315
25
25
  kodexa/platform/manifest.py,sha256=ThjQOk0xbP0qACcpS8NM6-zQL_Emd_bv4QAW2FpbUWk,19454
@@ -45,7 +45,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
45
45
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
46
46
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
48
- kodexa-7.4.416789395760.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
49
- kodexa-7.4.416789395760.dist-info/METADATA,sha256=uv7xYEa5omirE0VBlMzM6Nd5i_fIpQmQvUPaMxBBX88,2916
50
- kodexa-7.4.416789395760.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
51
- kodexa-7.4.416789395760.dist-info/RECORD,,
48
+ kodexa-7.4.416807352183.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
49
+ kodexa-7.4.416807352183.dist-info/METADATA,sha256=Y4Og75pnoAvg5VHhnN8RAmoTn-MHEchlFijCD_WT-dc,2916
50
+ kodexa-7.4.416807352183.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
51
+ kodexa-7.4.416807352183.dist-info/RECORD,,