vectorvein 0.2.6__py3-none-any.whl → 0.2.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.
@@ -1,11 +1,30 @@
1
1
  # @Author: Bi Ying
2
2
  # @Date: 2024-07-26 14:48:55
3
3
  import json
4
- from typing import overload, Generator, AsyncGenerator, Any, Literal, Iterable
4
+ from typing import (
5
+ Any,
6
+ Dict,
7
+ List,
8
+ Union,
9
+ Literal,
10
+ Iterable,
11
+ overload,
12
+ Optional,
13
+ Generator,
14
+ AsyncGenerator,
15
+ )
5
16
 
6
17
  import httpx
7
18
  from openai._types import NotGiven as OpenAINotGiven
8
19
  from openai._types import NOT_GIVEN as OPENAI_NOT_GIVEN
20
+ from openai._types import Headers, Query, Body
21
+ from openai.types.shared_params.metadata import Metadata
22
+ from openai.types.chat.completion_create_params import ResponseFormat
23
+ from openai.types.chat.chat_completion_modality import ChatCompletionModality
24
+ from openai.types.chat.chat_completion_audio_param import ChatCompletionAudioParam
25
+ from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
26
+ from openai.types.chat.chat_completion_stream_options_param import ChatCompletionStreamOptionsParam
27
+ from openai.types.chat.chat_completion_prediction_content_param import ChatCompletionPredictionContentParam
9
28
  from anthropic import (
10
29
  Anthropic,
11
30
  AnthropicVertex,
@@ -17,8 +36,11 @@ from anthropic import (
17
36
  from anthropic._types import NOT_GIVEN
18
37
  from anthropic.types import (
19
38
  TextBlock,
39
+ ThinkingBlock,
40
+ RedactedThinkingBlock,
20
41
  MessageParam,
21
42
  ToolUseBlock,
43
+ ThinkingConfigParam,
22
44
  RawMessageDeltaEvent,
23
45
  RawMessageStartEvent,
24
46
  RawContentBlockStartEvent,
@@ -43,7 +65,6 @@ from ..types.llm_parameters import (
43
65
  ChatCompletionMessage,
44
66
  ChatCompletionToolParam,
45
67
  ChatCompletionDeltaMessage,
46
- ChatCompletionStreamOptionsParam,
47
68
  )
48
69
 
49
70
 
@@ -128,6 +149,8 @@ def refactor_into_openai_messages(messages: Iterable[MessageParam]):
128
149
  for item in content:
129
150
  if isinstance(item, (TextBlock, ToolUseBlock)):
130
151
  _content.append(item.model_dump())
152
+ elif isinstance(item, (ThinkingBlock, RedactedThinkingBlock)):
153
+ continue
131
154
  elif item.get("type") == "image":
132
155
  image_data = item.get("source", {}).get("data", "")
133
156
  media_type = item.get("source", {}).get("media_type", "")
@@ -257,11 +280,33 @@ class AnthropicChatClient(BaseChatClient):
257
280
  max_tokens: int | None = None,
258
281
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
259
282
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
260
- response_format: dict | None = None,
283
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
261
284
  stream_options: ChatCompletionStreamOptionsParam | None = None,
262
285
  top_p: float | NotGiven | None = NOT_GIVEN,
263
286
  skip_cutoff: bool = False,
264
- **kwargs,
287
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
288
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
289
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
290
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
291
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
292
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
293
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
294
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
295
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
296
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
297
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
298
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
299
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
300
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
301
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
302
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
303
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
304
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
305
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
306
+ extra_headers: Headers | None = None,
307
+ extra_query: Query | None = None,
308
+ extra_body: Body | None = None,
309
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
265
310
  ) -> ChatCompletionMessage:
266
311
  pass
267
312
 
@@ -276,11 +321,33 @@ class AnthropicChatClient(BaseChatClient):
276
321
  max_tokens: int | None = None,
277
322
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
278
323
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
279
- response_format: dict | None = None,
324
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
280
325
  stream_options: ChatCompletionStreamOptionsParam | None = None,
281
326
  top_p: float | NotGiven | None = NOT_GIVEN,
282
327
  skip_cutoff: bool = False,
283
- **kwargs,
328
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
329
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
330
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
331
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
332
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
333
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
334
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
335
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
336
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
337
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
338
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
339
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
340
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
341
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
342
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
343
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
344
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
345
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
346
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
347
+ extra_headers: Headers | None = None,
348
+ extra_query: Query | None = None,
349
+ extra_body: Body | None = None,
350
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
284
351
  ) -> Generator[ChatCompletionDeltaMessage, None, None]:
285
352
  pass
286
353
 
@@ -295,11 +362,33 @@ class AnthropicChatClient(BaseChatClient):
295
362
  max_tokens: int | None = None,
296
363
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
297
364
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
298
- response_format: dict | None = None,
365
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
299
366
  stream_options: ChatCompletionStreamOptionsParam | None = None,
300
367
  top_p: float | NotGiven | None = NOT_GIVEN,
301
368
  skip_cutoff: bool = False,
302
- **kwargs,
369
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
370
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
371
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
372
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
373
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
374
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
375
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
376
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
377
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
378
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
379
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
380
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
381
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
382
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
383
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
384
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
385
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
386
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
387
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
388
+ extra_headers: Headers | None = None,
389
+ extra_query: Query | None = None,
390
+ extra_body: Body | None = None,
391
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
303
392
  ) -> ChatCompletionMessage | Generator[ChatCompletionDeltaMessage, Any, None]:
