deepanything 0.1.6__py3-none-any.whl → 0.1.8__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.
- deepanything/DeepAnythingClient.py +253 -32
- deepanything/ReasonClient.py +102 -0
- deepanything/ResponseClient.py +58 -2
- deepanything/Server/Server.py +74 -32
- deepanything/Server/Types.py +3 -2
- deepanything/Stream.py +39 -1
- deepanything/Utility.py +14 -1
- deepanything/__main__.py +1 -1
- deepanything/metadatas.py +4 -1
- {deepanything-0.1.6.dist-info → deepanything-0.1.8.dist-info}/METADATA +28 -7
- deepanything-0.1.8.dist-info/RECORD +17 -0
- deepanything-0.1.6.dist-info/RECORD +0 -17
- {deepanything-0.1.6.dist-info → deepanything-0.1.8.dist-info}/LICENSE +0 -0
- {deepanything-0.1.6.dist-info → deepanything-0.1.8.dist-info}/WHEEL +0 -0
- {deepanything-0.1.6.dist-info → deepanything-0.1.8.dist-info}/entry_points.txt +0 -0
- {deepanything-0.1.6.dist-info → deepanything-0.1.8.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,14 @@
|
|
1
1
|
import time
|
2
2
|
from typing import Optional, List
|
3
|
+
|
3
4
|
from openai.types.chat.chat_completion import ChatCompletion
|
4
5
|
|
5
|
-
from deepanything.
|
6
|
-
from deepanything.
|
7
|
-
|
8
|
-
from deepanything.
|
9
|
-
|
6
|
+
from deepanything.ReasonClient import ReasonClient, AsyncReasonClient
|
7
|
+
from deepanything.ResponseClient import ResponseClient, AsyncResponseClient
|
8
|
+
from deepanything.Stream import Stream, AsyncStream
|
9
|
+
from deepanything.Utility import make_usage, make_chat_completion_message, make_chat_completion, \
|
10
|
+
make_chat_completion_choice, merge_usage, make_id_by_timestamp, \
|
11
|
+
extend_message
|
10
12
|
|
11
13
|
|
12
14
|
def _merge_chat_completion(
|
@@ -41,10 +43,7 @@ def _build_message(
|
|
41
43
|
reason_content : str,
|
42
44
|
reason_prompt : str
|
43
45
|
) -> List:
|
44
|
-
return messages
|
45
|
-
role="assistant",
|
46
|
-
content=reason_prompt.format(reason_content)
|
47
|
-
)]
|
46
|
+
return extend_message(messages, role="assistant", content=reason_prompt.format(reason_content))
|
48
47
|
def _process_reason_chunk(chunk, reasoning_contents, reason_usage, show_model, created, _id):
|
49
48
|
new_chunk = chunk.model_copy(deep=False)
|
50
49
|
new_chunk.model = show_model
|
@@ -82,12 +81,34 @@ def chat_completion(
|
|
82
81
|
show_model: str,
|
83
82
|
reason_args=None,
|
84
83
|
response_args=None,
|
85
|
-
reason_prompt: str = "<
|
84
|
+
reason_prompt: str = "<think>{}</think>",
|
85
|
+
reason_system_prompt: Optional[str] = None,
|
86
86
|
created: int = int(time.time()),
|
87
87
|
stream = False,
|
88
88
|
_id: str = make_id_by_timestamp(),
|
89
89
|
max_tokens : Optional[int] = None
|
90
90
|
) -> Stream or ChatCompletion:
|
91
|
+
|
92
|
+
"""
|
93
|
+
Make chat completion synchronously.
|
94
|
+
|
95
|
+
:param messages: Messages
|
96
|
+
:param reason_client: Reason client
|
97
|
+
:param reason_model: Reason model
|
98
|
+
:param response_client: Response client
|
99
|
+
:param response_model: Response model
|
100
|
+
:param show_model: Specify the model name in the return value
|
101
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
102
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
103
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
104
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
105
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
106
|
+
:param stream: Whether you use streaming return
|
107
|
+
:param _id: Specify the `id` in the return value
|
108
|
+
:param max_tokens: max_tokens
|
109
|
+
:return: Return a Stream if stream is Ture,otherwise return a ChatCompletion
|
110
|
+
"""
|
111
|
+
|
91
112
|
if response_args is None:
|
92
113
|
response_args = {}
|
93
114
|
if reason_args is None:
|
@@ -105,7 +126,8 @@ def chat_completion(
|
|
105
126
|
created=created,
|
106
127
|
_id=_id,
|
107
128
|
reason_prompt=reason_prompt,
|
108
|
-
|
129
|
+
reason_system_prompt=reason_system_prompt,
|
130
|
+
max_tokens=max_tokens,
|
109
131
|
)
|
110
132
|
|
111
133
|
if max_tokens is not None:
|
@@ -144,11 +166,32 @@ def chat_completion_stream(
|
|
144
166
|
show_model: str,
|
145
167
|
reason_args=None,
|
146
168
|
response_args=None,
|
147
|
-
reason_prompt: str = "<
|
169
|
+
reason_prompt: str = "<think>{}</think>",
|
170
|
+
reason_system_prompt: Optional[str] = None,
|
148
171
|
created: int = int(time.time()),
|
149
172
|
_id: str = make_id_by_timestamp(),
|
150
173
|
max_tokens : Optional[int] = None
|
151
174
|
) -> Stream:
|
175
|
+
|
176
|
+
"""
|
177
|
+
Make chat completion synchronously.This method uses streaming return
|
178
|
+
|
179
|
+
:param messages: Messages
|
180
|
+
:param reason_client: Reason client
|
181
|
+
:param reason_model: Reason model
|
182
|
+
:param response_client: Response client
|
183
|
+
:param response_model: Response model
|
184
|
+
:param show_model: Specify the model name in the return value
|
185
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
186
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
187
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
188
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
189
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
190
|
+
:param _id: Specify the `id` in the return value
|
191
|
+
:param max_tokens: max_tokens
|
192
|
+
:return: A stream
|
193
|
+
"""
|
194
|
+
|
152
195
|
if response_args is None:
|
153
196
|
response_args = {}
|
154
197
|
if reason_args is None:
|
@@ -166,6 +209,7 @@ def chat_completion_stream(
|
|
166
209
|
reason_stream = reason_client.reason_stream(
|
167
210
|
messages,
|
168
211
|
reason_model,
|
212
|
+
reason_system_prompt,
|
169
213
|
**reason_args
|
170
214
|
)
|
171
215
|
stream = reason_stream
|
@@ -205,12 +249,33 @@ async def chat_completion_async(
|
|
205
249
|
show_model: str,
|
206
250
|
reason_args=None,
|
207
251
|
response_args=None,
|
208
|
-
reason_prompt: str = "<
|
252
|
+
reason_prompt: str = "<think>{}</think>",
|
253
|
+
reason_system_prompt: Optional[str] = None,
|
209
254
|
created: int = int(time.time()),
|
210
255
|
_id: str = make_id_by_timestamp(),
|
211
256
|
stream=False,
|
212
257
|
max_tokens : Optional[int] = None
|
213
258
|
):
|
259
|
+
"""
|
260
|
+
Make chat completion asynchronously.
|
261
|
+
|
262
|
+
:param messages: Messages
|
263
|
+
:param reason_client: Reason client
|
264
|
+
:param reason_model: Reason model
|
265
|
+
:param response_client: Response client
|
266
|
+
:param response_model: Response model
|
267
|
+
:param show_model: Specify the model name in the return value
|
268
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
269
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
270
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
271
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
272
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
273
|
+
:param stream: Whether you use streaming return
|
274
|
+
:param _id: Specify the `id` in the return value
|
275
|
+
:param max_tokens: max_tokens
|
276
|
+
:return: Return a AsyncStream if stream is Ture,otherwise return a ChatCompletion
|
277
|
+
"""
|
278
|
+
|
214
279
|
if response_args is None:
|
215
280
|
response_args = {}
|
216
281
|
if reason_args is None:
|
@@ -228,6 +293,7 @@ async def chat_completion_async(
|
|
228
293
|
created=created,
|
229
294
|
_id=_id,
|
230
295
|
reason_prompt=reason_prompt,
|
296
|
+
reason_system_prompt=reason_system_prompt,
|
231
297
|
max_tokens=max_tokens
|
232
298
|
)
|
233
299
|
|
@@ -246,11 +312,14 @@ async def chat_completion_async(
|
|
246
312
|
return reason_chat_completion
|
247
313
|
response_args["max_tokens"] = max_tokens
|
248
314
|
|
315
|
+
messages = _build_message(
|
316
|
+
messages,
|
317
|
+
reason_chat_completion.choices[0].message.reasoning_content,
|
318
|
+
reason_prompt
|
319
|
+
)
|
320
|
+
|
249
321
|
response_chat_completion:ChatCompletion = await response_client.chat_completions(
|
250
|
-
messages=messages
|
251
|
-
role="assistant",
|
252
|
-
content=reason_prompt.format(reason_chat_completion.choices[0].message.reasoning_content)
|
253
|
-
)],
|
322
|
+
messages=messages,
|
254
323
|
model=response_model,
|
255
324
|
**response_args
|
256
325
|
)
|
@@ -266,11 +335,31 @@ async def chat_completion_stream_async(
|
|
266
335
|
show_model: str,
|
267
336
|
reason_args=None,
|
268
337
|
response_args=None,
|
269
|
-
reason_prompt: str = "<
|
338
|
+
reason_prompt: str = "<think>{}</think>",
|
339
|
+
reason_system_prompt: Optional[str] = None,
|
270
340
|
created: int = int(time.time()),
|
271
341
|
_id: str = make_id_by_timestamp(),
|
272
342
|
max_tokens : Optional[int] = None
|
273
343
|
) -> AsyncStream:
|
344
|
+
"""
|
345
|
+
Make chat completion asynchronously.This method uses streaming return
|
346
|
+
|
347
|
+
:param messages: Messages
|
348
|
+
:param reason_client: Reason client
|
349
|
+
:param reason_model: Reason model
|
350
|
+
:param response_client: Response client
|
351
|
+
:param response_model: Response model
|
352
|
+
:param show_model: Specify the model name in the return value
|
353
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
354
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
355
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
356
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
357
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
358
|
+
:param _id: Specify the `id` in the return value
|
359
|
+
:param max_tokens: max_tokens
|
360
|
+
:return: A AsyncStream
|
361
|
+
"""
|
362
|
+
|
274
363
|
if response_args is None:
|
275
364
|
response_args = {}
|
276
365
|
if reason_args is None:
|
@@ -287,6 +376,7 @@ async def chat_completion_stream_async(
|
|
287
376
|
reason_stream = await reason_client.reason_stream(
|
288
377
|
messages,
|
289
378
|
reason_model,
|
379
|
+
reason_system_prompt,
|
290
380
|
**reason_args
|
291
381
|
)
|
292
382
|
|
@@ -319,20 +409,32 @@ async def chat_completion_stream_async(
|
|
319
409
|
return AsyncStream(_iter()).on_next(lambda it:it.__anext__()).on_close(lambda _:stream.close())
|
320
410
|
|
321
411
|
class DeepAnythingClient:
|
412
|
+
"""
|
413
|
+
DeepAnything Client
|
414
|
+
"""
|
415
|
+
|
322
416
|
reason_client : ReasonClient
|
323
417
|
response_client : ResponseClient
|
324
|
-
|
325
|
-
|
418
|
+
reason_prompt : Optional[str]
|
419
|
+
reason_system_prompt : Optional[str]
|
326
420
|
|
327
421
|
def __init__(
|
328
422
|
self,
|
329
423
|
reason_client: ReasonClient,
|
330
424
|
response_client: ResponseClient,
|
331
|
-
reason_prompt : str =
|
425
|
+
reason_prompt : str = None,
|
426
|
+
reason_system_prompt: Optional[str] = None
|
332
427
|
):
|
428
|
+
"""
|
429
|
+
:param reason_client: Reason client
|
430
|
+
:param response_client: Response client
|
431
|
+
:param reason_prompt: Default value for reason_prompt
|
432
|
+
:param reason_system_prompt: Default value for reason_system_prompt
|
433
|
+
"""
|
333
434
|
self.reason_client = reason_client
|
334
435
|
self.response_client = response_client
|
335
436
|
self.reason_prompt = reason_prompt
|
437
|
+
self.reason_system_prompt = reason_system_prompt
|
336
438
|
|
337
439
|
def chat_completion(
|
338
440
|
self,
|
@@ -342,10 +444,35 @@ class DeepAnythingClient:
|
|
342
444
|
show_model : str,
|
343
445
|
reason_args=None,
|
344
446
|
response_args=None,
|
447
|
+
reason_prompt: Optional[str] = None,
|
448
|
+
reason_system_prompt: Optional[str] = None,
|
345
449
|
created : int = int(time.time()),
|
346
450
|
_id : str = make_id_by_timestamp(),
|
347
|
-
stream = False
|
451
|
+
stream = False,
|
452
|
+
max_tokens : Optional[int] = None
|
348
453
|
) -> Stream or ChatCompletion:
|
454
|
+
"""
|
455
|
+
Make chat completion synchronously.
|
456
|
+
|
457
|
+
:param messages: Messages
|
458
|
+
:param reason_model: Reason model
|
459
|
+
:param response_model: Response model
|
460
|
+
:param show_model: Specify the model name in the return value
|
461
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
462
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
463
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
464
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
465
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
466
|
+
:param stream: Whether you use streaming return
|
467
|
+
:param _id: Specify the `id` in the return value
|
468
|
+
:param max_tokens: max_tokens
|
469
|
+
:return: Return a Stream if stream is Ture,otherwise return a ChatCompletion
|
470
|
+
"""
|
471
|
+
if reason_prompt is None:
|
472
|
+
reason_prompt = self.reason_prompt
|
473
|
+
if reason_system_prompt is None:
|
474
|
+
reason_system_prompt = self.reason_system_prompt
|
475
|
+
|
349
476
|
return chat_completion(
|
350
477
|
messages=messages,
|
351
478
|
reason_model=reason_model,
|
@@ -355,10 +482,12 @@ class DeepAnythingClient:
|
|
355
482
|
show_model=show_model,
|
356
483
|
reason_args=reason_args,
|
357
484
|
response_args=response_args,
|
485
|
+
reason_prompt=reason_prompt,
|
486
|
+
reason_system_prompt=reason_system_prompt,
|
358
487
|
created=created,
|
359
488
|
_id=_id,
|
360
489
|
stream=stream,
|
361
|
-
|
490
|
+
max_tokens=max_tokens
|
362
491
|
)
|
363
492
|
|
364
493
|
def chat_completion_stream(
|
@@ -369,9 +498,33 @@ class DeepAnythingClient:
|
|
369
498
|
show_model : str,
|
370
499
|
reason_args=None,
|
371
500
|
response_args=None,
|
501
|
+
reason_prompt: Optional[str] = None,
|
502
|
+
reason_system_prompt: Optional[str] = None,
|
372
503
|
created : int = int(time.time()),
|
373
|
-
_id : str = make_id_by_timestamp()
|
504
|
+
_id : str = make_id_by_timestamp(),
|
505
|
+
max_tokens : Optional[int] = None
|
374
506
|
) -> Stream:
|
507
|
+
"""
|
508
|
+
Make chat completion synchronously.This method uses streaming return
|
509
|
+
|
510
|
+
:param messages: Messages
|
511
|
+
:param reason_model: Reason model
|
512
|
+
:param response_model: Response model
|
513
|
+
:param show_model: Specify the model name in the return value
|
514
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
515
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
516
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
517
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
518
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
519
|
+
:param _id: Specify the `id` in the return value
|
520
|
+
:param max_tokens: max_tokens
|
521
|
+
:return: Return a Stream if stream is Ture,otherwise return a ChatCompletion
|
522
|
+
"""
|
523
|
+
|
524
|
+
if reason_prompt is None:
|
525
|
+
reason_prompt = self.reason_prompt
|
526
|
+
if reason_system_prompt is None:
|
527
|
+
reason_system_prompt = self.reason_system_prompt
|
375
528
|
return chat_completion_stream(
|
376
529
|
messages=messages,
|
377
530
|
reason_model=reason_model,
|
@@ -381,27 +534,40 @@ class DeepAnythingClient:
|
|
381
534
|
show_model=show_model,
|
382
535
|
reason_args=reason_args,
|
383
536
|
response_args=response_args,
|
537
|
+
reason_prompt=reason_prompt,
|
538
|
+
reason_system_prompt=reason_system_prompt,
|
384
539
|
created=created,
|
385
540
|
_id=_id,
|
386
|
-
|
541
|
+
max_tokens=max_tokens
|
387
542
|
)
|
388
543
|
|
389
544
|
|
390
545
|
class AsyncDeepAnythingClient:
|
546
|
+
"""
|
547
|
+
DeepAnything Async Client
|
548
|
+
"""
|
391
549
|
reason_client : AsyncReasonClient
|
392
550
|
response_client : AsyncResponseClient
|
393
|
-
|
394
|
-
|
551
|
+
reason_prompt : Optional[str]
|
552
|
+
reason_system_prompt : Optional[str]
|
395
553
|
|
396
554
|
def __init__(
|
397
555
|
self,
|
398
556
|
reason_client: AsyncReasonClient,
|
399
557
|
response_client: AsyncResponseClient,
|
400
|
-
reason_prompt : str =
|
558
|
+
reason_prompt : Optional[str] = None,
|
559
|
+
reason_system_prompt: Optional[str] = None
|
401
560
|
):
|
561
|
+
"""
|
562
|
+
:param reason_client: Reason client
|
563
|
+
:param response_client: Response client
|
564
|
+
:param reason_prompt: Default value for reason_prompt
|
565
|
+
:param reason_system_prompt: Default value for reason_system_prompt
|
566
|
+
"""
|
402
567
|
self.reason_client = reason_client
|
403
568
|
self.response_client = response_client
|
404
569
|
self.reason_prompt = reason_prompt
|
570
|
+
self.reason_system_prompt = reason_system_prompt
|
405
571
|
|
406
572
|
async def chat_completion(
|
407
573
|
self,
|
@@ -411,10 +577,36 @@ class AsyncDeepAnythingClient:
|
|
411
577
|
show_model: str,
|
412
578
|
reason_args=None,
|
413
579
|
response_args=None,
|
580
|
+
reason_prompt: Optional[str] = None,
|
581
|
+
reason_system_prompt: Optional[str] = None,
|
414
582
|
created: int = int(time.time()),
|
415
583
|
_id: str = make_id_by_timestamp(),
|
416
|
-
stream=False
|
584
|
+
stream=False,
|
585
|
+
max_tokens : Optional[int] = None
|
417
586
|
):
|
587
|
+
"""
|
588
|
+
Make chat completion asynchronously.
|
589
|
+
|
590
|
+
:param stream: Whether you use streaming return
|
591
|
+
:param messages: Messages
|
592
|
+
:param reason_model: Reason model
|
593
|
+
:param response_model: Response model
|
594
|
+
:param show_model: Specify the model name in the return value
|
595
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
596
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
597
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
598
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
599
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
600
|
+
:param _id: Specify the `id` in the return value
|
601
|
+
:param max_tokens: max_tokens
|
602
|
+
:return: Return an AsyncStream if stream is Ture,otherwise return a ChatCompletion
|
603
|
+
"""
|
604
|
+
|
605
|
+
if reason_prompt is None:
|
606
|
+
reason_prompt = self.reason_prompt
|
607
|
+
if reason_system_prompt is None:
|
608
|
+
reason_system_prompt = self.reason_system_prompt
|
609
|
+
|
418
610
|
return await chat_completion_async(
|
419
611
|
messages=messages,
|
420
612
|
reason_model=reason_model,
|
@@ -424,10 +616,12 @@ class AsyncDeepAnythingClient:
|
|
424
616
|
show_model=show_model,
|
425
617
|
reason_args=reason_args,
|
426
618
|
response_args=response_args,
|
619
|
+
reason_prompt=reason_prompt,
|
620
|
+
reason_system_prompt=reason_system_prompt,
|
427
621
|
created=created,
|
428
622
|
_id=_id,
|
429
623
|
stream=stream,
|
430
|
-
|
624
|
+
max_tokens=max_tokens
|
431
625
|
)
|
432
626
|
|
433
627
|
async def chat_completion_stream(
|
@@ -438,9 +632,34 @@ class AsyncDeepAnythingClient:
|
|
438
632
|
show_model : str,
|
439
633
|
reason_args=None,
|
440
634
|
response_args=None,
|
635
|
+
reason_prompt: Optional[str] = None,
|
636
|
+
reason_system_prompt: Optional[str] = None,
|
441
637
|
created : int = int(time.time()),
|
442
|
-
_id : str = make_id_by_timestamp()
|
638
|
+
_id : str = make_id_by_timestamp(),
|
639
|
+
max_tokens : Optional[int] = None
|
443
640
|
) -> AsyncStream:
|
641
|
+
"""
|
642
|
+
Make chat completion asynchronously.This method uses streaming return
|
643
|
+
|
644
|
+
:param messages: Messages
|
645
|
+
:param reason_model: Reason model
|
646
|
+
:param response_model: Response model
|
647
|
+
:param show_model: Specify the model name in the return value
|
648
|
+
:param reason_args: Additional parameters passed to the reason client, such as temperature, top_k, etc.
|
649
|
+
:param response_args: Additional parameters passed to the response client, such as temperature, top_k, etc.
|
650
|
+
:param reason_prompt: Specifies how the thinking content should be embedded into the conversation. DeepAnything will use `reason_prompt` to format the thinking content. The default is `<think>{}</think>`.
|
651
|
+
:param reason_system_prompt: Adds extra prompt words for the thinking model. This prompt will be placed at the end of the message as a `system` role and passed to the thinking model. If not specified, it will not take effect.
|
652
|
+
:param created: The timestamp indicating the time when the chat completion was created
|
653
|
+
:param _id: Specify the `id` in the return value
|
654
|
+
:param max_tokens: max_tokens
|
655
|
+
:return: Return a Stream if stream is Ture,otherwise return a ChatCompletion
|
656
|
+
"""
|
657
|
+
|
658
|
+
if reason_prompt is None:
|
659
|
+
reason_prompt = self.reason_prompt
|
660
|
+
if reason_system_prompt is None:
|
661
|
+
reason_system_prompt = self.reason_system_prompt
|
662
|
+
|
444
663
|
return await chat_completion_stream_async(
|
445
664
|
messages=messages,
|
446
665
|
reason_model=reason_model,
|
@@ -450,7 +669,9 @@ class AsyncDeepAnythingClient:
|
|
450
669
|
show_model=show_model,
|
451
670
|
reason_args=reason_args,
|
452
671
|
response_args=response_args,
|
672
|
+
reason_prompt=reason_prompt,
|
673
|
+
reason_system_prompt=reason_system_prompt,
|
453
674
|
created=created,
|
454
675
|
_id=_id,
|
455
|
-
|
676
|
+
max_tokens=max_tokens
|
456
677
|
)
|