unique_toolkit 0.8.10__py3-none-any.whl → 0.8.12__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.
@@ -4,6 +4,7 @@ from enum import StrEnum
4
4
  from humps import camelize
5
5
  from openai.types.chat import (
6
6
  ChatCompletionAssistantMessageParam,
7
+ ChatCompletionMessageParam,
7
8
  ChatCompletionUserMessageParam,
8
9
  )
9
10
  from openai.types.chat.chat_completion_message_function_tool_call_param import (
@@ -96,7 +97,7 @@ class ChatMessage(BaseModel):
96
97
  raise ValueError("tool_call_ids is required when role is 'tool'")
97
98
  return self
98
99
 
99
- def to_openai_param(self):
100
+ def to_openai_param(self) -> ChatCompletionMessageParam:
100
101
  match self.role:
101
102
  case ChatMessageRole.USER:
102
103
  return ChatCompletionUserMessageParam(
@@ -105,14 +106,25 @@ class ChatMessage(BaseModel):
105
106
  )
106
107
 
107
108
  case ChatMessageRole.ASSISTANT:
108
- return ChatCompletionAssistantMessageParam(
109
- role="assistant",
110
- audio=None,
111
- content=self.content or "",
112
- function_call=None,
113
- refusal=None,
114
- tool_calls=[t.to_openai_param() for t in self.tool_calls or []],
115
- )
109
+ if self.tool_calls:
110
+ assistant_message = ChatCompletionAssistantMessageParam(
111
+ role="assistant",
112
+ audio=None,
113
+ content=self.content or "",
114
+ function_call=None,
115
+ refusal=None,
116
+ tool_calls=[t.to_openai_param() for t in self.tool_calls],
117
+ )
118
+ else:
119
+ assistant_message = ChatCompletionAssistantMessageParam(
120
+ role="assistant",
121
+ audio=None,
122
+ content=self.content or "",
123
+ function_call=None,
124
+ refusal=None,
125
+ )
126
+
127
+ return assistant_message
116
128
 
117
129
  case ChatMessageRole.TOOL:
118
130
  raise NotImplementedError
@@ -402,9 +402,9 @@ class ChatService:
402
402
  references: list[ContentReference] | None = None,
403
403
  debug_info: dict | None = None,
404
404
  message_id: str | None = None,
405
- set_completed_at: bool = False,
405
+ set_completed_at: bool | None = None,
406
406
  ) -> ChatMessage:
407
- """Modifies a message in the chat session synchronously.
407
+ """Modifies a message in the chat session synchronously if parameter is not specified the corresponding field will remain as is.
408
408
 
409
409
  Args:
410
410
  content (str, optional): The new content for the message.
@@ -8,6 +8,7 @@ from typing_extensions import deprecated
8
8
 
9
9
  from unique_toolkit._common.validate_required_values import validate_required_values
10
10
  from unique_toolkit.app.schemas import BaseEvent, ChatEvent, Event
11
+ from unique_toolkit.app.unique_settings import UniqueSettings
11
12
  from unique_toolkit.content import DOMAIN_NAME
12
13
  from unique_toolkit.content.constants import DEFAULT_SEARCH_LANGUAGE
13
14
  from unique_toolkit.content.functions import (
@@ -53,7 +54,7 @@ class ContentService:
53
54
  *,
54
55
  company_id: str,
55
56
  user_id: str,
56
- chat_id: str | None,
57
+ chat_id: str | None = None,
57
58
  metadata_filter: dict | None = None,
58
59
  ): ...
59
60
 
@@ -107,6 +108,19 @@ class ContentService:
107
108
  metadata_filter=metadata_filter,
108
109
  )
109
110
 
111
+ @classmethod
112
+ def from_settings(
113
+ cls, settings: UniqueSettings, metadata_filter: dict | None = None
114
+ ):
115
+ """
116
+ Initialize the ContentService with a settings object.
117
+ """
118
+ return cls(
119
+ company_id=settings.auth.company_id.get_secret_value(),
120
+ user_id=settings.auth.user_id.get_secret_value(),
121
+ metadata_filter=metadata_filter,
122
+ )
123
+
110
124
  @property