304
393
  pass
305
394
 
@@ -313,11 +402,33 @@ class AnthropicChatClient(BaseChatClient):
313
402
  max_tokens: int | None = None,
314
403
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
315
404
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
316
- response_format: dict | None = None,
405
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
317
406
  stream_options: ChatCompletionStreamOptionsParam | None = None,
318
407
  top_p: float | NotGiven | None = NOT_GIVEN,
319
408
  skip_cutoff: bool = False,
320
- **kwargs,
409
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
410
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
411
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
412
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
413
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
414
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
415
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
416
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
417
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
418
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
419
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
420
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
421
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
422
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
423
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
424
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
425
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
426
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
427
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
428
+ extra_headers: Headers | None = None,
429
+ extra_query: Query | None = None,
430
+ extra_body: Body | None = None,
431
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
321
432
  ):
322
433
  if model is not None:
323
434
  self.model = model
@@ -362,7 +473,28 @@ class AnthropicChatClient(BaseChatClient):
362
473
  stream_options=stream_options,
363
474
  top_p=top_p,
364
475
  skip_cutoff=skip_cutoff,
365
- **kwargs,
476
+ audio=audio,
477
+ frequency_penalty=frequency_penalty,
478
+ logit_bias=logit_bias,
479
+ logprobs=logprobs,
480
+ max_completion_tokens=max_completion_tokens,
481
+ metadata=metadata,
482
+ modalities=modalities,
483
+ n=n,
484
+ parallel_tool_calls=parallel_tool_calls,
485
+ prediction=prediction,
486
+ presence_penalty=presence_penalty,
487
+ reasoning_effort=reasoning_effort,
488
+ seed=seed,
489
+ service_tier=service_tier,
490
+ stop=stop,
491
+ store=store,
492
+ top_logprobs=top_logprobs,
493
+ user=user,
494
+ extra_headers=extra_headers,
495
+ extra_query=extra_query,
496
+ extra_body=extra_body,
497
+ timeout=timeout,
366
498
  )
367
499
  for chunk in response:
368
500
  yield chunk
@@ -389,7 +521,28 @@ class AnthropicChatClient(BaseChatClient):
389
521
  response_format=response_format,
390
522
  top_p=top_p,
391
523
  skip_cutoff=skip_cutoff,
392
- **kwargs,
524
+ audio=audio,
525
+ frequency_penalty=frequency_penalty,
526
+ logit_bias=logit_bias,
527
+ logprobs=logprobs,
528
+ max_completion_tokens=max_completion_tokens,
529
+ metadata=metadata,
530
+ modalities=modalities,
531
+ n=n,
532
+ parallel_tool_calls=parallel_tool_calls,
533
+ prediction=prediction,
534
+ presence_penalty=presence_penalty,
535
+ reasoning_effort=reasoning_effort,
536
+ seed=seed,
537
+ service_tier=service_tier,
538
+ stop=stop,
539
+ store=store,
540
+ top_logprobs=top_logprobs,
541
+ user=user,
542
+ extra_headers=extra_headers,
543
+ extra_query=extra_query,
544
+ extra_body=extra_body,
545
+ timeout=timeout,
393
546
  )
394
547
 
395
548
  raw_client = self.raw_client # 调用完 self.raw_client 后,self.model_id 会被赋值
@@ -403,6 +556,8 @@ class AnthropicChatClient(BaseChatClient):
403
556
  top_p = NOT_GIVEN
404
557
  if isinstance(self.temperature, NotGiven) or self.temperature is None:
405
558
  self.temperature = NOT_GIVEN
