agi-med-common 4.2.16__tar.gz → 5.0.0__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.
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/PKG-INFO +1 -1
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/__init__.py +1 -3
- agi_med_common-5.0.0/src/agi_med_common/models/__init__.py +6 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/chat_item.py +28 -49
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/enums.py +1 -16
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/PKG-INFO +1 -1
- agi_med_common-4.2.16/src/agi_med_common/models/__init__.py +0 -6
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/README.md +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/pyproject.toml +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/requirements.txt +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/setup.cfg +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/file_storage.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/logger/__init__.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/logger/log_level_enum.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/logger/logger.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/_base.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/base_config_models/__init__.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/base_config_models/gigachat_config.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/models/widget.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/parallel_map.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/utils.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/validators.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common/xml_parser.py +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/SOURCES.txt +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/dependency_links.txt +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/requires.txt +0 -0
- {agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/top_level.txt +0 -0
@@ -1,14 +1,12 @@
|
|
1
|
-
__version__ = "
|
1
|
+
__version__ = "5.0.0"
|
2
2
|
|
3
3
|
from .logger import LogLevelEnum, logger_init, log_llm_error
|
4
4
|
from .models import (
|
5
5
|
MTRSLabelEnum,
|
6
|
-
ModerationLabelEnum,
|
7
6
|
ChatItem,
|
8
7
|
InnerContextItem,
|
9
8
|
OuterContextItem,
|
10
9
|
ReplicaItem,
|
11
|
-
ReplicaItemPair,
|
12
10
|
)
|
13
11
|
from .models.widget import Widget
|
14
12
|
from .file_storage import FileStorage, ResourceId
|
@@ -1,48 +1,40 @@
|
|
1
1
|
from datetime import datetime
|
2
|
-
from typing import Any
|
2
|
+
from typing import Any, List
|
3
3
|
|
4
|
-
from pydantic import Field, ConfigDict
|
5
4
|
from agi_med_common.models.widget import Widget
|
5
|
+
from pydantic import Field, ConfigDict
|
6
6
|
|
7
|
-
from .enums import ModerationLabelEnum
|
8
7
|
from ._base import _Base
|
9
8
|
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
_DT_FORMAT: str = "%Y-%m-%d-%H-%M-%S"
|
11
|
+
_EXAMPLE_DT_0 = datetime(1970, 1, 1, 0, 0, 0)
|
12
|
+
_EXAMPLE_DT: str = _EXAMPLE_DT_0.strftime(_DT_FORMAT)
|
13
|
+
|
14
|
+
|
15
|
+
def now_pretty() -> str:
|
16
|
+
return datetime.now().strftime(ReplicaItem.DATETIME_FORMAT())
|
14
17
|
|
15
18
|
|
16
19
|
class OuterContextItem(_Base):
|
17
20
|
# remove annoying warning for protected `model_` namespace
|
18
21
|
model_config = ConfigDict(protected_namespaces=())
|
19
22
|
|
20
|
-
sex: bool = Field(
|
21
|
-
False,
|
22
|
-
alias="Sex",
|
23
|
-
description="True = male, False = female",
|
24
|
-
examples=[True]
|
25
|
-
)
|
23
|
+
sex: bool = Field(False, alias="Sex", description="True = male, False = female", examples=[True])
|
26
24
|
age: int = Field(0, alias="Age", examples=[20])
|
27
25
|
user_id: str = Field("", alias="UserId", examples=["123456789"])
|
28
|
-
parent_session_id: str | None = Field(
|
29
|
-
None,
|
30
|
-
alias="ParentSessionId",
|
31
|
-
examples=["987654320"]
|
32
|
-
)
|
26
|
+
parent_session_id: str | None = Field(None, alias="ParentSessionId", examples=["987654320"])
|
33
27
|
session_id: str = Field("", alias="SessionId", examples=["987654321"])
|
34
28
|
client_id: str = Field("", alias="ClientId", examples=["543216789"])
|
35
29
|
track_id: str = Field(default="Consultation", alias="TrackId")
|
36
30
|
entrypoint_key: str = Field("", alias="EntrypointKey", examples=["giga"])
|
37
31
|
language_code: str = Field("ru", alias="LanguageCode", examples=["ru"])
|
38
32
|
|
39
|
-
def create_id(self, short: bool = False
|
33
|
+
def create_id(self, short: bool = False) -> str:
|
40
34
|
uid, sid, cid = self.user_id, self.session_id, self.client_id
|
41
35
|
if short:
|
42
36
|
return f"{uid}_{sid}_{cid}"
|
43
|
-
|
44
|
-
return f"user_{uid}_session_{sid}_client_{cid}"
|
45
|
-
return f"user_{uid}_session_{sid}_client_{cid}_clean"
|
37
|
+
return f"user_{uid}_session_{sid}_client_{cid}"
|
46
38
|
|
47
39
|
def to_dict(self) -> dict[str, Any]:
|
48
40
|
return self.model_dump(by_alias=True)
|
@@ -55,19 +47,12 @@ class ReplicaItem(_Base):
|
|
55
47
|
command: dict | None = Field(None, alias="Command", examples=[None])
|
56
48
|
role: bool = Field(False, alias="Role", description="True = ai, False = client", examples=[False])
|
57
49
|
date_time: str = Field(
|
58
|
-
|
59
|
-
alias="DateTime",
|
60
|
-
examples=[_EXAMPLE_DATETIME],
|
61
|
-
description=f"Format: {_DATETIME_FORMAT}",
|
62
|
-
)
|
63
|
-
state: str = Field("EMPTY", alias="State", description="chat manager fsm state", examples=["COLLECTION"])
|
64
|
-
action: str = Field("START", alias="Action", description="chat manager fsm action", examples=["DIAGNOSIS"])
|
65
|
-
moderation: ModerationLabelEnum = Field(
|
66
|
-
ModerationLabelEnum.OK,
|
67
|
-
alias="Moderation",
|
68
|
-
description="chat manager moderated outcome type",
|
69
|
-
examples=[ModerationLabelEnum.NON_MED],
|
50
|
+
default_factory=now_pretty, alias="DateTime", examples=[_EXAMPLE_DT], description=f"Format: {_DT_FORMAT}"
|
70
51
|
)
|
52
|
+
state: str = Field("", alias="State", description="chat manager fsm state", examples=["COLLECTION"])
|
53
|
+
action: str = Field("", alias="Action", description="chat manager fsm action", examples=["DIAGNOSIS"])
|
54
|
+
# todo fix: support loading from `moderation: int`
|
55
|
+
moderation: str = Field("OK", alias="Moderation", description="moderation outcome", examples=["OK"])
|
71
56
|
extra: dict | None = Field(None, alias="Extra", examples=[None])
|
72
57
|
|
73
58
|
def to_dict(self) -> dict[str, Any]:
|
@@ -75,11 +60,10 @@ class ReplicaItem(_Base):
|
|
75
60
|
|
76
61
|
@staticmethod
|
77
62
|
def DATETIME_FORMAT() -> str:
|
78
|
-
return
|
63
|
+
return _DT_FORMAT
|
79
64
|
|
80
65
|
def with_now_datetime(self):
|
81
|
-
|
82
|
-
return self.model_copy(update=dict(date_time=dt))
|
66
|
+
return self.model_copy(update=dict(date_time=now_pretty()))
|
83
67
|
|
84
68
|
|
85
69
|
class InnerContextItem(_Base):
|
@@ -90,27 +74,22 @@ class InnerContextItem(_Base):
|
|
90
74
|
return self.model_dump(by_alias=True)
|
91
75
|
|
92
76
|
|
93
|
-
class ReplicaItemPair(_Base):
|
94
|
-
# remove annoying warning for protected `model_` namespace
|
95
|
-
model_config = ConfigDict(protected_namespaces=())
|
96
|
-
|
97
|
-
user_replica: ReplicaItem = Field(alias="UserReplica")
|
98
|
-
bot_replica: ReplicaItem = Field(alias="BotReplica")
|
99
|
-
|
100
|
-
|
101
77
|
class ChatItem(_Base):
|
102
78
|
outer_context: OuterContextItem = Field(alias="OuterContext")
|
103
79
|
inner_context: InnerContextItem = Field(alias="InnerContext")
|
104
80
|
|
105
|
-
def create_id(self, short: bool = False
|
106
|
-
return self.outer_context.create_id(short
|
81
|
+
def create_id(self, short: bool = False) -> str:
|
82
|
+
return self.outer_context.create_id(short)
|
107
83
|
|
108
84
|
def to_dict(self) -> dict[str, Any]:
|
109
85
|
return self.model_dump(by_alias=True)
|
110
86
|
|
111
|
-
def
|
112
|
-
self.inner_context.replicas.append(
|
113
|
-
|
87
|
+
def add_replica(self, replica: ReplicaItem):
|
88
|
+
self.inner_context.replicas.append(replica)
|
89
|
+
|
90
|
+
def add_replicas(self, replicas: List[ReplicaItem]):
|
91
|
+
for replica in replicas:
|
92
|
+
self.inner_context.replicas.append(replica)
|
114
93
|
|
115
94
|
def zip_history(self, field: str) -> list[Any]:
|
116
95
|
return [replica.to_dict().get(field, None) for replica in self.inner_context.replicas]
|
@@ -1,17 +1,4 @@
|
|
1
|
-
from enum import
|
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
|
+
from enum import StrEnum, auto
|
15
2
|
|
16
3
|
|
17
4
|
class DoctorChoiceXMLTagEnum(StrEnum):
|
@@ -51,5 +38,3 @@ class DiagnosticsXMLTagEnum(StrEnum):
|
|
51
38
|
DIAG = auto()
|
52
39
|
DOC = auto()
|
53
40
|
DESC = auto()
|
54
|
-
|
55
|
-
|
@@ -1,6 +0,0 @@
|
|
1
|
-
from ._base import _Base
|
2
|
-
|
3
|
-
from .enums import MTRSLabelEnum, ModerationLabelEnum, DiagnosticsXMLTagEnum, MTRSXMLTagEnum, DoctorChoiceXMLTagEnum
|
4
|
-
|
5
|
-
from .chat_item import ChatItem, OuterContextItem, InnerContextItem, ReplicaItem, ReplicaItemPair
|
6
|
-
from .base_config_models import GigaChatConfig
|
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
|
{agi_med_common-4.2.16 → agi_med_common-5.0.0}/src/agi_med_common.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|