111
125
  @deprecated(
112
126
  "The event property is deprecated and will be removed in a future version."
@@ -5,6 +5,7 @@ from typing_extensions import deprecated
5
5
  from unique_toolkit._common._base_service import BaseService
6
6
  from unique_toolkit._common.validate_required_values import validate_required_values
7
7
  from unique_toolkit.app.schemas import BaseEvent, Event
8
+ from unique_toolkit.app.unique_settings import UniqueSettings
8
9
  from unique_toolkit.embedding.constants import DEFAULT_TIMEOUT
9
10
  from unique_toolkit.embedding.functions import embed_texts, embed_texts_async
10
11
  from unique_toolkit.embedding.schemas import Embeddings
@@ -54,6 +55,16 @@ class EmbeddingService(BaseService):
54
55
  """
55
56
  return cls(company_id=event.company_id, user_id=event.user_id)
56
57
 
58
+ @classmethod
59
+ def from_settings(cls, settings: UniqueSettings):
60
+ """
61
+ Initialize the EmbeddingService with a settings object.
62
+ """
63
+ return cls(
64
+ company_id=settings.auth.company_id.get_secret_value(),
65
+ user_id=settings.auth.user_id.get_secret_value(),
66
+ )
67
+
57
68
  @property
58
69
  @deprecated(
59
70
  "The event property is deprecated and will be removed in a future version."
@@ -49,6 +49,9 @@ class OpenAIMessageBuilder:
49
49
  builder._messages = messages.copy()
50
50
  return builder
51
51
 
52
+ def append(self, message: ChatCompletionMessageParam):
53
+ self._messages.append(message)
54
+
52
55
  def system_message_append(
53
56
  self,
54
57
  content: str | Iterable[ChatCompletionContentPartTextParam],
@@ -6,6 +6,7 @@ from typing_extensions import deprecated
6
6
 
7
7
  from unique_toolkit._common.validate_required_values import validate_required_values
8
8
  from unique_toolkit.app.schemas import BaseEvent, ChatEvent, Event
9
+ from unique_toolkit.app.unique_settings import UniqueSettings
9
10
  from unique_toolkit.content.schemas import ContentChunk
10
11
  from unique_toolkit.language_model.constants import (
11
12
  DEFAULT_COMPLETE_TEMPERATURE,
@@ -89,6 +90,16 @@ class LanguageModelService:
89
90
  """
90
91
  return cls(company_id=event.company_id, user_id=event.user_id)
91
92
 
93
+ @classmethod
94
+ def from_settings(cls, settings: UniqueSettings):
95
+ """
96
+ Initialize the LanguageModelService with a settings object.
97
+ """
98
+ return cls(
99
+ company_id=settings.auth.company_id.get_secret_value(),
100
+ user_id=settings.auth.user_id.get_secret_value(),
101
+ )
102
+
92
103
  @property
93
104
  @deprecated(
94
105
  "The event property is deprecated and will be removed in a future version."
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.8.10
3
+ Version: 0.8.12
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -114,6 +114,14 @@ All notable changes to this project will be documented in this file.
114
114
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
115
115
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
116
116
 
117
+ ## [0.8.12] - 2025-08-18
118
+ - Fix no tool call respoonse in ChatMessage -> Open Ai messages translation
119
+ - Add simple append method to OpenAIMessageBuilder
120
+
121
+ ## [0.8.11] - 2025-08-15
122
+ - Fix no tool call respoonse in ChatMessage -> Open Ai messages translation
123
+ - Add simple append method to OpenAIMessageBuilder
124
+
117
125
  ## [0.8.10] - 2025-08-15
118
126
  - Add min and max temperature to `LanguageModelInfo`: temperature will be clamped to the min and max temperature
119
127
  - Add default options to `LanguageModelInfo`: These are used by default
@@ -16,21 +16,21 @@ unique_toolkit/app/verification.py,sha256=GxFFwcJMy25fCA_Xe89wKW7bgqOu8PAs5y8QpH
16
16
  unique_toolkit/chat/__init__.py,sha256=LRs2G-JTVuci4lbtHTkVUiNcZcSR6uqqfnAyo7af6nY,619
17
17
  unique_toolkit/chat/constants.py,sha256=05kq6zjqUVB2d6_P7s-90nbljpB3ryxwCI-CAz0r2O4,83
18
18
  unique_toolkit/chat/functions.py,sha256=I6r81PpWNu-j9DvHxNFKN3V6T5E5q42FhW9kF8pJJSY,29950
19
- unique_toolkit/chat/schemas.py,sha256=0tWzu5_F_-PRK5A6MUsdpNqCfNAIMEAuQ26wIgP2pYs,4415
20
- unique_toolkit/chat/service.py,sha256=LNZm9JS17M-MWcVRR3o2HpQFgDkIkxnGMUCoYmz9vzA,37759
19
+ unique_toolkit/chat/schemas.py,sha256=ekmDzxZRnO4pF-8DAnP4JqKmYuJnSC5RpYcO7j5T3aI,4927
20
+ unique_toolkit/chat/service.py,sha256=iyOSzbRxAnxxGw4VrcduVPjA6cPw_98SL70YgL7V9VI,37837
21
21
  unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,1445
22
22
  unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
23
23
  unique_toolkit/content/__init__.py,sha256=EdJg_A_7loEtCQf4cah3QARQreJx6pdz89Rm96YbMVg,940
24
24
  unique_toolkit/content/constants.py,sha256=1iy4Y67xobl5VTnJB6SxSyuoBWbdLl9244xfVMUZi5o,60
25
25
  unique_toolkit/content/functions.py,sha256=HZtDIAH3ZxWleq5Si_v30n_7vTnNRu6BCxpTHb9TxdA,18635
26
26
  unique_toolkit/content/schemas.py,sha256=KJ604BOx0vBh2AwlTCZkOo55aHsI6yj8vxDAARKKqEo,2995
27
- unique_toolkit/content/service.py,sha256=GA4KHNmppp2L2TRKbFUI1grYUJbuNscfoVBYTPilY7s,20972
27
+ unique_toolkit/content/service.py,sha256=3zUu3vUcPV8Mb_v1TCyi2hicGVMLNBamKB3Q6-z1trY,21455
28
28
  unique_toolkit/content/utils.py,sha256=qNVmHTuETaPNGqheg7TbgPr1_1jbNHDc09N5RrmUIyo,7901
29
29
  unique_toolkit/embedding/__init__.py,sha256=uUyzjonPvuDCYsvXCIt7ErQXopLggpzX-MEQd3_e2kE,250
30
30
  unique_toolkit/embedding/constants.py,sha256=Lj8-Lcy1FvuC31PM9Exq7vaFuxQV4pEI1huUMFX-J2M,52
31
31
  unique_toolkit/embedding/functions.py,sha256=3qp-BfuMAbnp8YB04rh3xH8vsJuCBPizoy-JeaBFtoQ,1944
32
32
  unique_toolkit/embedding/schemas.py,sha256=1GvKCaSk4jixzVQ2PKq8yDqwGEVY_hWclYtoAr6CC2g,96
33
- unique_toolkit/embedding/service.py,sha256=z1MwwaeEloLvgT8rwUAydlt28TnKZ9TkcPgdYIyqZvs,4657
33
+ unique_toolkit/embedding/service.py,sha256=2KjYlUKxeh-Je8S1mOPiQ735pqAmdbeztycVNJxcUXA,5039
34
34
  unique_toolkit/embedding/utils.py,sha256=v86lo__bCJbxZBQ3OcLu5SuwT6NbFfWlcq8iyk6BuzQ,279
35
35
  unique_toolkit/evaluators/__init__.py,sha256=3Rfpnowm7MUXHWmeU4UV4s_3Hk-sw3V20oBwQCYlejQ,50
36
36
  unique_toolkit/evaluators/config.py,sha256=_DIXToJ-hGNpDAdWa7Q6GMjAsxiC_DquLF-SS5s9rTE,717
@@ -49,7 +49,7 @@ unique_toolkit/evaluators/schemas.py,sha256=Jaue6Uhx75X1CyHKWj8sT3RE1JZXTqoLtfLt
49
49
  unique_toolkit/framework_utilities/langchain/client.py,sha256=Msfmr7uezwqagyRJ2zjWbQRFqzDExWYK0y5KLEnDNqM,1329
50
50
  unique_toolkit/framework_utilities/langchain/history.py,sha256=R9RuCeSFNaUO3OZ0G_LmIC4gmOCIANcl91MfyWLnZ1c,650
51
51
  unique_toolkit/framework_utilities/openai/client.py,sha256=IasxPXlVJHIsZdXHin7yq-5tO4RNLUu9cEuhrgb4ghE,1205
52
- unique_toolkit/framework_utilities/openai/message_builder.py,sha256=XNtgFcgzVeTHZBjfs-fS4cgMEOWqkGObj6ygG08HdfM,4240
52
+ unique_toolkit/framework_utilities/openai/message_builder.py,sha256=VU6mJm_upLcarJQKFft_t1RlLRncWDxDuLC5LIJ5lQQ,4339
53
53
  unique_toolkit/framework_utilities/utils.py,sha256=JK7g2yMfEx3eMprug26769xqNpS5WJcizf8n2zWMBng,789
54
54
  unique_toolkit/language_model/__init__.py,sha256=lRQyLlbwHbNFf4-0foBU13UGb09lwEeodbVsfsSgaCk,1971
55
55
  unique_toolkit/language_model/builder.py,sha256=4OKfwJfj3TrgO1ezc_ewIue6W7BCQ2ZYQXUckWVPPTA,3369
@@ -59,7 +59,7 @@ unique_toolkit/language_model/infos.py,sha256=7huMpiDhGdWyhFBZx9dVLXdSkONSrxHL1F
59
59
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
60
60
  unique_toolkit/language_model/reference.py,sha256=nkX2VFz-IrUz8yqyc3G5jUMNwrNpxITBrMEKkbqqYoI,8583
61
61
  unique_toolkit/language_model/schemas.py,sha256=p95cAwrYmEBupI8f7JZY17aJTKEHvtqF88hMIzS5r_k,16259
62
- unique_toolkit/language_model/service.py,sha256=zlvC_t9T1wixwcGDPRxl6yYniaKl2725NxWrbW51jUs,11290
62
+ unique_toolkit/language_model/service.py,sha256=N_I3VtK5B0G8s5c6TcBVWM7CcLGqakDhEdHQ_z-Hcok,11676
63
63
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
64
64
  unique_toolkit/protocols/support.py,sha256=V15WEIFKVMyF1QCnR8vIi4GrJy4dfTCB6d6JlqPZ58o,2341
65
65
  unique_toolkit/reference_manager/reference_manager.py,sha256=FNCW4CQSsimS8UG7OTdu4-JNQXUMhPrOfRuKAbK9vvE,2305
@@ -82,7 +82,7 @@ unique_toolkit/tools/utils/execution/execution.py,sha256=vjG2Y6awsGNtlvyQAGCTthQ
82
82
  unique_toolkit/tools/utils/source_handling/schema.py,sha256=pvNhtL2daDLpCVIQpfdn6R35GvKmITVLXjZNLAwpgUE,871
83
83
  unique_toolkit/tools/utils/source_handling/source_formatting.py,sha256=C7uayNbdkNVJdEARA5CENnHtNY1SU6etlaqbgHNyxaQ,9152
84
84
  unique_toolkit/tools/utils/source_handling/tests/test_source_formatting.py,sha256=zu3AJnYH9CMqZPrxKEH3IgI-fM3nlvIBuspJG6W6B18,6978
85
- unique_toolkit-0.8.10.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
86
- unique_toolkit-0.8.10.dist-info/METADATA,sha256=GVFDjq3YzjeBV-w8WTtrqLKSuCYuPTc42lgv7Ev9hWk,27071
87
- unique_toolkit-0.8.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
88
- unique_toolkit-0.8.10.dist-info/RECORD,,
85
+ unique_toolkit-0.8.12.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
86
+ unique_toolkit-0.8.12.dist-info/METADATA,sha256=EFm6wn8_fM4GsB6o9AypQeB49rtgJ9HX_c6lFk_sm8M,27377
87
+ unique_toolkit-0.8.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
88
+ unique_toolkit-0.8.12.dist-info/RECORD,,