559
+ if isinstance(thinking, NotGiven) or thinking is None:
560
+ thinking = NOT_GIVEN
406
561
 
407
562
  if messages[0].get("role") == "system":
408
563
  system_prompt: str = messages[0]["content"]
@@ -447,11 +602,11 @@ class AnthropicChatClient(BaseChatClient):
447
602
  tools=tools_params,
448
603
  tool_choice=tool_choice_param,
449
604
  top_p=top_p,
450
- **kwargs,
605
+ thinking=thinking,
451
606
  )
452
607
 
453
608
  def generator():
454
- result = {"content": "", "usage": {}, "tool_calls": []}
609
+ result = {"content": "", "reasoning_content": "", "usage": {}, "tool_calls": []}
455
610
  for chunk in stream_response:
456
611
  message = {"content": "", "tool_calls": []}
457
612
  if isinstance(chunk, RawMessageStartEvent):
@@ -472,11 +627,16 @@ class AnthropicChatClient(BaseChatClient):
472
627
  ]
473
628
  elif chunk.content_block.type == "text":
474
629
  message["content"] = chunk.content_block.text
630
+ elif chunk.content_block.type == "thinking":
631
+ message["reasoning_content"] = chunk.content_block.thinking
475
632
  yield ChatCompletionDeltaMessage(**message)
476
633
  elif isinstance(chunk, RawContentBlockDeltaEvent):
477
634
  if chunk.delta.type == "text_delta":
478
635
  message["content"] = chunk.delta.text
479
636
  result["content"] += chunk.delta.text
637
+ elif chunk.delta.type == "thinking_delta":
638
+ message["reasoning_content"] = chunk.delta.thinking
639
+ result["reasoning_content"] += chunk.delta.thinking
480
640
  elif chunk.delta.type == "input_json_delta":
481
641
  result["tool_calls"][0]["function"]["arguments"] += chunk.delta.partial_json
482
642
  message["tool_calls"] = [
@@ -516,11 +676,12 @@ class AnthropicChatClient(BaseChatClient):
516
676
  tools=tools_params,
517
677
  tool_choice=tool_choice_param,
518
678
  top_p=top_p,
519
- **kwargs,
679
+ thinking=thinking,
520
680
  )
521
681
 
522
682
  result = {
523
683
  "content": "",
684
+ "reasoning_content": "",
524
685
  "usage": {
525
686
  "prompt_tokens": response.usage.input_tokens,
526
687
  "completion_tokens": response.usage.output_tokens,
@@ -531,6 +692,8 @@ class AnthropicChatClient(BaseChatClient):
531
692
  for content_block in response.content:
532
693
  if isinstance(content_block, TextBlock):
533
694
  result["content"] += content_block.text
695
+ elif isinstance(content_block, ThinkingBlock):
696
+ result["reasoning_content"] = content_block.thinking
534
697
  elif isinstance(content_block, ToolUseBlock):
535
698
  tool_calls.append(content_block.model_dump())
536
699
 
@@ -647,11 +810,33 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
647
810
  max_tokens: int | None = None,
648
811
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
649
812
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
650
- response_format: dict | None = None,
813
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
651
814
  stream_options: ChatCompletionStreamOptionsParam | None = None,
652
815
  top_p: float | NotGiven | None = NOT_GIVEN,
653
816
  skip_cutoff: bool = False,
654
- **kwargs,
817
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
818
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
819
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
820
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
821
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
822
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
823
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
824
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
825
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
826
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
827
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
828
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
829
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
830
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
831
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
832
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
833
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
834
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
835
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
836
+ extra_headers: Headers | None = None,
837
+ extra_query: Query | None = None,
838
+ extra_body: Body | None = None,
839
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
655
840
  ) -> ChatCompletionMessage:
656
841
  pass
657
842
 
@@ -666,11 +851,33 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
666
851
  max_tokens: int | None = None,
667
852
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
668
853
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
669
- response_format: dict | None = None,
854
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
670
855
  stream_options: ChatCompletionStreamOptionsParam | None = None,
671
856
  top_p: float | NotGiven | None = NOT_GIVEN,
672
857
  skip_cutoff: bool = False,
673
- **kwargs,
858
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
859
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
860
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
861
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
862
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
863
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
864
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
865
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
866
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
867
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
868
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
869
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
870
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
871
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
872
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
873
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
874
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
875
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
876
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
877
+ extra_headers: Headers | None = None,
878
+ extra_query: Query | None = None,
879
+ extra_body: Body | None = None,
880
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
674
881
  ) -> AsyncGenerator[ChatCompletionDeltaMessage, Any]:
