Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions zhipuai/api_resource/chat/async_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions zhipuai/api_resource/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion zhipuai/types/chat/chat_completion_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading