dais-sdk 0.6.3__py3-none-any.whl → 0.6.4__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.
dais_sdk/stream.py CHANGED
@@ -74,6 +74,9 @@ class AssistantMessageCollector:
74
74
 
75
75
  def get_message(self) -> AssistantMessage:
76
76
  self.message_buf.tool_calls = self.tool_call_collector.get_tool_calls()
77
+ if self.message_buf.content is not None and self.message_buf.reasoning_content is None:
78
+ self.message_buf.content, self.message_buf.reasoning_content =\
79
+ AssistantMessage.extract_thinking_content(self.message_buf.content)
77
80
  return self.message_buf
78
81
 
79
82
  def clear(self):
dais_sdk/types/message.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import json
2
2
  import dataclasses
3
+ import re
3
4
  import uuid
4
5
  from abc import ABC, abstractmethod
5
6
  from typing import Any, Literal, cast
@@ -92,6 +93,22 @@ class AssistantMessage(ChatMessage):
92
93
  usage: LiteLlmUsage | None = None
93
94
  role: Literal["assistant"] = "assistant"
94
95
 
96
+ @staticmethod
97
+ def extract_thinking_content(text: str) -> tuple[str, str | None]:
98
+ """
99
+ Extract thinking content from the start of model responsed text.
100
+ Returns:
101
+ A tuple of (extracted_content, optional thinking_content)
102
+ """
103
+ pattern = r"<(think|thinking)>(.*?)</\1>"
104
+ match = re.match(pattern, text, re.DOTALL)
105
+ if match:
106
+ start, end = match.span()
107
+ thinking_content = match.group(2)
108
+ remaining_content = text[:start] + text[end:]
109
+ return remaining_content.strip(), thinking_content
110
+ return text, None
111
+
95
112
  @classmethod
96
113
  def from_litellm_message(cls, response: LiteLlmModelResponse) -> "AssistantMessage":
97
114
  choices = cast(list[LiteLlmModelResponseChoices], response.choices)
@@ -108,9 +125,16 @@ class AssistantMessage(ChatMessage):
108
125
  type="function",
109
126
  ) for tool_call in cast(list[ChatCompletionMessageToolCall], message_tool_calls)]
110
127
 