675
882
  pass
676
883
 
@@ -685,11 +892,33 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
685
892
  max_tokens: int | None = None,
686
893
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
687
894
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
688
- response_format: dict | None = None,
895
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
689
896
  stream_options: ChatCompletionStreamOptionsParam | None = None,
690
897
  top_p: float | NotGiven | None = NOT_GIVEN,
691
898
  skip_cutoff: bool = False,
692
- **kwargs,
899
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
900
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
901
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
902
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
903
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
904
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
905
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
906
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
907
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
908
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
909
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
910
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
911
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
912
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
913
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
914
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
915
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
916
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
917
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
918
+ extra_headers: Headers | None = None,
919
+ extra_query: Query | None = None,
920
+ extra_body: Body | None = None,
921
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
693
922
  ) -> ChatCompletionMessage | AsyncGenerator[ChatCompletionDeltaMessage, Any]:
694
923
  pass
695
924
 
@@ -703,11 +932,33 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
703
932
  max_tokens: int | None = None,
704
933
  tools: Iterable[ToolParam] | NotGiven = NOT_GIVEN,
705
934
  tool_choice: ToolChoice | NotGiven = NOT_GIVEN,
706
- response_format: dict | None = None,
935
+ response_format: ResponseFormat | NotGiven = NOT_GIVEN,
707
936
  stream_options: ChatCompletionStreamOptionsParam | None = None,
708
937
  top_p: float | NotGiven | None = NOT_GIVEN,
709
938
  skip_cutoff: bool = False,
710
- **kwargs,
939
+ audio: Optional[ChatCompletionAudioParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
940
+ frequency_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
941
+ logit_bias: Optional[Dict[str, int]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
942
+ logprobs: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
943
+ max_completion_tokens: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
944
+ metadata: Optional[Metadata] | OpenAINotGiven = OPENAI_NOT_GIVEN,
945
+ modalities: Optional[List[ChatCompletionModality]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
946
+ n: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
947
+ parallel_tool_calls: bool | OpenAINotGiven = OPENAI_NOT_GIVEN,
948
+ prediction: Optional[ChatCompletionPredictionContentParam] | OpenAINotGiven = OPENAI_NOT_GIVEN,
949
+ presence_penalty: Optional[float] | OpenAINotGiven = OPENAI_NOT_GIVEN,
950
+ reasoning_effort: Optional[ChatCompletionReasoningEffort] | OpenAINotGiven = OPENAI_NOT_GIVEN,
951
+ thinking: ThinkingConfigParam | None | NotGiven = NOT_GIVEN,
952
+ seed: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
953
+ service_tier: Optional[Literal["auto", "default"]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
954
+ stop: Union[Optional[str], List[str]] | OpenAINotGiven = OPENAI_NOT_GIVEN,
955
+ store: Optional[bool] | OpenAINotGiven = OPENAI_NOT_GIVEN,
956
+ top_logprobs: Optional[int] | OpenAINotGiven = OPENAI_NOT_GIVEN,
957
+ user: str | OpenAINotGiven = OPENAI_NOT_GIVEN,
958
+ extra_headers: Headers | None = None,
959
+ extra_query: Query | None = None,
960
+ extra_body: Body | None = None,
961
+ timeout: float | httpx.Timeout | None | OpenAINotGiven = OPENAI_NOT_GIVEN,
711
962
  ):
712
963
  if model is not None:
713
964
  self.model = model
@@ -753,7 +1004,28 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
753
1004
  stream_options=stream_options,
754
1005
  top_p=top_p,
755
1006
  skip_cutoff=skip_cutoff,
756
- **kwargs,
1007
+ audio=audio,
1008
+ frequency_penalty=frequency_penalty,
1009
+ logit_bias=logit_bias,
1010
+ logprobs=logprobs,
1011
+ max_completion_tokens=max_completion_tokens,
1012
+ metadata=metadata,
1013
+ modalities=modalities,
1014
+ n=n,
1015
+ parallel_tool_calls=parallel_tool_calls,
1016
+ prediction=prediction,
1017
+ presence_penalty=presence_penalty,
1018
+ reasoning_effort=reasoning_effort,
1019
+ seed=seed,
1020
+ service_tier=service_tier,
1021
+ stop=stop,
1022
+ store=store,
1023
+ top_logprobs=top_logprobs,
1024
+ user=user,
1025
+ extra_headers=extra_headers,
1026
+ extra_query=extra_query,
1027
+ extra_body=extra_body,
1028
+ timeout=timeout,
757
1029
  )
758
1030
  async for chunk in response:
759
1031
  yield chunk
@@ -781,7 +1053,28 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
781
1053
  response_format=response_format,
782
1054
  top_p=top_p,
783
1055
  skip_cutoff=skip_cutoff,
784
- **kwargs,
1056
+ audio=audio,
1057
+ frequency_penalty=frequency_penalty,
1058
+ logit_bias=logit_bias,
1059
+ logprobs=logprobs,
1060
+ max_completion_tokens=max_completion_tokens,
1061
+ metadata=metadata,
1062
+ modalities=modalities,
1063
+ n=n,
1064
+ parallel_tool_calls=parallel_tool_calls,
1065
+ prediction=prediction,
1066
+ presence_penalty=presence_penalty,
1067
+ reasoning_effort=reasoning_effort,
1068
+ seed=seed,
1069
+ service_tier=service_tier,
1070
+ stop=stop,
1071
+ store=store,
1072
+ top_logprobs=top_logprobs,
1073
+ user=user,
1074
+ extra_headers=extra_headers,
1075
+ extra_query=extra_query,
1076
+ extra_body=extra_body,
1077
+ timeout=timeout,
785
1078
  )
786
1079
 
787
1080
  raw_client = self.raw_client # 调用完 self.raw_client 后,self.model_id 会被赋值
@@ -795,6 +1088,8 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
795
1088
  top_p = NOT_GIVEN
796
1089
  if isinstance(self.temperature, NotGiven) or self.temperature is None:
797
1090
  self.temperature = NOT_GIVEN
1091
+ if isinstance(thinking, NotGiven) or thinking is None:
1092
+ thinking = NOT_GIVEN
798
1093
 
799
1094
  if messages[0].get("role") == "system":
800
1095
  system_prompt = messages[0]["content"]
@@ -839,11 +1134,11 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
839
1134
  tools=tools_params,
840
1135
  tool_choice=tool_choice_param,
841
1136
  top_p=top_p,
842
- **kwargs,
1137
+ thinking=thinking,
843
1138
  )
