agi-med-common 4.2.5__tar.gz → 4.2.6__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 (37) hide show
  1. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/PKG-INFO +1 -1
  2. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/__init__.py +3 -3
  3. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/__init__.py +1 -1
  4. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/chat_item/outer_context_item.py +1 -2
  5. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/chat_item/replica_item.py +8 -2
  6. agi_med_common-4.2.6/src/agi_med_common/models/enums.py +58 -0
  7. agi_med_common-4.2.6/src/agi_med_common/models/widget.py +20 -0
  8. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common.egg-info/PKG-INFO +1 -1
  9. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common.egg-info/SOURCES.txt +3 -8
  10. agi_med_common-4.2.5/src/agi_med_common/models/enums/__init__.py +0 -9
  11. agi_med_common-4.2.5/src/agi_med_common/models/enums/diagnostics_xml_tag_enum.py +0 -11
  12. agi_med_common-4.2.5/src/agi_med_common/models/enums/doctor_choice_xml_tag_enum.py +0 -11
  13. agi_med_common-4.2.5/src/agi_med_common/models/enums/moderation_label_enum.py +0 -14
  14. agi_med_common-4.2.5/src/agi_med_common/models/enums/mtrs_label_enum.py +0 -10
  15. agi_med_common-4.2.5/src/agi_med_common/models/enums/mtrs_xml_tag_enum.py +0 -11
  16. agi_med_common-4.2.5/src/agi_med_common/models/enums/track_id_enum.py +0 -18
  17. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/README.md +0 -0
  18. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/pyproject.toml +0 -0
  19. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/requirements.txt +0 -0
  20. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/setup.cfg +0 -0
  21. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/file_storage.py +0 -0
  22. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/logger/__init__.py +0 -0
  23. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/logger/log_level_enum.py +0 -0
  24. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/logger/logger.py +0 -0
  25. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/_base.py +0 -0
  26. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/base_config_models/__init__.py +0 -0
  27. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/base_config_models/gigachat_config.py +0 -0
  28. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/chat_item/__init__.py +0 -0
  29. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/chat_item/chat_item.py +0 -0
  30. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/models/chat_item/inner_context_item.py +0 -0
  31. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/parallel_map.py +0 -0
  32. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/utils.py +0 -0
  33. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/validators.py +0 -0
  34. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common/xml_parser.py +0 -0
  35. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common.egg-info/dependency_links.txt +0 -0
  36. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common.egg-info/requires.txt +0 -0
  37. {agi_med_common-4.2.5 → agi_med_common-4.2.6}/src/agi_med_common.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agi_med_common
3
- Version: 4.2.5
3
+ Version: 4.2.6
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -1,8 +1,7 @@
1
- __version__ = "4.2.5"
1
+ __version__ = "4.2.6"
2
2
 
