unique_toolkit 2026.36.0.dev1__py3-none-any.whl → 2026.36.0.dev2__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/language_model/functions.py +11 -2
- unique_toolkit/language_model/service.py +15 -1
- {unique_toolkit-2026.36.0.dev1.dist-info → unique_toolkit-2026.36.0.dev2.dist-info}/METADATA +1 -1
- {unique_toolkit-2026.36.0.dev1.dist-info → unique_toolkit-2026.36.0.dev2.dist-info}/RECORD +5 -5
- {unique_toolkit-2026.36.0.dev1.dist-info → unique_toolkit-2026.36.0.dev2.dist-info}/WHEEL +0 -0
|
@@ -46,12 +46,15 @@ logger = logging.getLogger(f"toolkit.language_model.{__name__}")
|
|
|
46
46
|
def _completion_headers(
|
|
47
47
|
chat_id: str | None,
|
|
48
48
|
assistant_id: str | None,
|
|
49
|
+
assistant_message_id: str | None = None,
|
|
49
50
|
) -> dict[str, str] | None:
|
|
50
51
|
headers: dict[str, str] = {}
|
|
51
52
|
if chat_id:
|
|
52
53
|
headers["x-chat-id"] = chat_id
|
|
53
54
|
if assistant_id:
|
|
54
55
|
headers["x-assistant-id"] = assistant_id
|
|
56
|
+
if assistant_message_id:
|
|
57
|
+
headers["x-assistant-message-id"] = assistant_message_id
|
|
55
58
|
return headers or None
|
|
56
59
|
|
|
57
60
|
|
|
@@ -68,6 +71,7 @@ def complete(
|
|
|
68
71
|
user_id: str | None = None,
|
|
69
72
|
chat_id: str | None = None,
|
|
70
73
|
assistant_id: str | None = None,
|
|
74
|
+
assistant_message_id: str | None = None,
|
|
71
75
|
) -> LanguageModelResponse:
|
|
72
76
|
"""Call the completion endpoint synchronously without streaming the response.
|
|
73
77
|
|
|
@@ -103,7 +107,7 @@ def complete(
|
|
|
103
107
|
)
|
|
104
108
|
|
|
105
109
|
try:
|
|
106
|
-
headers = _completion_headers(chat_id, assistant_id)
|
|
110
|
+
headers = _completion_headers(chat_id, assistant_id, assistant_message_id)
|
|
107
111
|
if headers is None:
|
|
108
112
|
response = unique_sdk.ChatCompletion.create(
|
|
109
113
|
company_id=company_id,
|
|
@@ -142,6 +146,7 @@ async def complete_async(
|
|
|
142
146
|
structured_output_enforce_schema: bool = False,
|
|
143
147
|
chat_id: str | None = None,
|
|
144
148
|
assistant_id: str | None = None,
|
|
149
|
+
assistant_message_id: str | None = None,
|
|
145
150
|
) -> LanguageModelResponse:
|
|
146
151
|
"""Call the completion endpoint asynchronously without streaming the response.
|
|
147
152
|
|
|
@@ -186,7 +191,7 @@ async def complete_async(
|
|
|
186
191
|
)
|
|
187
192
|
|
|
188
193
|
try:
|
|
189
|
-
headers = _completion_headers(chat_id, assistant_id)
|
|
194
|
+
headers = _completion_headers(chat_id, assistant_id, assistant_message_id)
|
|
190
195
|
if headers is None:
|
|
191
196
|
response = await unique_sdk.ChatCompletion.create_async(
|
|
192
197
|
company_id=company_id,
|
|
@@ -502,6 +507,7 @@ def complete_with_references(
|
|
|
502
507
|
other_options: dict[str, Any] | None = None,
|
|
503
508
|
chat_id: str | None = None,
|
|
504
509
|
assistant_id: str | None = None,
|
|
510
|
+
assistant_message_id: str | None = None,
|
|
505
511
|
) -> LanguageModelStreamResponse:
|
|
506
512
|
# Use toolkit language model functions for chat completion
|
|
507
513
|
|
|
@@ -516,6 +522,7 @@ def complete_with_references(
|
|
|
516
522
|
other_options=other_options,
|
|
517
523
|
chat_id=chat_id,
|
|
518
524
|
assistant_id=assistant_id,
|
|
525
|
+
assistant_message_id=assistant_message_id,
|
|
519
526
|
)
|
|
520
527
|
|
|
521
528
|
return _create_language_model_stream_response_with_references(
|
|
@@ -539,6 +546,7 @@ async def complete_with_references_async(
|
|
|
539
546
|
other_options: dict[str, Any] | None = None,
|
|
540
547
|
chat_id: str | None = None,
|
|
541
548
|
assistant_id: str | None = None,
|
|
549
|
+
assistant_message_id: str | None = None,
|
|
542
550
|
) -> LanguageModelStreamResponse:
|
|
543
551
|
# Use toolkit language model functions for chat completion
|
|
544
552
|
response = await complete_async(
|
|
@@ -552,6 +560,7 @@ async def complete_with_references_async(
|
|
|
552
560
|
other_options=other_options,
|
|
553
561
|
chat_id=chat_id,
|
|
554
562
|
assistant_id=assistant_id,
|
|
563
|
+
assistant_message_id=assistant_message_id,
|
|
555
564
|
)
|
|
556
565
|
|
|
557
566
|
return _create_language_model_stream_response_with_references(
|
|
@@ -5,7 +5,11 @@ from pydantic import BaseModel
|
|
|
5
5
|
from typing_extensions import deprecated
|
|
6
6
|
|
|
7
7
|
from unique_toolkit._common.validate_required_values import validate_required_values
|
|
8
|
-
from unique_toolkit.app.schemas import
|
|
8
|
+
from unique_toolkit.app.schemas import (
|
|
9
|
+
AssistantWebhookEvent,
|
|
10
|
+
BaseEvent,
|
|
11
|
+
ChatEventPayload,
|
|
12
|
+
)
|
|
9
13
|
from unique_toolkit.app.unique_settings import UniqueSettings
|
|
10
14
|
from unique_toolkit.content.schemas import ContentChunk
|
|
11
15
|
from unique_toolkit.language_model.constants import (
|
|
@@ -67,10 +71,13 @@ class LanguageModelService:
|
|
|
67
71
|
self._event = event
|
|
68
72
|
self._chat_id = None
|
|
69
73
|
self._assistant_id = None
|
|
74
|
+
self._assistant_message_id = None
|
|
70
75
|
if isinstance(event, AssistantWebhookEvent):
|
|
71
76
|
payload = event.payload
|
|
72
77
|
self._chat_id = payload.chat_id
|
|
73
78
|
self._assistant_id = payload.assistant_id
|
|
79
|
+
if isinstance(payload, ChatEventPayload):
|
|
80
|
+
self._assistant_message_id = payload.assistant_message.id
|
|
74
81
|
return
|
|
75
82
|
|
|
76
83
|
[company_id, user_id] = validate_required_values([company_id, user_id])
|
|
@@ -79,6 +86,7 @@ class LanguageModelService:
|
|
|
79
86
|
self._user_id: str = user_id
|
|
80
87
|
self._chat_id: str | None = None
|
|
81
88
|
self._assistant_id: str | None = None
|
|
89
|
+
self._assistant_message_id: str | None = None
|
|
82
90
|
|
|
83
91
|
@classmethod
|
|
84
92
|
def from_event(cls, event: BaseEvent[Any]):
|
|
@@ -89,6 +97,8 @@ class LanguageModelService:
|
|
|
89
97
|
if isinstance(event, AssistantWebhookEvent):
|
|
90
98
|
service._chat_id = event.payload.chat_id
|
|
91
99
|
service._assistant_id = event.payload.assistant_id
|
|
100
|
+
if isinstance(event.payload, ChatEventPayload):
|
|
101
|
+
service._assistant_message_id = event.payload.assistant_message.id
|
|
92
102
|
return service
|
|
93
103
|
|
|
94
104
|
@classmethod
|
|
@@ -251,6 +261,7 @@ class LanguageModelService:
|
|
|
251
261
|
structured_output_enforce_schema=structured_output_enforce_schema,
|
|
252
262
|
chat_id=self._chat_id,
|
|
253
263
|
assistant_id=self._assistant_id,
|
|
264
|
+
assistant_message_id=self._assistant_message_id,
|
|
254
265
|
)
|
|
255
266
|
|
|
256
267
|
async def complete_async(
|
|
@@ -281,6 +292,7 @@ class LanguageModelService:
|
|
|
281
292
|
structured_output_enforce_schema=structured_output_enforce_schema,
|
|
282
293
|
chat_id=self._chat_id,
|
|
283
294
|
assistant_id=self._assistant_id,
|
|
295
|
+
assistant_message_id=self._assistant_message_id,
|
|
284
296
|
)
|
|
285
297
|
|
|
286
298
|
@classmethod
|
|
@@ -344,6 +356,7 @@ class LanguageModelService:
|
|
|
344
356
|
start_text=start_text,
|
|
345
357
|
chat_id=self._chat_id,
|
|
346
358
|
assistant_id=self._assistant_id,
|
|
359
|
+
assistant_message_id=self._assistant_message_id,
|
|
347
360
|
)
|
|
348
361
|
|
|
349
362
|
async def complete_with_references_async(
|
|
@@ -371,4 +384,5 @@ class LanguageModelService:
|
|
|
371
384
|
start_text=start_text,
|
|
372
385
|
chat_id=self._chat_id,
|
|
373
386
|
assistant_id=self._assistant_id,
|
|
387
|
+
assistant_message_id=self._assistant_message_id,
|
|
374
388
|
)
|
{unique_toolkit-2026.36.0.dev1.dist-info → unique_toolkit-2026.36.0.dev2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: unique-toolkit
|
|
3
|
-
Version: 2026.36.0.
|
|
3
|
+
Version: 2026.36.0.dev2
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Cedric Klinkert, Martin Fadler, Sadique Sheik, Fabian Schläpfer, Pascal Hauri, Ejiroghene Oki-Peter, Rami Azouz, Ricardo Visini, Sanzio Monti
|
|
6
6
|
Author-email: Cedric Klinkert <cedric.klinkert@unique.ch>, Martin Fadler <martin.fadler@unique.ch>, Sadique Sheik <sadique@unique.ch>, Fabian Schläpfer <fabian@unique.ch>, Pascal Hauri <pascal@unique.ch>, Ejiroghene Oki-Peter <oki-peter.ejiroghene@unique.ai>, Rami Azouz <rami.ext@unique.ch>, Ricardo Visini <ricardo.visini@unique.ch>, Sanzio Monti <sanzio.monti@unique.ai>
|
|
@@ -391,14 +391,14 @@ unique_toolkit/language_model/_responses_api_utils.py,sha256=w2ZyleOQcWLpOWGJNNb
|
|
|
391
391
|
unique_toolkit/language_model/builder.py,sha256=KwBzsD6-fvQnB4p2I7M-5Tk6j4tmQ973MYwU1ulXFb4,4526
|
|
392
392
|
unique_toolkit/language_model/constants.py,sha256=B-topqW0r83dkC_25DeQfnPk3n53qzIHUCBS7YJ0-1U,119
|
|
393
393
|
unique_toolkit/language_model/default_language_model.py,sha256=mcyuFs_V6tp52C8xJSHiEHO4kFGj6xed1gvozvCRD7k,1181
|
|
394
|
-
unique_toolkit/language_model/functions.py,sha256=
|
|
394
|
+
unique_toolkit/language_model/functions.py,sha256=W6JC4LUh-LZ9waDgph--xVmKeQ7Ls6NRAqDx9DwQdeY,26691
|
|
395
395
|
unique_toolkit/language_model/infos.py,sha256=zs0UFhds4UkSRr3zxyTJ-jJ9u2O2x9VgZx3a9d4zbYU,146221
|
|
396
396
|
unique_toolkit/language_model/invocation_stats.py,sha256=XAM_qckI-BoMBSgDpVcxFD1cFSdi1-GHZToHz_jLynM,2491
|
|
397
397
|
unique_toolkit/language_model/model_costs.py,sha256=WM1u2fWAKpPB_creS-ew8YAzc1V8oiaCbvhpSJaO8B0,3789
|
|
398
398
|
unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
|
|
399
399
|
unique_toolkit/language_model/reference.py,sha256=T3wr2jP_uRg5wKVIbKqLbxJlcgxfbZQGq3XdjbQ2kSo,6984
|
|
400
400
|
unique_toolkit/language_model/schemas.py,sha256=IUmp_JMHx0czadJlmsLL9nmc-nCPmVRVLp2T5DSYsqY,35402
|
|
401
|
-
unique_toolkit/language_model/service.py,sha256=
|
|
401
|
+
unique_toolkit/language_model/service.py,sha256=lgpzWhqxLBOeFacCafQi4e7BqAxJbOlr8GnCYcKeTdM,13274
|
|
402
402
|
unique_toolkit/language_model/settings.py,sha256=7szohExI-qmTfUf2Zp5AB5TzrsZy1UekAGyXx_UaPMc,1524
|
|
403
403
|
unique_toolkit/language_model/stream_transform.py,sha256=iNNGpLY_7G6Bpp9Y4KtbIkQm3WB4yZt75BXcqx0DVkI,2775
|
|
404
404
|
unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
|
|
@@ -420,6 +420,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
|
|
|
420
420
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
421
421
|
unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
|
|
422
422
|
unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
|
|
423
|
-
unique_toolkit-2026.36.0.
|
|
424
|
-
unique_toolkit-2026.36.0.
|
|
425
|
-
unique_toolkit-2026.36.0.
|
|
423
|
+
unique_toolkit-2026.36.0.dev2.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
424
|
+
unique_toolkit-2026.36.0.dev2.dist-info/METADATA,sha256=Caxi8wvrymP225m-SxkPfSMbMQ4agwTI-81eGleVGXw,7821
|
|
425
|
+
unique_toolkit-2026.36.0.dev2.dist-info/RECORD,,
|
|
File without changes
|