agi-med-common 3.5.4__tar.gz → 3.5.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 (36) hide show
  1. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/PKG-INFO +1 -1
  2. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/__init__.py +2 -2
  3. agi_med_common-3.5.6/src/agi_med_common/file_storage.py +39 -0
  4. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/chat_item/replica_item.py +2 -1
  5. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/track_id_enum.py +1 -0
  6. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/utils.py +0 -4
  7. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common.egg-info/PKG-INFO +1 -1
  8. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common.egg-info/SOURCES.txt +1 -0
  9. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/README.md +0 -0
  10. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/pyproject.toml +0 -0
  11. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/requirements.txt +0 -0
  12. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/setup.cfg +0 -0
  13. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/logger/__init__.py +0 -0
  14. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/logger/log_level_enum.py +0 -0
  15. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/logger/logger.py +0 -0
  16. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/__init__.py +0 -0
  17. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/_base.py +0 -0
  18. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/base_config_models/__init__.py +0 -0
  19. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/base_config_models/gigachat_config.py +0 -0
  20. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/chat_item/__init__.py +0 -0
  21. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/chat_item/chat_item.py +0 -0
  22. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/chat_item/inner_context_item.py +0 -0
  23. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/chat_item/outer_context_item.py +0 -0
  24. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/__init__.py +0 -0
  25. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/action_enum.py +0 -0
  26. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/diagnostics_xml_tag_enum.py +0 -0
  27. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/doctor_choice_xml_tag_enum.py +0 -0
  28. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/moderation_label_enum.py +0 -0
  29. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/mtrs_label_enum.py +0 -0
  30. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/mtrs_xml_tag_enum.py +0 -0
  31. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/models/enums/state_enum.py +0 -0
  32. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/validators.py +0 -0
  33. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common/xml_parser.py +0 -0
  34. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common.egg-info/dependency_links.txt +0 -0
  35. {agi_med_common-3.5.4 → agi_med_common-3.5.6}/src/agi_med_common.egg-info/requires.txt +0 -0
  36. {agi_med_common-3.5.4 → agi_med_common-3.5.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: 3.5.4
3
+ Version: 3.5.6
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -1,4 +1,4 @@
1
- __version__ = "3.5.4"
1
+ __version__ = "3.5.6"
2
2
 
3
3
  from .logger import LogLevelEnum, logger_init
4
4
  from .models import (
@@ -16,6 +16,6 @@ from .models import (
16
16
 
17
17
  from .models import DiagnosticsXMLTagEnum, MTRSXMLTagEnum, DoctorChoiceXMLTagEnum
18
18
 
19
- from .utils import make_session_id, read_json, replace_n
19
+ from .utils import make_session_id, read_json
20
20
  from .validators import is_file_exist, validate_prompt
21
21
  from .xml_parser import XMLParser
@@ -0,0 +1,39 @@
1
+ import string
2
+ from hashlib import md5
3
+ from pathlib import Path
4
+
5
+ ResourceId = str
6
+ ASCII_DIGITS = set(string.ascii_lowercase + string.digits)
7
+
8
+
9
+ def _validate_exist(files_dir):
10
+ if not files_dir.exists():
11
+ err = f"Failed to access file-storage directory: {files_dir}"
12
+ raise OSError(err)
13
+
14
+
15
+ def _validate_dtype(dtype: str):
16
+ if all(map(ASCII_DIGITS.__contains__, dtype)):
17
+ return
18
+ raise ValueError(f'Bad dtype: {dtype}')
19
+
20
+
21
+ class FileStorage:
22
+ def __init__(self, files_dir):
23
+ self.files_dir = Path(files_dir)
24
+ self.files_dir.mkdir(exist_ok=True)
25
+ _validate_exist(self.files_dir)
26
+
27
+ def upload(self, content: bytes, dtype: str) -> ResourceId | None:
28
+ _validate_dtype(dtype)
29
+ fname_hash = md5(content).hexdigest()
30
+ fname = f'{fname_hash}.{dtype}'
31
+ fpath = self.files_dir / fname
32
+ fpath.write_bytes(content)
33
+ return str(fpath)
34
+
35
+ def download(self, rid: ResourceId) -> bytes:
36
+ return Path(rid).read_bytes()
37
+
38
+ def is_valid(self, rid: ResourceId) -> bytes:
39
+ return Path(rid).exists() and Path(rid).is_file()
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Any
2
+ from typing import Any, Optional
3
3
 
4
4
  from pydantic import Field
5
5
 
@@ -12,6 +12,7 @@ _EXAMPLE_DATETIME: str = datetime(1970, 1, 1, 0, 0, 0).strftime(_DATETIME_FORMAT
12
12
 
13
13
  class ReplicaItem(_Base):
14
14
  body: str = Field("", alias="Body", examples=["Привет"])
15
+ resource_id: Optional[str] = Field(None, alias="ResourceId", examples=["<link-id>"])
15
16
  role: bool = Field(False, alias="Role", description="True = ai, False = client", examples=[False])
16
17
  date_time: str = Field(
17
18
  _EXAMPLE_DATETIME,
@@ -14,3 +14,4 @@ class TrackIdEnum(StrEnum):
14
14
  DUMMY = auto()
15
15
  COMMON_CONSULTATION = auto()
16
16
  FINANCIER = auto()
17
+ MULTIMODAL = auto()
@@ -12,7 +12,3 @@ def make_session_id() -> str:
12
12
  def read_json(path: Path | os.PathLike[str] | str) -> list | dict:
13
13
  with codecs.open(path, "r", encoding="utf8") as file:
14
14
  return json.load(file)
15
-
16
-
17
- def replace_n(value: str) -> str:
18
- return value.replace("\\n", "\n")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agi_med_common
3
- Version: 3.5.4
3
+ Version: 3.5.6
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  requirements.txt
4
4
  src/agi_med_common/__init__.py
5
+ src/agi_med_common/file_storage.py
5
6
  src/agi_med_common/utils.py
6
7
  src/agi_med_common/validators.py
7
8
  src/agi_med_common/xml_parser.py
File without changes
File without changes