3
- from .logger import LogLevelEnum, logger_init
3
+ from .logger import LogLevelEnum, logger_init, log_llm_error
4
4
  from .models import (
5
- TrackIdEnum,
6
5
  StateEnum,
7
6
  MTRSLabelEnum,
8
7
  ActionEnum,
@@ -13,6 +12,7 @@ from .models import (
13
12
  ReplicaItem,
14
13
  ReplicaItemPair,
15
14
  )
15
+ from .models.widget import Widget
16
16
  from .file_storage import FileStorage
17
17
  from .models import DiagnosticsXMLTagEnum, MTRSXMLTagEnum, DoctorChoiceXMLTagEnum
18
18
  from .utils import make_session_id, read_json
@@ -1,6 +1,6 @@
1
1
  from ._base import _Base
2
2
 
3
- from .enums import TrackIdEnum, StateEnum, MTRSLabelEnum, ActionEnum, ModerationLabelEnum
3
+ from .enums import StateEnum, MTRSLabelEnum, ActionEnum, ModerationLabelEnum
4
4
  from .enums import DiagnosticsXMLTagEnum, MTRSXMLTagEnum, DoctorChoiceXMLTagEnum
5
5
 
6
6
  from .chat_item import ChatItem, OuterContextItem, InnerContextItem, ReplicaItem, ReplicaItemPair
@@ -2,7 +2,6 @@ from pydantic import Field, ConfigDict
2
2
  from typing import Any
3
3
 
4
4
  from .. import _Base
5
- from ..enums import TrackIdEnum
6
5
 
7
6
 
8
7
  class OuterContextItem(_Base):
@@ -14,7 +13,7 @@ class OuterContextItem(_Base):
14
13
  user_id: str = Field("", alias="UserId", examples=["123456789"])
15
14
  session_id: str = Field("", alias="SessionId", examples=["987654321"])
16
15
  client_id: str = Field("", alias="ClientId", examples=["543216789"])
17
- track_id: TrackIdEnum | str = Field(default=TrackIdEnum.CONSULTATION, alias="TrackId")
16
+ track_id: str = Field(default="Consultation", alias="TrackId")
18
17
  entrypoint_key: str = Field("", alias="EntrypointKey", examples=["giga"])
19
18
 
20
19
  def create_id(self, short: bool = False, clean: bool = False) -> str:
@@ -1,10 +1,11 @@
1
1
  from datetime import datetime
2
- from typing import Any, Optional
2
+ from typing import Any
3
3
 
4
4
  from pydantic import Field, ConfigDict
5
5
 
6
6
  from .. import _Base
7
7
  from ..enums import StateEnum, ActionEnum, ModerationLabelEnum
8
+ from agi_med_common.models.widget import Widget
8
9
 
9
10
 
10
11
  _DATETIME_FORMAT: str = "%Y-%m-%d-%H-%M-%S"
@@ -13,7 +14,8 @@ _EXAMPLE_DATETIME: str = datetime(1970, 1, 1, 0, 0, 0).strftime(_DATETIME_FORMAT
13
14
 
14
15
  class ReplicaItem(_Base):
15
16
  body: str = Field("", alias="Body", examples=["Привет"])
16
- resource_id: Optional[str] = Field(None, alias="ResourceId", examples=["<link-id>"])
17
+ resource_id: str | None = Field(None, alias="ResourceId", examples=["<link-id>"])
18
+ widget: Widget | None = Field(None, alias="Widget", exampels=[None])
17
19
  role: bool = Field(False, alias="Role", description="True = ai, False = client", examples=[False])
18
20
  date_time: str = Field(
19
21
  _EXAMPLE_DATETIME,
@@ -37,6 +39,10 @@ class ReplicaItem(_Base):
37
39
  def DATETIME_FORMAT() -> str:
38
40
  return _DATETIME_FORMAT
39
41
 
42
+ def with_now_datetime(self):
43
+ dt = datetime.now().strftime(ReplicaItem.DATETIME_FORMAT())
44
+ return self.model_copy(update=dict(date_time=dt))
45
+
40
46
 
41
47
  class ReplicaItemPair(_Base):
42
48
  # remove annoying warning for protected `model_` namespace
@@ -0,0 +1,58 @@
1
+ from enum import IntEnum, StrEnum, auto
2
+
3
+
4
+ StateEnum, ActionEnum = str, str
5
+
6
+
7
+ class ModerationLabelEnum(IntEnum):
8
+ @staticmethod
9
+ def _generate_next_value_(name, start, count, last_values):
10
+ return count
11
+
12
+ OK = auto()
13
+ NON_MED = auto()
14
+ CHILD = auto()
15
+ ABSURD = auto()
16
+ GREETING = auto()
17
+ RECEIPT = auto()
18
+
19
+
20
+ class DoctorChoiceXMLTagEnum(StrEnum):
21
+ @staticmethod
22
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
23
+ return f"{name.lower()}"
24
+
25
+ DIAGNOSTICS = auto()
26
+ SUMMARIZATION = auto()
27
+ MTRS = auto()
28
+
29
+
30
+ class MTRSXMLTagEnum(StrEnum):
31
+ @staticmethod
32
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
33
+ return f"mtrs_{name.lower()}"
34
+
35
+ NAME = auto()
36
+ LABEL = auto()
37
+ DESC = auto()
38
+
39
+
40
+ class MTRSLabelEnum(StrEnum):
41
+ @staticmethod
42
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
43
+ return name.upper()
44
+
45
+ LABORATORY = auto()
46
+ INSTRUMENTAL = auto()
47
+
48
+
49
+ class DiagnosticsXMLTagEnum(StrEnum):
50
+ @staticmethod
51
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
52
+ return f"diag_{name.lower()}"
53
+
54
+ DIAG = auto()
55
+ DOC = auto()
56
+ DESC = auto()
57
+
58
+
@@ -0,0 +1,20 @@
1
+ from typing import List, Self
2
+ from pydantic import BaseModel, model_validator
3
+
4
+
5
+ class Widget(BaseModel):
6
+ buttons: List[List[str]] | None = None
7
+ ibuttons: List[List[str]] | None = None
8
+
9
+ @model_validator(mode="after")
10
+ def check(self) -> Self:
11
+ if not self.buttons and not self.ibuttons:
12
+ raise ValueError("Empty widget is not allowed!")
13
+ if not self.ibuttons:
14
+ return self
15
+ for row in self.ibuttons:
16
+ for btn in row:
17
+ if ":" in btn:
18
+ continue
19
+ raise ValueError(f"Expected buttons like `<callback>:<caption>`, found: {btn}")
20
+ return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agi_med_common
3
- Version: 4.2.5
3
+ Version: 4.2.6
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -17,17 +17,12 @@ src/agi_med_common/logger/log_level_enum.py
17
17
  src/agi_med_common/logger/logger.py
18
18
  src/agi_med_common/models/__init__.py
19
19
  src/agi_med_common/models/_base.py
20
+ src/agi_med_common/models/enums.py
21
+ src/agi_med_common/models/widget.py
20
22
  src/agi_med_common/models/base_config_models/__init__.py
21
23
  src/agi_med_common/models/base_config_models/gigachat_config.py
22
24
  src/agi_med_common/models/chat_item/__init__.py
23
25
  src/agi_med_common/models/chat_item/chat_item.py
24
26
  src/agi_med_common/models/chat_item/inner_context_item.py
25
27
  src/agi_med_common/models/chat_item/outer_context_item.py
26
- src/agi_med_common/models/chat_item/replica_item.py
27
- src/agi_med_common/models/enums/__init__.py
28
- src/agi_med_common/models/enums/diagnostics_xml_tag_enum.py
29
- src/agi_med_common/models/enums/doctor_choice_xml_tag_enum.py
30
- src/agi_med_common/models/enums/moderation_label_enum.py
31
- src/agi_med_common/models/enums/mtrs_label_enum.py
32
- src/agi_med_common/models/enums/mtrs_xml_tag_enum.py
33
- src/agi_med_common/models/enums/track_id_enum.py
28
+ src/agi_med_common/models/chat_item/replica_item.py
@@ -1,9 +0,0 @@
1
- from .track_id_enum import TrackIdEnum
2
- from .mtrs_label_enum import MTRSLabelEnum
3
- from .moderation_label_enum import ModerationLabelEnum
4
-
5
- from .diagnostics_xml_tag_enum import DiagnosticsXMLTagEnum
6
- from .mtrs_xml_tag_enum import MTRSXMLTagEnum
7
- from .doctor_choice_xml_tag_enum import DoctorChoiceXMLTagEnum
8
-
9
- StateEnum, ActionEnum = str, str
@@ -1,11 +0,0 @@
1
- from enum import StrEnum, auto
2
-
3
-
4
- class DiagnosticsXMLTagEnum(StrEnum):
5
- @staticmethod
6
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
7
- return f"diag_{name.lower()}"
8
-
9
- DIAG = auto()
10
- DOC = auto()
11
- DESC = auto()
@@ -1,11 +0,0 @@
1
- from enum import StrEnum, auto
2
-
3
-
4
- class DoctorChoiceXMLTagEnum(StrEnum):
5
- @staticmethod
6
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
7
- return f"{name.lower()}"
8
-
9
- DIAGNOSTICS = auto()
10
- SUMMARIZATION = auto()
11
- MTRS = auto()
@@ -1,14 +0,0 @@
1
- from enum import IntEnum, auto
2
-
3
-
4
- class ModerationLabelEnum(IntEnum):
5
- @staticmethod
6
- def _generate_next_value_(name, start, count, last_values):
7
- return count
8
-
9
- OK = auto()
10
- NON_MED = auto()
11
- CHILD = auto()
12
- ABSURD = auto()
13
- GREETING = auto()
14
- RECEIPT = auto()
@@ -1,10 +0,0 @@
1
- from enum import StrEnum, auto
2
-
3
-
4
- class MTRSLabelEnum(StrEnum):
5
- @staticmethod
6
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
7
- return name.upper()
8
-
9
- LABORATORY = auto()
10
- INSTRUMENTAL = auto()
@@ -1,11 +0,0 @@
1
- from enum import StrEnum, auto
2
-
3
-
4
- class MTRSXMLTagEnum(StrEnum):
5
- @staticmethod
6
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
7
- return f"mtrs_{name.lower()}"
8
-
9
- NAME = auto()
10
- LABEL = auto()
11
- DESC = auto()
@@ -1,18 +0,0 @@
1
- from enum import StrEnum, auto
2
-
3
-
4
- class TrackIdEnum(StrEnum):
5
- @staticmethod
6
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[str]) -> str:
7
- return "".join([word.title() for word in name.lower().split("_")])
8
-
9
- DIAGNOSTIC = auto()
10
- DIAGNOSTIC_SBERHEALTH = auto()
11
- SECOND_OPINION = auto()
12
- MEDICAL_TEST_DECRYPTION = auto()
13
- CONSULTATION = auto()
14
- DUMMY = auto()
15
- COMMON_CONSULTATION = auto()
16
- FINANCIER = auto()
17
- FINANCIER_GENERIC = auto()
18
- MULTIMODAL = auto()
File without changes
File without changes