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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## ✨ Core Features

### 🤖 **Chat Completions**
- **Standard Chat**: Create chat completions with various models including `glm-5.1`
- **Standard Chat**: Create chat completions with various models including `glm-5.2`
- **Streaming Support**: Real-time streaming responses for interactive applications
- **Tool Calling**: Function calling capabilities for enhanced AI interactions
- **Multimodal Chat**: Image understanding capabilities with vision models
Expand Down Expand Up @@ -104,7 +104,7 @@ client = ZhipuAiClient(api_key="your-api-key")

# Create chat completion
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "user", "content": "Hello, Z.ai!"}
]
Expand Down Expand Up @@ -278,7 +278,7 @@ client = ZaiClient(api_key="your-api-key")

try:
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "user", "content": "Hello, Z.ai!"}
]
Expand Down
6 changes: 3 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## ✨ 核心功能

### 🤖 **对话补全**
- **标准对话**: 支持 `glm-5.1` 等多种模型的对话补全
- **标准对话**: 支持 `glm-5.2` 等多种模型的对话补全
- **流式支持**: 实时流式响应,适用于交互式应用
- **工具调用**: 函数调用能力,增强 AI 交互体验
- **多模态对话**: 支持图像理解的视觉模型
Expand Down Expand Up @@ -106,7 +106,7 @@ client = ZhipuAiClient(api_key="your-api-key")

# Create chat completion
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "user", "content": "Hello, Z.ai!"}
]
Expand Down Expand Up @@ -285,7 +285,7 @@ client = ZaiClient(api_key="your-api-key") # 请填写您自己的APIKey

try:
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "user", "content": "你好, Z.ai !"}
]
Expand Down
14 changes: 7 additions & 7 deletions examples/basic_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def completion():

# Create chat completion
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
temperature=1.0,
)
Expand All @@ -19,7 +19,7 @@ def completion_with_stream():

# Create chat completion
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
messages=[
{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'Tell me a story about AI.'},
Expand All @@ -38,7 +38,7 @@ def completion_with_websearch():

# Create chat completion
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
messages=[
{'role': 'system', 'content': 'You are a helpful assistant.'},
{'role': 'user', 'content': 'What is artificial intelligence?'},
Expand Down Expand Up @@ -66,7 +66,7 @@ def completion_with_mcp_server_url():

# Create chat completion with MCP server URL
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
stream=False,
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
tools=[
Expand Down Expand Up @@ -95,7 +95,7 @@ def completion_with_mcp_server_label():

# Create chat completion with MCP server label
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
stream=False,
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
tools=[
Expand Down Expand Up @@ -217,7 +217,7 @@ def ofZai():
client = ZaiClient()
print(client.base_url)
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
temperature=0.7,
)
Expand All @@ -227,7 +227,7 @@ def ofZhipu():
client = ZhipuAiClient()
print(client.base_url)
response = client.chat.completions.create(
model='glm-5.1',
model='glm-5.2',
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
temperature=0.7,
)
Expand Down
6 changes: 3 additions & 3 deletions examples/glm_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def stream_web_search_example():
}]
client = ZaiClient()
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=messages,
tools=tools,
stream=True
Expand All @@ -35,7 +35,7 @@ def sync_example():
print("=== GLM-4 Synchronous Example ===")
client = ZaiClient()
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "system", "content": "You are a helpful assistant who provides professional, accurate, and insightful advice."},
{"role": "user", "content": "I'm very interested in the planets of the solar system, especially Saturn. Please provide basic information about Saturn, including its size, composition, ring system, and any unique astronomical phenomena."},
Expand All @@ -47,7 +47,7 @@ def async_example():
print("=== GLM-4 Async Example ===")
client = ZaiClient()
response = client.chat.asyncCompletions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion examples/glm_thinking.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ZaiSampler(SamplerBase):

def __init__(
self,
model: str = "glm-5",
model: str = "glm-5.2",
api_key: str = '',
system_message: Optional[str] = None,
temperature: float = 0.0,
Expand Down
2 changes: 1 addition & 1 deletion examples/stream_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def main():
client = ZhipuAiClient()
# create chat completion with tool calls and streaming
response = client.chat.completions.create(
model="glm-5.1",
model="glm-5.2",
messages=[
{"role": "user", "content": "How is the weather in Beijing and Shanghai? Please provide the answer in Celsius."},
],
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zai-sdk"
version = "0.2.2"
version = "0.2.3"
description = "A SDK library for accessing big model apis from Z.ai"
authors = ["Z.ai"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/zai/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = 'Z.ai'
__version__ = '0.2.2'
__version__ = '0.2.3'
7 changes: 5 additions & 2 deletions src/zai/api_resource/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def create(
response_format: object | None = None,
thinking: object | None = None,
watermark_enabled: Optional[bool] | NotGiven = NOT_GIVEN,
tool_stream: bool | NotGiven = NOT_GIVEN,
tool_stream: bool | NotGiven = NOT_GIVEN,
reasoning_effort: Optional[str] | NotGiven = NOT_GIVEN,
) -> Completion | StreamResponse[ChatCompletionChunk]:
"""
Create a chat completion
Expand Down Expand Up @@ -95,6 +96,7 @@ def create(
thinking (Optional[object]): Configuration parameters for model reasoning
watermark_enabled (Optional[bool]): Whether to enable watermark on generated audio
tool_stream (Optional[bool]): Whether to enable tool streaming
reasoning_effort (Optional[str]): Reasoning effort level, supports none, minimal, low, medium, high, xhigh, max. Effective for glm-5.2 and above models.
"""
logger.debug(f'temperature:{temperature}, top_p:{top_p}')
if temperature is not None and temperature != NOT_GIVEN:
Expand Down Expand Up @@ -143,7 +145,8 @@ def create(
'response_format': response_format,
'thinking': thinking,
'watermark_enabled': watermark_enabled,
'tool_stream': tool_stream,
'tool_stream': tool_stream,
'reasoning_effort': reasoning_effort,
}
)
return self._post(
Expand Down
Loading