844
1139
 
845
1140
  async def generator():
846
- result = {"content": "", "usage": {}, "tool_calls": []}
1141
+ result = {"content": "", "reasoning_content": "", "usage": {}, "tool_calls": []}
847
1142
  async for chunk in stream_response:
848
1143
  message = {"content": "", "tool_calls": []}
849
1144
  if isinstance(chunk, RawMessageStartEvent):
@@ -864,11 +1159,16 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
864
1159
  ]
865
1160
  elif chunk.content_block.type == "text":
866
1161
  message["content"] = chunk.content_block.text
1162
+ elif chunk.content_block.type == "thinking":
1163
+ message["reasoning_content"] = chunk.content_block.thinking
867
1164
  yield ChatCompletionDeltaMessage(**message)
868
1165
  elif isinstance(chunk, RawContentBlockDeltaEvent):
869
1166
  if chunk.delta.type == "text_delta":
870
1167
  message["content"] = chunk.delta.text
871
1168
  result["content"] += chunk.delta.text
1169
+ elif chunk.delta.type == "thinking_delta":
1170
+ message["reasoning_content"] = chunk.delta.thinking
1171
+ result["reasoning_content"] += chunk.delta.thinking
872
1172
  elif chunk.delta.type == "input_json_delta":
873
1173
  result["tool_calls"][0]["function"]["arguments"] += chunk.delta.partial_json
874
1174
  message["tool_calls"] = [
@@ -908,11 +1208,12 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
908
1208
  tools=tools_params,
909
1209
  tool_choice=tool_choice_param,
910
1210
  top_p=top_p,
911
- **kwargs,
1211
+ thinking=thinking,
912
1212
  )
913
1213
 
914
1214
  result = {
915
1215
  "content": "",
1216
+ "reasoning_content": "",
916
1217
  "usage": {
917
1218
  "prompt_tokens": response.usage.input_tokens,
918
1219
  "completion_tokens": response.usage.output_tokens,
@@ -923,6 +1224,8 @@ class AsyncAnthropicChatClient(BaseAsyncChatClient):
923
1224
  for content_block in response.content:
924
1225
  if isinstance(content_block, TextBlock):
925
1226
  result["content"] += content_block.text
1227
+ elif isinstance(content_block, ThinkingBlock):
1228
+ result["reasoning_content"] = content_block.thinking
926
1229
  elif isinstance(content_block, ToolUseBlock):
927
1230
  tool_calls.append(content_block.model_dump())
928
1231