agi-med-common 5.0.26__py3-none-any.whl → 5.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.
@@ -1,4 +1,4 @@
1
- __version__ = "5.0.26"
1
+ __version__ = "5.1.0"
2
2
 
3
3
  from .models import (
4
4
  MTRSLabelEnum,
agi_med_common/api.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from typing import List, Tuple
2
2
 
3
- from agi_med_common.models import ChatItem, ReplicaItem, DomainInfo, TrackInfo
3
+ from agi_med_common.models import Chat, ChatMessage, DomainInfo, TrackInfo
4
4
  from pydantic import BaseModel
5
5
 
6
6
 
@@ -16,12 +16,12 @@ class ChatManagerAPI:
16
16
  def get_tracks(self, language_code: str, client_id: str) -> List[TrackInfo]:
17
17
  raise NotImplementedError
18
18
 
19
- def get_response(self, chat: ChatItem, request_id: str = "") -> List[ReplicaItem]:
19
+ def get_response(self, chat: Chat, request_id: str = "") -> List[ChatMessage]:
20
20
  raise NotImplementedError
21
21
 
22
22
 
23
23
  class TextGeneratorAPI:
24
- def process(self, chat: ChatItem, request_id: str = "") -> str:
24
+ def process(self, chat: Chat, request_id: str = "") -> str:
25
25
  raise NotImplementedError
26
26
 
27
27
 
@@ -37,7 +37,7 @@ class ContentInterpreterRemoteAPI:
37
37
  kind: str,
38
38
  query: str,
39
39
  resource: bytes,
40
- chat: ChatItem | None = None,
40
+ chat: Chat | None = None,
41
41
  request_id: str = "",
42
42
  ) -> ContentInterpreterRemoteResponse:
43
43
  raise NotImplementedError
@@ -47,22 +47,22 @@ class ClassifierAPI:
47
47
  def get_values(self) -> List[Value]:
48
48
  raise NotImplementedError
49
49
 
50
- def evaluate(self, chat: ChatItem, request_id: str = "") -> Value:
50
+ def evaluate(self, chat: Chat, request_id: str = "") -> Value:
51
51
  raise NotImplementedError
52
52
 
53
53
 
54
54
  class CriticAPI:
55
- def evaluate(self, text: str, chat: ChatItem | None = None, request_id: str = "") -> float:
55
+ def evaluate(self, text: str, chat: Chat | None = None, request_id: str = "") -> float:
56
56
  raise NotImplementedError
57
57
 
58
58
 
59
59
  class ContentInterpreterAPI:
60
60
  def interpret(
61
- self, kind: str, query: str, resource_id: str = "", chat: ChatItem | None = None, request_id: str = ""
61
+ self, kind: str, query: str, resource_id: str = "", chat: Chat | None = None, request_id: str = ""
62
62
  ) -> Tuple[Interpretation, ResourceId | None]:
63
63
  raise NotImplementedError
64
64
 
65
65
 
66
66
  class TextProcessorAPI:
67
- def process(self, text: str, chat: ChatItem | None = None, request_id: str = "") -> str:
67
+ def process(self, text: str, chat: Chat | None = None, request_id: str = "") -> str:
68
68
  raise NotImplementedError
@@ -207,9 +207,10 @@ class Chat(_Base):
207
207
  return self.model_copy(update=dict(messages=messages))
208
208
 
209
209
  def get_last_state(self, default: str = "empty") -> str:
210
- for msg in range(self.messages - 1, -1, -1):
211
- if isinstance(msg, AIMessage):
212
- return msg.state
210
+ for ii in range(len(self.messages) - 1, -1, -1):
211
+ message = self.messages[ii]
212
+ if isinstance(message, AIMessage):
213
+ return message.state
213
214
  return default
214
215
 
215
216
 
@@ -133,6 +133,15 @@ class ChatItem(_Base):
133
133
  def replace_replicas(self, replicas: List[ReplicaItem]):