128
+ content: str | None = message.get("content")
129
+ reasoning_content: str | None = message.get("reasoning_content")
130
+ if content is not None:
131
+ content, thinking_block_content = cls.extract_thinking_content(content)
132
+ if reasoning_content is None:
133
+ reasoning_content = thinking_block_content
134
+
111
135
  return cls.model_construct(
112
- content=message.get("content"),
113
- reasoning_content=message.get("reasoning_content"),
136
+ content=content,
137
+ reasoning_content=reasoning_content,
114
138
  tool_calls=tool_calls,
115
139
  audio=message.get("audio"),
116
140
  images=message.get("images"),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dais-sdk
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: A wrapper of LiteLLM
5
5
  Author-email: BHznJNs <bhznjns@outlook.com>
6
6
  Requires-Python: >=3.14
@@ -11,11 +11,11 @@ Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Programming Language :: Python :: 3 :: Only
12
12
  Classifier: Programming Language :: Python :: 3.14
13
13
  License-File: LICENSE
14
- Requires-Dist: litellm>=1.80.0
14
+ Requires-Dist: litellm>=1.81.0
15
15
  Requires-Dist: pydantic>=2.0.0
16
16
  Requires-Dist: httpx==0.28.1
17
17
  Requires-Dist: mcp==1.26.0
18
- Requires-Dist: starlette==0.50.0
18
+ Requires-Dist: starlette==0.52.1
19
19
  Requires-Dist: uvicorn==0.40.0
20
20
  Project-URL: Source, https://github.com/Dais-Project/Dais-SDK
21
21
  Project-URL: Tracker, https://github.com/Dais-Project/Dais-SDK/issues
@@ -2,7 +2,7 @@ dais_sdk/__init__.py,sha256=5QAoL8GyyFuKfe4HZ-TiRVj9VIpHc45i2xMMYORoWXU,11805
2
2
  dais_sdk/debug.py,sha256=T7qIy1BeeUGlF40l9JCMMVn8pvvMJAEQeG4adQbOydA,69
3
3
  dais_sdk/logger.py,sha256=99vJAQRKcu4CuHgZYAJ2zDQtGea6Bn3vJJrS-mtza7c,677
4
4
  dais_sdk/param_parser.py,sha256=QIxt1izv69r725pzU1qhq5bilcrGUgzlpiItHEWOrdc,1874
5
- dais_sdk/stream.py,sha256=yu9Zvr3CUrPD9sGsjqwNXy_233Tw25Hd72kwjrraMAM,3170
5
+ dais_sdk/stream.py,sha256=97y6CysPFMq37uXryd4tNlvZYCZ7Rv3CZpntaw1-SF4,3426
6
6
  dais_sdk/mcp_client/__init__.py,sha256=B86aC4nnGzwfjk7H0CZ38YlMDiEx3EIDEAgJKUnwqIU,405
7
7
  dais_sdk/mcp_client/base_mcp_client.py,sha256=jWAfinzY00aL-qdNgyzYXKM-LhPHkmdqL24Uw439v-0,1055
8
8
  dais_sdk/mcp_client/local_mcp_client.py,sha256=JI7jdFyyL4VkrUuzwUybHJ3Y1vgEH0iCG3WqAgyLO1g,1951
@@ -18,10 +18,10 @@ dais_sdk/tool/toolset/python_toolset.py,sha256=p4QeBY_yZpzpnDT5w1S4EECtPOwt8dF8T
18
18
  dais_sdk/tool/toolset/toolset.py,sha256=X1xqWiWov4fboWQowB_YgJ_Tc-fIDmxbP8GreTj_7ME,322
19
19
  dais_sdk/types/__init__.py,sha256=-i1MYWIlUfjQIX0xZJta6phQNL44vXPSIx1eGyIYZXc,710
20
20
  dais_sdk/types/exceptions.py,sha256=ZlQW6QfzPatbfHJi_1s_2XBAHK4bZaeSreI3SUAX_5c,1439
21
- dais_sdk/types/message.py,sha256=a65Q6K3Hq1aVhsedUv2XjyJq2rQQJi9SkEAPPHcLtFw,7770
21
+ dais_sdk/types/message.py,sha256=l54b-vcCCfUtFyTAfVKQd3Csso5KYuSXk1fidfrs2SM,8718
22
22
  dais_sdk/types/request_params.py,sha256=8Jq-aTeK933YENE-9ay_8q88hEr-oeZZGC7l52tOKEM,1635
23
23
  dais_sdk/types/tool.py,sha256=GT6gxjAGdnVzk6W84nPzZb24bLznzqilkHN6uvocf5M,1377
24
- dais_sdk-0.6.3.dist-info/licenses/LICENSE,sha256=Qwd-hsctqFqJErH4OWNNttmd0jccbH0ZCsf-YtAFNdo,1064
25
- dais_sdk-0.6.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
- dais_sdk-0.6.3.dist-info/METADATA,sha256=Tm4_bgcDUtx7rp1rW82aLeA9VpvBnM-fctwQHiqyPgY,2612
27
- dais_sdk-0.6.3.dist-info/RECORD,,
24
+ dais_sdk-0.6.4.dist-info/licenses/LICENSE,sha256=Qwd-hsctqFqJErH4OWNNttmd0jccbH0ZCsf-YtAFNdo,1064
25
+ dais_sdk-0.6.4.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
+ dais_sdk-0.6.4.dist-info/METADATA,sha256=sVSP1GTTvQQbY5OzpBe3PjXQxnKYUNO9RwU46a8zTD0,2612
27
+ dais_sdk-0.6.4.dist-info/RECORD,,