HowdenCommonObjects 0.1.0__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.
File without changes
@@ -0,0 +1,10 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional, Generic, TypeVar
3
+ from HowdenCommonObjects.usage import Usage
4
+
5
+ T = TypeVar("T")
6
+
7
+ @dataclass
8
+ class HowdenResult(Generic[T]):
9
+ result: T
10
+ usage: Optional[Usage] = None
@@ -0,0 +1,38 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+
4
+
5
+ @dataclass
6
+ class Usage:
7
+ llm_model: Optional[str] = None
8
+ input_tokens: int = 0
9
+ output_tokens: int = 0
10
+ parser_model: Optional[str] = None
11
+ parsing_tier: Optional[str] = None
12
+ pages_parsed: int = 0
13
+
14
+ def __iadd__(self, other):
15
+ if not isinstance(other, Usage):
16
+ raise TypeError(f"Cannot add Usage and {type(other).__name__}")
17
+
18
+ for field, val in vars(self).items():
19
+ other_val = getattr(other, field)
20
+
21
+ if isinstance(val, int):
22
+ setattr(self, field, val + other_val)
23
+ elif isinstance(val, str) or val is None:
24
+ if (val is None and other_val is None) or val == other_val:
25
+ # Neither object has a value or equal values
26
+ continue
27
+ elif val is None and isinstance(other_val, str):
28
+ # self is empty, so take other's value
29
+ setattr(self, field, other_val)
30
+ elif isinstance(val, str) and other_val is None:
31
+ # self already has the value, keep it
32
+ continue
33
+ else:
34
+ # Conflicting values
35
+ raise ValueError(f"Conflicting values for {field}:{val!r} and {other_val!r}")
36
+ else:
37
+ raise NotImplementedError(f"Addition for type {type(val).__name__} has not been implemented.")
38
+ return self
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.4
2
+ Name: HowdenCommonObjects
3
+ Version: 0.1.0
4
+ Summary: A simple configuration manager with Pydantic and JSON export.
5
+ Author-email: Casper Bresdahl <casper.bresdahl@howdendanmark.dk>
6
+ License: MIT
7
+ Requires-Python: <3.14,>=3.12
8
+ Description-Content-Type: text/markdown
@@ -0,0 +1,7 @@
1
+ HowdenCommonObjects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ HowdenCommonObjects/howden_result.py,sha256=22zbzv-Wh35V-bYS4CtAa9pDYFu-pYmOQCrK8ldqjBI,242
3
+ HowdenCommonObjects/usage.py,sha256=9xAhhZ1KlQnL1GOZa9En7CZHQbxCdss_FQID-WCQ7Sk,1513
4
+ howdencommonobjects-0.1.0.dist-info/METADATA,sha256=yw4dkAg7P4lWQJh97ob2lQzYElj-2u7X7TuFDZwST90,290
5
+ howdencommonobjects-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
+ howdencommonobjects-0.1.0.dist-info/top_level.txt,sha256=01JP1FI1iq9298HaBWAPQtdcauZ-ah4fcEVohgO92BA,20
7
+ howdencommonobjects-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ HowdenCommonObjects