134
134
  return self.model_copy(update=dict(inner_context=InnerContextItem(replicas=replicas)))
135
135
 
136
+ def get_last_state(self, default: str = "empty") -> str:
137
+ replicas = self.inner_context.replicas
138
+ for ii in range(len(replicas) - 1, -1, -1):
139
+ replica = replicas[ii]
140
+ if replica.role:
141
+ return replica.state
142
+ return default
143
+
144
+
136
145
  def zip_history(self, field: str) -> list[Any]:
137
146
  return [replica.to_dict().get(field, None) for replica in self.inner_context.replicas]
138
147
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agi_med_common
3
- Version: 5.0.26
3
+ Version: 5.1.0
4
4
  Summary: Сommon for agi-med team
5
5
  Author: AGI-MED-TEAM
6
6
  Requires-Python: >=3.11
@@ -1,6 +1,5 @@
1
- agi_med_common/__init__.py,sha256=3iqTNDjcukCgm6cnLY8vQaom03mBn2KH-MPxaVOM4y0,740
2
- agi_med_common/api.py,sha256=kGLKiebbF91s_7V2S55ETS7R6tQgZNkoFMoawdjeMYw,1860
3
- agi_med_common/api_v2.py,sha256=gj6BPEAOvpT6GHWeE7bzmKIR-pvq0yORZ3L0ADvI8ps,1828
1
+ agi_med_common/__init__.py,sha256=8FdoVXkVoK3EoCnW_WIYfEePasHves8Xw7q1Jj6_8wM,739
2
+ agi_med_common/api.py,sha256=gj6BPEAOvpT6GHWeE7bzmKIR-pvq0yORZ3L0ADvI8ps,1828
4
3
  agi_med_common/file_storage.py,sha256=T0Hbs4W-pWO6HdWcmlVqABrQHYdq7lLZH4_Vu-YNVbw,1802
5
4
  agi_med_common/parallel_map.py,sha256=Qx6xe7DqlEUDpSucp5Hm8r9y9Iquwh9JvX7lOqHhnOw,921
6
5
  agi_med_common/type_union.py,sha256=diwmzcnbqkpGFckPHNw9o8zyQ955mOGNvhTlcBJ0RMI,1905
@@ -9,14 +8,14 @@ agi_med_common/validators.py,sha256=vMoPN42XzC8re-zdjekk5_lNQYHuTiAWD56YLvj2Z2w,
9
8
  agi_med_common/xml_parser.py,sha256=VvLIX_XCZao9i0qqpTVx8nx0vbFXSe8pEbdJdXnj97g,568
10
9
  agi_med_common/models/__init__.py,sha256=dqr2kP-RuxFfAZhCr103PQzTVZFKIcdxyzTYiHhdTsE,375
11
10
  agi_med_common/models/_base.py,sha256=qNdH8x3x3mYbo5XgWtR9VpEarxsEvXvzynadUlDvHmU,149
12
- agi_med_common/models/chat.py,sha256=1GVcwOM97UMrsiPg3fAd9xJe2p9cHouidWgIPMWUxc0,10668
13
- agi_med_common/models/chat_item.py,sha256=eTUBCLlTVPqIS64qnaPB92vCJyiBixIPi8ochrgOPHo,5262
11
+ agi_med_common/models/chat.py,sha256=lj6nxxsk0ng_1bhlakHqR_51ho7JonN2-2kYYhVpSxU,10720
12
+ agi_med_common/models/chat_item.py,sha256=QlJ5Q40eX7lEeH9YBmdTH71ugrEtsU-4thkhD8cJhu0,5548
14
13
  agi_med_common/models/enums.py,sha256=J-GNpql9MCnKnWiV9aJRQGI-pAybvV86923RZs99grA,1006
15
14
  agi_med_common/models/tracks.py,sha256=UP-jeWqDiCK6dyoMDfs7hemgl_xsJKee_DApjBf-XYc,311
