deepanything 0.1.1__tar.gz → 0.1.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {deepanything-0.1.1 → deepanything-0.1.2}/PKG-INFO +1 -1
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/ReasonClient.py +38 -7
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/PKG-INFO +1 -1
- {deepanything-0.1.1 → deepanything-0.1.2}/setup.py +1 -1
- {deepanything-0.1.1 → deepanything-0.1.2}/LICENSE +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/README.md +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/DeepAnythingClient.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/ResponseClient.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/Server/Server.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/Server/Types.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/Server/__init__.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/Stream.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/Utility.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/__init__.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything/__main__.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/SOURCES.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/dependency_links.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/entry_points.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/requires.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/deepanything.egg-info/top_level.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/requirements.txt +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/setup.cfg +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/test/server.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/test/think.py +0 -0
- {deepanything-0.1.1 → deepanything-0.1.2}/test/think_async.py +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import openai
|
2
|
-
from openai.types.chat import chat_completion
|
2
|
+
from openai.types.chat import chat_completion, chat_completion_chunk
|
3
3
|
from deepanything.Stream import Stream,AsyncStream
|
4
4
|
from deepanything import Utility
|
5
5
|
|
@@ -126,6 +126,15 @@ class AsyncDeepseekReasonClient(AsyncReasonClient):
|
|
126
126
|
.on_next(lambda it : it.__anext__())
|
127
127
|
.on_close(lambda _: stream.close()))
|
128
128
|
|
129
|
+
|
130
|
+
def _rebuild_chunk_for_openai(
|
131
|
+
chunk:chat_completion_chunk.ChatCompletionChunk
|
132
|
+
) -> chat_completion_chunk.ChatCompletionChunk:
|
133
|
+
chunk.choices[0].delta.reasoning_content = chunk.choices[0].delta.content
|
134
|
+
chunk.choices[0].delta.content = None
|
135
|
+
return chunk
|
136
|
+
|
137
|
+
|
129
138
|
class OpenaiReasonClient(ReasonClient):
|
130
139
|
client : openai.OpenAI
|
131
140
|
def __init__(
|
@@ -146,13 +155,15 @@ class OpenaiReasonClient(ReasonClient):
|
|
146
155
|
model: str,
|
147
156
|
**kwargs
|
148
157
|
) -> Stream:
|
149
|
-
|
158
|
+
stream = self.client.chat.completions.create(
|
150
159
|
messages=messages,
|
151
160
|
model=model,
|
152
161
|
stream=True,
|
153
162
|
**kwargs
|
154
163
|
)
|
155
164
|
|
165
|
+
return Stream(stream).on_next(lambda it: _rebuild_chunk_for_openai(it.__next__())).on_close(lambda _: stream.close())
|
166
|
+
|
156
167
|
def reason(
|
157
168
|
self,
|
158
169
|
messages:list[dict],
|
@@ -160,13 +171,20 @@ class OpenaiReasonClient(ReasonClient):
|
|
160
171
|
stream = False,
|
161
172
|
**kwargs
|
162
173
|
) -> Stream or chat_completion.ChatCompletion:
|
163
|
-
|
174
|
+
if stream:
|
175
|
+
return self.reason_stream(messages, model, **kwargs)
|
176
|
+
completion = self.client.chat.completions.create(
|
164
177
|
messages=messages,
|
165
178
|
model=model,
|
166
179
|
stream=stream,
|
167
180
|
**kwargs
|
168
181
|
)
|
169
182
|
|
183
|
+
completion.choices[0].message.reasoning_content = completion.choices[0].message.content
|
184
|
+
completion.choices[0].message.content = None
|
185
|
+
|
186
|
+
return completion
|
187
|
+
|
170
188
|
class AsyncOpenaiReasonClient(AsyncReasonClient):
|
171
189
|
client : openai.AsyncOpenAI
|
172
190
|
def __init__(self,base_url:str,api_key:str,**kwargs) -> None:
|
@@ -182,22 +200,35 @@ class AsyncOpenaiReasonClient(AsyncReasonClient):
|
|
182
200
|
model: str,
|
183
201
|
**kwargs
|
184
202
|
) -> AsyncStream:
|
185
|
-
|
203
|
+
|
204
|
+
stream = await self.client.chat.completions.create(
|
186
205
|
messages=messages,
|
187
206
|
model=model,
|
188
207
|
stream=True,
|
189
208
|
**kwargs
|
190
209
|
)
|
191
210
|
|
211
|
+
async def _next(it):
|
212
|
+
return _rebuild_chunk_for_openai(await it.__anext__())
|
213
|
+
|
214
|
+
return AsyncStream(stream).on_next(lambda it: _next(it)).on_close(lambda _: stream.close())
|
215
|
+
|
192
216
|
async def reason(self,
|
193
217
|
messages: list[dict],
|
194
218
|
model: str,
|
195
219
|
stream = False,
|
196
220
|
**kwargs
|
197
221
|
) -> AsyncStream or chat_completion.ChatCompletion:
|
198
|
-
|
222
|
+
if stream:
|
223
|
+
return await self.reason_stream(messages, model, **kwargs)
|
224
|
+
|
225
|
+
completion = await self.client.chat.completions.create(
|
199
226
|
messages=messages,
|
200
227
|
model=model,
|
201
|
-
stream=stream,
|
202
228
|
**kwargs
|
203
|
-
)
|
229
|
+
)
|
230
|
+
|
231
|
+
completion.choices[0].message.reasoning_content = completion.choices[0].message.content
|
232
|
+
completion.choices[0].message.content = None
|
233
|
+
|
234
|
+
return completion
|
@@ -8,7 +8,7 @@ with open("requirements.txt") as f:
|
|
8
8
|
|
9
9
|
setup(
|
10
10
|
name="deepanything",
|
11
|
-
version="0.1.
|
11
|
+
version="0.1.2",
|
12
12
|
author="Junity",
|
13
13
|
author_email="1727636624@qq.com",
|
14
14
|
description="DeepAnything is a project that provides DeepSeek R1's deep thinking capabilities for various large language models (LLMs).",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|