unique_toolkit 0.8.28__py3-none-any.whl → 0.8.30__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.
- unique_toolkit/app/schemas.py +4 -0
- unique_toolkit/chat/functions.py +467 -0
- unique_toolkit/chat/schemas.py +70 -0
- unique_toolkit/chat/service.py +569 -0
- unique_toolkit/tools/a2a/__init__.py +4 -0
- unique_toolkit/tools/a2a/config.py +29 -0
- unique_toolkit/tools/a2a/manager.py +50 -0
- unique_toolkit/tools/a2a/memory.py +27 -0
- unique_toolkit/tools/a2a/schema.py +15 -0
- unique_toolkit/tools/a2a/service.py +154 -0
- unique_toolkit/tools/config.py +1 -0
- unique_toolkit/tools/mcp/models.py +0 -1
- unique_toolkit/tools/test/test_mcp_manager.py +55 -1
- unique_toolkit/tools/tool_manager.py +10 -1
- {unique_toolkit-0.8.28.dist-info → unique_toolkit-0.8.30.dist-info}/METADATA +11 -1
- {unique_toolkit-0.8.28.dist-info → unique_toolkit-0.8.30.dist-info}/RECORD +18 -12
- {unique_toolkit-0.8.28.dist-info → unique_toolkit-0.8.30.dist-info}/LICENSE +0 -0
- {unique_toolkit-0.8.28.dist-info → unique_toolkit-0.8.30.dist-info}/WHEEL +0 -0
unique_toolkit/chat/service.py
CHANGED
|
@@ -14,13 +14,23 @@ from unique_toolkit.chat.functions import (
|
|
|
14
14
|
create_message_assessment,
|
|
15
15
|
create_message_assessment_async,
|
|
16
16
|
create_message_async,
|
|
17
|
+
create_message_execution,
|
|
18
|
+
create_message_execution_async,
|
|
19
|
+
create_message_log,
|
|
20
|
+
create_message_log_async,
|
|
17
21
|
get_full_history,
|
|
18
22
|
get_full_history_async,
|
|
23
|
+
get_message_execution,
|
|
24
|
+
get_message_execution_async,
|
|
19
25
|
get_selection_from_history,
|
|
20
26
|
modify_message,
|
|
21
27
|
modify_message_assessment,
|
|
22
28
|
modify_message_assessment_async,
|
|
23
29
|
modify_message_async,
|
|
30
|
+
update_message_execution,
|
|
31
|
+
update_message_execution_async,
|
|
32
|
+
update_message_log,
|
|
33
|
+
update_message_log_async,
|
|
24
34
|
)
|
|
25
35
|
from unique_toolkit.chat.schemas import (
|
|
26
36
|
ChatMessage,
|
|
@@ -29,6 +39,13 @@ from unique_toolkit.chat.schemas import (
|
|
|
29
39
|
ChatMessageAssessmentStatus,
|
|
30
40
|
ChatMessageAssessmentType,
|
|
31
41
|
ChatMessageRole,
|
|
42
|
+
MessageExecution,
|
|
43
|
+
MessageExecutionType,
|
|
44
|
+
MessageExecutionUpdateStatus,
|
|
45
|
+
MessageLog,
|
|
46
|
+
MessageLogDetails,
|
|
47
|
+
MessageLogStatus,
|
|
48
|
+
MessageLogUncitedReferences,
|
|
32
49
|
)
|
|
33
50
|
from unique_toolkit.content.schemas import ContentChunk, ContentReference
|
|
34
51
|
from unique_toolkit.language_model.constants import (
|
|
@@ -896,6 +913,558 @@ class ChatService:
|
|
|
896
913
|
label=label,
|
|
897
914
|
)
|
|
898
915
|
|
|
916
|
+
def create_message_log(
|
|
917
|
+
self,
|
|
918
|
+
message_id: str,
|
|
919
|
+
text: str,
|
|
920
|
+
status: MessageLogStatus,
|
|
921
|
+
order: int,
|
|
922
|
+
details: MessageLogDetails | None = None,
|
|
923
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
924
|
+
references: list[ContentReference] | None = None,
|
|
925
|
+
) -> MessageLog:
|
|
926
|
+
"""Creates a message log for tracking execution steps synchronously.
|
|
927
|
+
|
|
928
|
+
Args:
|
|
929
|
+
message_id (str): The ID of the message this log belongs to
|
|
930
|
+
text (str): The log text content
|
|
931
|
+
status (MessageLogStatus): The status of this log entry
|
|
932
|
+
order (int): The order/sequence number of this log entry
|
|
933
|
+
details (MessageLogDetails | None): Additional details about this log entry
|
|
934
|
+
uncited_references (MessageLogUncitedReferences | None): References that are not cited
|
|
935
|
+
references (list[ContentReference] | None): List of references for this log
|
|
936
|
+
|
|
937
|
+
Returns:
|
|
938
|
+
MessageLog: The created message log
|
|
939
|
+
|
|
940
|
+
Raises:
|
|
941
|
+
Exception: If the creation fails
|
|
942
|
+
|
|
943
|
+
"""
|
|
944
|
+
return create_message_log(
|
|
945
|
+
user_id=self._user_id,
|
|
946
|
+
company_id=self._company_id,
|
|
947
|
+
message_id=message_id,
|
|
948
|
+
text=text,
|
|
949
|
+
status=status,
|
|
950
|
+
order=order,
|
|
951
|
+
details=details,
|
|
952
|
+
uncited_references=uncited_references,
|
|
953
|
+
references=references,
|
|
954
|
+
)
|
|
955
|
+
|
|
956
|
+
async def create_message_log_async(
|
|
957
|
+
self,
|
|
958
|
+
message_id: str,
|
|
959
|
+
text: str,
|
|
960
|
+
status: MessageLogStatus,
|
|
961
|
+
order: int,
|
|
962
|
+
details: MessageLogDetails | None = None,
|
|
963
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
964
|
+
references: list[ContentReference] | None = None,
|
|
965
|
+
) -> MessageLog:
|
|
966
|
+
"""Creates a message log for tracking execution steps asynchronously.
|
|
967
|
+
|
|
968
|
+
Args:
|
|
969
|
+
message_id (str): The ID of the message this log belongs to
|
|
970
|
+
text (str): The log text content
|
|
971
|
+
status (MessageLogStatus): The status of this log entry
|
|
972
|
+
order (int): The order/sequence number of this log entry
|
|
973
|
+
details (MessageLogDetails | None): Additional details about this log entry
|
|
974
|
+
uncited_references (MessageLogUncitedReferences | None): References that are not cited
|
|
975
|
+
references (list[ContentReference] | None): List of references for this log
|
|
976
|
+
|
|
977
|
+
Returns:
|
|
978
|
+
MessageLog: The created message log
|
|
979
|
+
|
|
980
|
+
Raises:
|
|
981
|
+
Exception: If the creation fails
|
|
982
|
+
|
|
983
|
+
"""
|
|
984
|
+
return await create_message_log_async(
|
|
985
|
+
user_id=self._user_id,
|
|
986
|
+
company_id=self._company_id,
|
|
987
|
+
message_id=message_id,
|
|
988
|
+
text=text,
|
|
989
|
+
status=status,
|
|
990
|
+
order=order,
|
|
991
|
+
details=details,
|
|
992
|
+
uncited_references=uncited_references,
|
|
993
|
+
references=references,
|
|
994
|
+
)
|
|
995
|
+
|
|
996
|
+
def update_message_log(
|
|
997
|
+
self,
|
|
998
|
+
message_log_id: str,
|
|
999
|
+
order: int,
|
|
1000
|
+
text: str | None = None,
|
|
1001
|
+
status: MessageLogStatus | None = None,
|
|
1002
|
+
details: MessageLogDetails | None = None,
|
|
1003
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
1004
|
+
references: list[ContentReference] | None = None,
|
|
1005
|
+
) -> MessageLog:
|
|
1006
|
+
"""Updates a message log synchronously.
|
|
1007
|
+
|
|
1008
|
+
Args:
|
|
1009
|
+
message_log_id (str): The ID of the message log to update
|
|
1010
|
+
order (int): The order/sequence number (required)
|
|
1011
|
+
text (str | None): The updated log text content
|
|
1012
|
+
status (MessageLogStatus | None): The updated status
|
|
1013
|
+
details (MessageLogDetails | None): Updated additional details
|
|
1014
|
+
uncited_references (MessageLogUncitedReferences | None): Updated uncited references
|
|
1015
|
+
references (list[ContentReference] | None): Updated list of references
|
|
1016
|
+
|
|
1017
|
+
Returns:
|
|
1018
|
+
MessageLog: The updated message log
|
|
1019
|
+
|
|
1020
|
+
Raises:
|
|
1021
|
+
Exception: If the update fails
|
|
1022
|
+
|
|
1023
|
+
"""
|
|
1024
|
+
return update_message_log(
|
|
1025
|
+
user_id=self._user_id,
|
|
1026
|
+
company_id=self._company_id,
|
|
1027
|
+
message_log_id=message_log_id,
|
|
1028
|
+
order=order,
|
|
1029
|
+
text=text,
|
|
1030
|
+
status=status,
|
|
1031
|
+
details=details,
|
|
1032
|
+
uncited_references=uncited_references,
|
|
1033
|
+
references=references,
|
|
1034
|
+
)
|
|
1035
|
+
|
|
1036
|
+
async def update_message_log_async(
|
|
1037
|
+
self,
|
|
1038
|
+
message_log_id: str,
|
|
1039
|
+
order: int,
|
|
1040
|
+
text: str | None = None,
|
|
1041
|
+
status: MessageLogStatus | None = None,
|
|
1042
|
+
details: MessageLogDetails | None = None,
|
|
1043
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
1044
|
+
references: list[ContentReference] | None = None,
|
|
1045
|
+
) -> MessageLog:
|
|
1046
|
+
"""Updates a message log asynchronously.
|
|
1047
|
+
|
|
1048
|
+
Args:
|
|
1049
|
+
message_log_id (str): The ID of the message log to update
|
|
1050
|
+
order (int): The order/sequence number (required)
|
|
1051
|
+
text (str | None): The updated log text content
|
|
1052
|
+
status (MessageLogStatus | None): The updated status
|
|
1053
|
+
details (MessageLogDetails | None): Updated additional details
|
|
1054
|
+
uncited_references (MessageLogUncitedReferences | None): Updated uncited references
|
|
1055
|
+
references (list[ContentReference] | None): Updated list of references
|
|
1056
|
+
|
|
1057
|
+
Returns:
|
|
1058
|
+
MessageLog: The updated message log
|
|
1059
|
+
|
|
1060
|
+
Raises:
|
|
1061
|
+
Exception: If the update fails
|
|
1062
|
+
|
|
1063
|
+
"""
|
|
1064
|
+
return await update_message_log_async(
|
|
1065
|
+
user_id=self._user_id,
|
|
1066
|
+
company_id=self._company_id,
|
|
1067
|
+
message_log_id=message_log_id,
|
|
1068
|
+
order=order,
|
|
1069
|
+
text=text,
|
|
1070
|
+
status=status,
|
|
1071
|
+
details=details,
|
|
1072
|
+
uncited_references=uncited_references,
|
|
1073
|
+
references=references,
|
|
1074
|
+
)
|
|
1075
|
+
|
|
1076
|
+
def create_assistant_message_log(
|
|
1077
|
+
self,
|
|
1078
|
+
text: str,
|
|
1079
|
+
status: MessageLogStatus,
|
|
1080
|
+
order: int,
|
|
1081
|
+
details: MessageLogDetails | None = None,
|
|
1082
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
1083
|
+
references: list[ContentReference] | None = None,
|
|
1084
|
+
) -> MessageLog:
|
|
1085
|
+
"""Creates a message log for the current assistant message synchronously.
|
|
1086
|
+
|
|
1087
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1088
|
+
|
|
1089
|
+
Args:
|
|
1090
|
+
text (str): The log text content
|
|
1091
|
+
status (MessageLogStatus): The status of this log entry
|
|
1092
|
+
order (int): The order/sequence number of this log entry
|
|
1093
|
+
details (MessageLogDetails | None): Additional details about this log entry
|
|
1094
|
+
uncited_references (MessageLogUncitedReferences | None): References that are not cited
|
|
1095
|
+
references (list[ContentReference] | None): List of references for this log
|
|
1096
|
+
|
|
1097
|
+
Returns:
|
|
1098
|
+
MessageLog: The created message log
|
|
1099
|
+
|
|
1100
|
+
Raises:
|
|
1101
|
+
Exception: If the creation fails
|
|
1102
|
+
|
|
1103
|
+
"""
|
|
1104
|
+
return self.create_message_log(
|
|
1105
|
+
message_id=self._assistant_message_id,
|
|
1106
|
+
text=text,
|
|
1107
|
+
status=status,
|
|
1108
|
+
order=order,
|
|
1109
|
+
details=details,
|
|
1110
|
+
uncited_references=uncited_references,
|
|
1111
|
+
references=references,
|
|
1112
|
+
)
|
|
1113
|
+
|
|
1114
|
+
async def create_assistant_message_log_async(
|
|
1115
|
+
self,
|
|
1116
|
+
text: str,
|
|
1117
|
+
status: MessageLogStatus,
|
|
1118
|
+
order: int,
|
|
1119
|
+
details: MessageLogDetails | None = None,
|
|
1120
|
+
uncited_references: MessageLogUncitedReferences | None = None,
|
|
1121
|
+
references: list[ContentReference] | None = None,
|
|
1122
|
+
) -> MessageLog:
|
|
1123
|
+
"""Creates a message log for the current assistant message asynchronously.
|
|
1124
|
+
|
|
1125
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1126
|
+
|
|
1127
|
+
Args:
|
|
1128
|
+
text (str): The log text content
|
|
1129
|
+
status (MessageLogStatus): The status of this log entry
|
|
1130
|
+
order (int): The order/sequence number of this log entry
|
|
1131
|
+
details (MessageLogDetails | None): Additional details about this log entry
|
|
1132
|
+
uncited_references (MessageLogUncitedReferences | None): References that are not cited
|
|
1133
|
+
references (list[ContentReference] | None): List of references for this log
|
|
1134
|
+
|
|
1135
|
+
Returns:
|
|
1136
|
+
MessageLog: The created message log
|
|
1137
|
+
|
|
1138
|
+
Raises:
|
|
1139
|
+
Exception: If the creation fails
|
|
1140
|
+
|
|
1141
|
+
"""
|
|
1142
|
+
return await self.create_message_log_async(
|
|
1143
|
+
message_id=self._assistant_message_id,
|
|
1144
|
+
text=text,
|
|
1145
|
+
status=status,
|
|
1146
|
+
order=order,
|
|
1147
|
+
details=details,
|
|
1148
|
+
uncited_references=uncited_references,
|
|
1149
|
+
references=references,
|
|
1150
|
+
)
|
|
1151
|
+
|
|
1152
|
+
def create_message_execution(
|
|
1153
|
+
self,
|
|
1154
|
+
message_id: str,
|
|
1155
|
+
type: MessageExecutionType = MessageExecutionType.DEEP_RESEARCH,
|
|
1156
|
+
seconds_remaining: int | None = None,
|
|
1157
|
+
percentage_completed: int | None = None,
|
|
1158
|
+
) -> MessageExecution:
|
|
1159
|
+
"""Creates a message execution for tracking long-running operations synchronously.
|
|
1160
|
+
|
|
1161
|
+
Args:
|
|
1162
|
+
message_id (str): The ID of the message this execution belongs to
|
|
1163
|
+
type (MessageExecutionType): The type of execution. Defaults to DEEP_RESEARCH.
|
|
1164
|
+
seconds_remaining (int | None): Estimated seconds remaining for completion
|
|
1165
|
+
percentage_completed (int | None): Percentage of completion (0-100)
|
|
1166
|
+
|
|
1167
|
+
Returns:
|
|
1168
|
+
MessageExecution: The created message execution
|
|
1169
|
+
|
|
1170
|
+
Raises:
|
|
1171
|
+
Exception: If the creation fails
|
|
1172
|
+
|
|
1173
|
+
"""
|
|
1174
|
+
return create_message_execution(
|
|
1175
|
+
user_id=self._user_id,
|
|
1176
|
+
company_id=self._company_id,
|
|
1177
|
+
message_id=message_id,
|
|
1178
|
+
chat_id=self._chat_id,
|
|
1179
|
+
type=type,
|
|
1180
|
+
seconds_remaining=seconds_remaining,
|
|
1181
|
+
percentage_completed=percentage_completed,
|
|
1182
|
+
)
|
|
1183
|
+
|
|
1184
|
+
async def create_message_execution_async(
|
|
1185
|
+
self,
|
|
1186
|
+
message_id: str,
|
|
1187
|
+
type: MessageExecutionType = MessageExecutionType.DEEP_RESEARCH,
|
|
1188
|
+
seconds_remaining: int | None = None,
|
|
1189
|
+
percentage_completed: int | None = None,
|
|
1190
|
+
) -> MessageExecution:
|
|
1191
|
+
"""Creates a message execution for tracking long-running operations asynchronously.
|
|
1192
|
+
|
|
1193
|
+
Args:
|
|
1194
|
+
message_id (str): The ID of the message this execution belongs to
|
|
1195
|
+
type (MessageExecutionType): The type of execution. Defaults to DEEP_RESEARCH.
|
|
1196
|
+
seconds_remaining (int | None): Estimated seconds remaining for completion
|
|
1197
|
+
percentage_completed (int | None): Percentage of completion (0-100)
|
|
1198
|
+
|
|
1199
|
+
Returns:
|
|
1200
|
+
MessageExecution: The created message execution
|
|
1201
|
+
|
|
1202
|
+
Raises:
|
|
1203
|
+
Exception: If the creation fails
|
|
1204
|
+
|
|
1205
|
+
"""
|
|
1206
|
+
return await create_message_execution_async(
|
|
1207
|
+
user_id=self._user_id,
|
|
1208
|
+
company_id=self._company_id,
|
|
1209
|
+
message_id=message_id,
|
|
1210
|
+
chat_id=self._chat_id,
|
|
1211
|
+
type=type,
|
|
1212
|
+
seconds_remaining=seconds_remaining,
|
|
1213
|
+
percentage_completed=percentage_completed,
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1216
|
+
def get_message_execution(
|
|
1217
|
+
self,
|
|
1218
|
+
message_id: str,
|
|
1219
|
+
) -> MessageExecution:
|
|
1220
|
+
"""Gets a message execution by message ID synchronously.
|
|
1221
|
+
|
|
1222
|
+
Args:
|
|
1223
|
+
message_id (str): The ID of the message to get execution for
|
|
1224
|
+
|
|
1225
|
+
Returns:
|
|
1226
|
+
MessageExecution: The message execution
|
|
1227
|
+
|
|
1228
|
+
Raises:
|
|
1229
|
+
Exception: If the retrieval fails
|
|
1230
|
+
|
|
1231
|
+
"""
|
|
1232
|
+
return get_message_execution(
|
|
1233
|
+
user_id=self._user_id,
|
|
1234
|
+
company_id=self._company_id,
|
|
1235
|
+
message_id=message_id,
|
|
1236
|
+
)
|
|
1237
|
+
|
|
1238
|
+
async def get_message_execution_async(
|
|
1239
|
+
self,
|
|
1240
|
+
message_id: str,
|
|
1241
|
+
) -> MessageExecution:
|
|
1242
|
+
"""Gets a message execution by message ID asynchronously.
|
|
1243
|
+
|
|
1244
|
+
Args:
|
|
1245
|
+
message_id (str): The ID of the message to get execution for
|
|
1246
|
+
|
|
1247
|
+
Returns:
|
|
1248
|
+
MessageExecution: The message execution
|
|
1249
|
+
|
|
1250
|
+
Raises:
|
|
1251
|
+
Exception: If the retrieval fails
|
|
1252
|
+
|
|
1253
|
+
"""
|
|
1254
|
+
return await get_message_execution_async(
|
|
1255
|
+
user_id=self._user_id,
|
|
1256
|
+
company_id=self._company_id,
|
|
1257
|
+
message_id=message_id,
|
|
1258
|
+
)
|
|
1259
|
+
|
|
1260
|
+
def update_message_execution(
|
|
1261
|
+
self,
|
|
1262
|
+
message_id: str,
|
|
1263
|
+
status: MessageExecutionUpdateStatus,
|
|
1264
|
+
seconds_remaining: int | None = None,
|
|
1265
|
+
percentage_completed: int | None = None,
|
|
1266
|
+
) -> MessageExecution:
|
|
1267
|
+
"""Updates a message execution synchronously.
|
|
1268
|
+
|
|
1269
|
+
Args:
|
|
1270
|
+
message_id (str): The ID of the message to update execution for
|
|
1271
|
+
status (MessageExecutionUpdateStatus): The updated status (COMPLETED or FAILED)
|
|
1272
|
+
seconds_remaining (int | None): Updated estimated seconds remaining
|
|
1273
|
+
percentage_completed (int | None): Updated percentage of completion (0-100)
|
|
1274
|
+
|
|
1275
|
+
Returns:
|
|
1276
|
+
MessageExecution: The updated message execution
|
|
1277
|
+
|
|
1278
|
+
Raises:
|
|
1279
|
+
Exception: If the update fails
|
|
1280
|
+
|
|
1281
|
+
"""
|
|
1282
|
+
return update_message_execution(
|
|
1283
|
+
user_id=self._user_id,
|
|
1284
|
+
company_id=self._company_id,
|
|
1285
|
+
message_id=message_id,
|
|
1286
|
+
status=status,
|
|
1287
|
+
seconds_remaining=seconds_remaining,
|
|
1288
|
+
percentage_completed=percentage_completed,
|
|
1289
|
+
)
|
|
1290
|
+
|
|
1291
|
+
async def update_message_execution_async(
|
|
1292
|
+
self,
|
|
1293
|
+
message_id: str,
|
|
1294
|
+
status: MessageExecutionUpdateStatus,
|
|
1295
|
+
seconds_remaining: int | None = None,
|
|
1296
|
+
percentage_completed: int | None = None,
|
|
1297
|
+
) -> MessageExecution:
|
|
1298
|
+
"""Updates a message execution asynchronously.
|
|
1299
|
+
|
|
1300
|
+
Args:
|
|
1301
|
+
message_id (str): The ID of the message to update execution for
|
|
1302
|
+
status (MessageExecutionUpdateStatus): The updated status (COMPLETED or FAILED)
|
|
1303
|
+
seconds_remaining (int | None): Updated estimated seconds remaining
|
|
1304
|
+
percentage_completed (int | None): Updated percentage of completion (0-100)
|
|
1305
|
+
|
|
1306
|
+
Returns:
|
|
1307
|
+
MessageExecution: The updated message execution
|
|
1308
|
+
|
|
1309
|
+
Raises:
|
|
1310
|
+
Exception: If the update fails
|
|
1311
|
+
|
|
1312
|
+
"""
|
|
1313
|
+
return await update_message_execution_async(
|
|
1314
|
+
user_id=self._user_id,
|
|
1315
|
+
company_id=self._company_id,
|
|
1316
|
+
message_id=message_id,
|
|
1317
|
+
status=status,
|
|
1318
|
+
seconds_remaining=seconds_remaining,
|
|
1319
|
+
percentage_completed=percentage_completed,
|
|
1320
|
+
)
|
|
1321
|
+
|
|
1322
|
+
def create_assistant_message_execution(
|
|
1323
|
+
self,
|
|
1324
|
+
type: MessageExecutionType = MessageExecutionType.DEEP_RESEARCH,
|
|
1325
|
+
seconds_remaining: int | None = None,
|
|
1326
|
+
percentage_completed: int | None = None,
|
|
1327
|
+
) -> MessageExecution:
|
|
1328
|
+
"""Creates a message execution for the current assistant message synchronously.
|
|
1329
|
+
|
|
1330
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1331
|
+
|
|
1332
|
+
Args:
|
|
1333
|
+
type (MessageExecutionType): The type of execution. Defaults to DEEP_RESEARCH.
|
|
1334
|
+
seconds_remaining (int | None): Estimated seconds remaining for completion
|
|
1335
|
+
percentage_completed (int | None): Percentage of completion (0-100)
|
|
1336
|
+
|
|
1337
|
+
Returns:
|
|
1338
|
+
MessageExecution: The created message execution
|
|
1339
|
+
|
|
1340
|
+
Raises:
|
|
1341
|
+
Exception: If the creation fails
|
|
1342
|
+
|
|
1343
|
+
"""
|
|
1344
|
+
return self.create_message_execution(
|
|
1345
|
+
message_id=self._assistant_message_id,
|
|
1346
|
+
type=type,
|
|
1347
|
+
seconds_remaining=seconds_remaining,
|
|
1348
|
+
percentage_completed=percentage_completed,
|
|
1349
|
+
)
|
|
1350
|
+
|
|
1351
|
+
async def create_assistant_message_execution_async(
|
|
1352
|
+
self,
|
|
1353
|
+
type: MessageExecutionType = MessageExecutionType.DEEP_RESEARCH,
|
|
1354
|
+
seconds_remaining: int | None = None,
|
|
1355
|
+
percentage_completed: int | None = None,
|
|
1356
|
+
) -> MessageExecution:
|
|
1357
|
+
"""Creates a message execution for the current assistant message asynchronously.
|
|
1358
|
+
|
|
1359
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1360
|
+
|
|
1361
|
+
Args:
|
|
1362
|
+
type (MessageExecutionType): The type of execution. Defaults to DEEP_RESEARCH.
|
|
1363
|
+
seconds_remaining (int | None): Estimated seconds remaining for completion
|
|
1364
|
+
percentage_completed (int | None): Percentage of completion (0-100)
|
|
1365
|
+
|
|
1366
|
+
Returns:
|
|
1367
|
+
MessageExecution: The created message execution
|
|
1368
|
+
|
|
1369
|
+
Raises:
|
|
1370
|
+
Exception: If the creation fails
|
|
1371
|
+
|
|
1372
|
+
"""
|
|
1373
|
+
return await self.create_message_execution_async(
|
|
1374
|
+
message_id=self._assistant_message_id,
|
|
1375
|
+
type=type,
|
|
1376
|
+
seconds_remaining=seconds_remaining,
|
|
1377
|
+
percentage_completed=percentage_completed,
|
|
1378
|
+
)
|
|
1379
|
+
|
|
1380
|
+
def get_assistant_message_execution(self) -> MessageExecution:
|
|
1381
|
+
"""Gets the message execution for the current assistant message synchronously.
|
|
1382
|
+
|
|
1383
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1384
|
+
|
|
1385
|
+
Returns:
|
|
1386
|
+
MessageExecution: The message execution
|
|
1387
|
+
|
|
1388
|
+
Raises:
|
|
1389
|
+
Exception: If the retrieval fails
|
|
1390
|
+
|
|
1391
|
+
"""
|
|
1392
|
+
return self.get_message_execution(message_id=self._assistant_message_id)
|
|
1393
|
+
|
|
1394
|
+
async def get_assistant_message_execution_async(self) -> MessageExecution:
|
|
1395
|
+
"""Gets the message execution for the current assistant message asynchronously.
|
|
1396
|
+
|
|
1397
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1398
|
+
|
|
1399
|
+
Returns:
|
|
1400
|
+
MessageExecution: The message execution
|
|
1401
|
+
|
|
1402
|
+
Raises:
|
|
1403
|
+
Exception: If the retrieval fails
|
|
1404
|
+
|
|
1405
|
+
"""
|
|
1406
|
+
return await self.get_message_execution_async(
|
|
1407
|
+
message_id=self._assistant_message_id
|
|
1408
|
+
)
|
|
1409
|
+
|
|
1410
|
+
def update_assistant_message_execution(
|
|
1411
|
+
self,
|
|
1412
|
+
status: MessageExecutionUpdateStatus,
|
|
1413
|
+
seconds_remaining: int | None = None,
|
|
1414
|
+
percentage_completed: int | None = None,
|
|
1415
|
+
) -> MessageExecution:
|
|
1416
|
+
"""Updates the message execution for the current assistant message synchronously.
|
|
1417
|
+
|
|
1418
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1419
|
+
|
|
1420
|
+
Args:
|
|
1421
|
+
status (MessageExecutionUpdateStatus): The updated status (COMPLETED or FAILED)
|
|
1422
|
+
seconds_remaining (int | None): Updated estimated seconds remaining
|
|
1423
|
+
percentage_completed (int | None): Updated percentage of completion (0-100)
|
|
1424
|
+
|
|
1425
|
+
Returns:
|
|
1426
|
+
MessageExecution: The updated message execution
|
|
1427
|
+
|
|
1428
|
+
Raises:
|
|
1429
|
+
Exception: If the update fails
|
|
1430
|
+
|
|
1431
|
+
"""
|
|
1432
|
+
return self.update_message_execution(
|
|
1433
|
+
message_id=self._assistant_message_id,
|
|
1434
|
+
status=status,
|
|
1435
|
+
seconds_remaining=seconds_remaining,
|
|
1436
|
+
percentage_completed=percentage_completed,
|
|
1437
|
+
)
|
|
1438
|
+
|
|
1439
|
+
async def update_assistant_message_execution_async(
|
|
1440
|
+
self,
|
|
1441
|
+
status: MessageExecutionUpdateStatus,
|
|
1442
|
+
seconds_remaining: int | None = None,
|
|
1443
|
+
percentage_completed: int | None = None,
|
|
1444
|
+
) -> MessageExecution:
|
|
1445
|
+
"""Updates the message execution for the current assistant message asynchronously.
|
|
1446
|
+
|
|
1447
|
+
This is a convenience method that uses the current assistant message ID.
|
|
1448
|
+
|
|
1449
|
+
Args:
|
|
1450
|
+
status (MessageExecutionUpdateStatus): The updated status (COMPLETED or FAILED)
|
|
1451
|
+
seconds_remaining (int | None): Updated estimated seconds remaining
|
|
1452
|
+
percentage_completed (int | None): Updated percentage of completion (0-100)
|
|
1453
|
+
|
|
1454
|
+
Returns:
|
|
1455
|
+
MessageExecution: The updated message execution
|
|
1456
|
+
|
|
1457
|
+
Raises:
|
|
1458
|
+
Exception: If the update fails
|
|
1459
|
+
|
|
1460
|
+
"""
|
|
1461
|
+
return await self.update_message_execution_async(
|
|
1462
|
+
message_id=self._assistant_message_id,
|
|
1463
|
+
status=status,
|
|
1464
|
+
seconds_remaining=seconds_remaining,
|
|
1465
|
+
percentage_completed=percentage_completed,
|
|
1466
|
+
)
|
|
1467
|
+
|
|
899
1468
|
@deprecated("Use complete_with_references instead")
|
|
900
1469
|
def stream_complete(
|
|
901
1470
|
self,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from unique_toolkit.tools.schemas import BaseToolConfig
|
|
2
|
+
|
|
3
|
+
from unique_toolkit.tools.config import get_configuration_dict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
DEFAULT_PARAM_DESCRIPTION_SUB_AGENT_USER_MESSAGE = """
|
|
7
|
+
This is the message that will be sent to the sub-agent.
|
|
8
|
+
""".strip()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SubAgentToolConfig(BaseToolConfig):
|
|
12
|
+
model_config = get_configuration_dict()
|
|
13
|
+
|
|
14
|
+
name: str = "default_name"
|
|
15
|
+
assistant_id: str = ""
|
|
16
|
+
chat_id: str | None = None
|
|
17
|
+
reuse_chat: bool = True
|
|
18
|
+
tool_description_for_system_prompt: str = ""
|
|
19
|
+
tool_description: str = ""
|
|
20
|
+
param_description_sub_agent_user_message: str = (
|
|
21
|
+
DEFAULT_PARAM_DESCRIPTION_SUB_AGENT_USER_MESSAGE
|
|
22
|
+
)
|
|
23
|
+
tool_format_information_for_system_prompt: str = ""
|
|
24
|
+
|
|
25
|
+
tool_description_for_user_prompt: str = ""
|
|
26
|
+
tool_format_information_for_user_prompt: str = ""
|
|
27
|
+
|
|
28
|
+
poll_interval: float = 1.0
|
|
29
|
+
max_wait: float = 120.0
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from logging import Logger
|
|
2
|
+
|
|
3
|
+
from unique_toolkit.app.schemas import ChatEvent
|
|
4
|
+
from unique_toolkit.tools.a2a.service import SubAgentTool, ToolProgressReporter
|
|
5
|
+
|
|
6
|
+
from unique_toolkit.tools.a2a.config import SubAgentToolConfig
|
|
7
|
+
from unique_toolkit.tools.config import ToolBuildConfig
|
|
8
|
+
from unique_toolkit.tools.schemas import BaseToolConfig
|
|
9
|
+
from unique_toolkit.tools.tool import Tool
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class A2AManager:
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
logger: Logger,
|
|
16
|
+
tool_progress_reporter: ToolProgressReporter,
|
|
17
|
+
):
|
|
18
|
+
self._logger = logger
|
|
19
|
+
self._tool_progress_reporter = tool_progress_reporter
|
|
20
|
+
|
|
21
|
+
def get_all_sub_agents(
|
|
22
|
+
self, tool_configs: list[ToolBuildConfig], event: ChatEvent
|
|
23
|
+
) -> tuple[list[ToolBuildConfig], list[Tool[BaseToolConfig]]]:
|
|
24
|
+
sub_agents = []
|
|
25
|
+
|
|
26
|
+
for tool_config in tool_configs:
|
|
27
|
+
if not tool_config.is_sub_agent:
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
if not isinstance(tool_config.configuration, SubAgentToolConfig):
|
|
31
|
+
self._logger.error(
|
|
32
|
+
"tool_config.configuration must be of type SubAgentToolConfig"
|
|
33
|
+
)
|
|
34
|
+
continue
|
|
35
|
+
|
|
36
|
+
sub_agent_tool_config: SubAgentToolConfig = tool_config.configuration
|
|
37
|
+
|
|
38
|
+
sub_agents.append(
|
|
39
|
+
SubAgentTool(
|
|
40
|
+
configuration=sub_agent_tool_config,
|
|
41
|
+
event=event,
|
|
42
|
+
tool_progress_reporter=self._tool_progress_reporter,
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
filtered_tool_config = [
|
|
47
|
+
tool_config for tool_config in tool_configs if not tool_config.is_sub_agent
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
return filtered_tool_config, sub_agents
|