16
15
  agi_med_common/models/widget.py,sha256=aJZ2vWx_PTFN02Wz16eokz9IIVrxqNuZYVDqLG36toE,710
17
16
  agi_med_common/models/base_config_models/__init__.py,sha256=KjS_bSCka8BOMsigwcIML-e6eNB2ouMU6gxlhRmzeuY,44
18
17
  agi_med_common/models/base_config_models/gigachat_config.py,sha256=WNSCTO8Fjpxc1v2LRUHfKqo9aeMDpXltTHYBFgTD2N0,422
19
- agi_med_common-5.0.26.dist-info/METADATA,sha256=wlJpGlj3NNyi2UvSjBx9z8474Nysj20mMfbOmVyhNO0,518
20
- agi_med_common-5.0.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
- agi_med_common-5.0.26.dist-info/top_level.txt,sha256=26o565jF_7wYQj7-YJfTedtT9yDxDcf8RNikOYuPq78,15
22
- agi_med_common-5.0.26.dist-info/RECORD,,
18
+ agi_med_common-5.1.0.dist-info/METADATA,sha256=wh-abOnVCcW_TqVKFyNXNnjXR_adZlPcC-LuRcAkujQ,517
19
+ agi_med_common-5.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ agi_med_common-5.1.0.dist-info/top_level.txt,sha256=26o565jF_7wYQj7-YJfTedtT9yDxDcf8RNikOYuPq78,15
21
+ agi_med_common-5.1.0.dist-info/RECORD,,
agi_med_common/api_v2.py DELETED
@@ -1,68 +0,0 @@
1
- from typing import List, Tuple
2
-
3
- from agi_med_common.models import Chat, ChatMessage, DomainInfo, TrackInfo
4
- from pydantic import BaseModel
5
-
6
-
7
- Value = str
8
- Interpretation = str
9
- ResourceId = str
10
-
11
-
12
- class ChatManagerAPI:
13
- def get_domains(self, language_code: str, client_id: str) -> List[DomainInfo]:
14
- raise NotImplementedError
15
-
16
- def get_tracks(self, language_code: str, client_id: str) -> List[TrackInfo]:
17
- raise NotImplementedError
18
-
19
- def get_response(self, chat: Chat, request_id: str = "") -> List[ChatMessage]:
20
- raise NotImplementedError
21
-
22
-
23
- class TextGeneratorAPI:
24
- def process(self, chat: Chat, request_id: str = "") -> str:
25
- raise NotImplementedError
26
-
27
-
28
- class ContentInterpreterRemoteResponse(BaseModel):
29
- interpretation: str
30
- resource_fname: str
31
- resource: bytes
32
-
33
-
34
- class ContentInterpreterRemoteAPI:
35
- def interpret_remote(
36
- self,
37
- kind: str,
38
- query: str,
39
- resource: bytes,
40
- chat: Chat | None = None,
41
- request_id: str = "",
42
- ) -> ContentInterpreterRemoteResponse:
43
- raise NotImplementedError
44
-
45
-
46
- class ClassifierAPI:
47
- def get_values(self) -> List[Value]:
48
- raise NotImplementedError
49
-
50
- def evaluate(self, chat: Chat, request_id: str = "") -> Value:
51
- raise NotImplementedError
52
-
53
-
54
- class CriticAPI:
55
- def evaluate(self, text: str, chat: Chat | None = None, request_id: str = "") -> float:
56
- raise NotImplementedError
57
-
58
-
59
- class ContentInterpreterAPI:
60
- def interpret(
61
- self, kind: str, query: str, resource_id: str = "", chat: Chat | None = None, request_id: str = ""
62
- ) -> Tuple[Interpretation, ResourceId | None]:
63
- raise NotImplementedError
64
-
65
-
66
- class TextProcessorAPI:
67
- def process(self, text: str, chat: Chat | None = None, request_id: str = "") -> str:
68
- raise NotImplementedError