diff --git a/zhipuai/api_resource/chat/async_completions.py b/zhipuai/api_resource/chat/async_completions.py index 012ae6a..44df527 100644 --- a/zhipuai/api_resource/chat/async_completions.py +++ b/zhipuai/api_resource/chat/async_completions.py @@ -44,6 +44,8 @@ def create( extra_headers: Headers | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + response_format: object | None = None, + thinking: object | None = None, ) -> AsyncTaskStatus: _cast_type = AsyncTaskStatus logger.debug(f"temperature:{temperature}, top_p:{top_p}") @@ -87,6 +89,8 @@ def create( "tool_choice": tool_choice, "meta": meta, "extra": maybe_transform(extra, code_geex_params.CodeGeexExtra), + "response_format": response_format, + "thinking": thinking } return self._post( "/async/chat/completions", diff --git a/zhipuai/api_resource/chat/completions.py b/zhipuai/api_resource/chat/completions.py index ae9f45d..ece8fb8 100644 --- a/zhipuai/api_resource/chat/completions.py +++ b/zhipuai/api_resource/chat/completions.py @@ -47,7 +47,8 @@ def create( extra_headers: Headers | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - response_format : object | None = None + response_format : object | None = None, + thinking : object | None = None, ) -> Completion | StreamResponse[ChatCompletionChunk]: logger.debug(f"temperature:{temperature}, top_p:{top_p}") if temperature is not None and temperature != NOT_GIVEN: @@ -91,7 +92,8 @@ def create( "tool_choice": tool_choice, "meta": meta, "extra": maybe_transform(extra, code_geex_params.CodeGeexExtra), - "response_format": response_format + "response_format": response_format, + "thinking": thinking }) return self._post( "/chat/completions", diff --git a/zhipuai/types/chat/chat_completion_chunk.py b/zhipuai/types/chat/chat_completion_chunk.py index 8b13311..5e2c0b5 100644 --- a/zhipuai/types/chat/chat_completion_chunk.py +++ b/zhipuai/types/chat/chat_completion_chunk.py @@ -49,13 +49,19 @@ class Choice(BaseModel): finish_reason: Optional[str] = None index: int +class PromptTokensDetails(BaseModel): + cached_tokens: int + +class CompletionTokensDetails(BaseModel): + reasoning_tokens: int class CompletionUsage(BaseModel): prompt_tokens: int + prompt_tokens_details: Optional[PromptTokensDetails] = None completion_tokens: int + completion_tokens_details: Optional[CompletionTokensDetails] = None total_tokens: int - class ChatCompletionChunk(BaseModel): id: Optional[str] = None choices: List[Choice]