chore: thinking (#18)

Co-authored-by: zhengweijun <weijun.zheng@aminer.cn>
This commit is contained in:
wellenzheng 2025-07-26 17:52:00 +08:00 committed by GitHub
parent 508eaf4f4c
commit f6ec3f2189
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 60 additions and 5 deletions

View file

@ -41,16 +41,14 @@
- **Web Search**: Integrated web search capabilities - **Web Search**: Integrated web search capabilities
- **File Management**: Upload, download, and manage files - **File Management**: Upload, download, and manage files
- **Batch Operations**: Efficient batch processing for multiple requests - **Batch Operations**: Efficient batch processing for multiple requests
- **Knowledge Base**: Knowledge management and retrieval
- **Content Moderation**: Built-in content safety and moderation - **Content Moderation**: Built-in content safety and moderation
- **Image Generation**: AI-powered image creation - **Image Generation**: AI-powered image creation
- **Fine-tuning**: Custom model training capabilities
## 📦 Installation ## 📦 Installation
### Requirements ### Requirements
- **Python**: 3.9+ - **Python**: 3.8+
- **Package Manager**: pip - **Package Manager**: pip
### Install via pip ### Install via pip

View file

@ -41,10 +41,8 @@
- **网络搜索**: 集成的网络搜索功能 - **网络搜索**: 集成的网络搜索功能
- **文件管理**: 上传、下载和管理文件 - **文件管理**: 上传、下载和管理文件
- **批量操作**: 多请求的高效批量处理 - **批量操作**: 多请求的高效批量处理
- **知识库**: 知识管理和检索
- **内容审核**: 内置内容安全和审核 - **内容审核**: 内置内容安全和审核
- **图像生成**: AI 驱动的图像创建 - **图像生成**: AI 驱动的图像创建
- **模型微调**: 自定义模型训练功能
## 📦 安装 ## 📦 安装

View file

@ -0,0 +1,59 @@
import logging
import logging.config
import time
import zai
from zai import ZaiClient
def test_chat_completion_with_thinking(logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore
client = ZaiClient() # Fill in your own API Key
try:
# Generate request_id
request_id = time.time()
print(f'request_id:{request_id}')
response = client.chat.completions.create(
request_id=request_id,
model='glm-4.5',
messages=[
{'role': 'user', 'content': '请介绍一下Agent的原理并给出详细的推理过程'}
],
top_p=0.7,
temperature=0.9,
)
print(response)
except zai.core._errors.APIRequestFailedError as err:
print(err)
except zai.core._errors.APIInternalError as err:
print(err)
except zai.core._errors.APIStatusError as err:
print(err)
def test_chat_completion_without_thinking(logging_conf):
logging.config.dictConfig(logging_conf) # type: ignore
client = ZaiClient() # Fill in your own API Key
try:
# Generate request_id
request_id = time.time()
print(f'request_id:{request_id}')
response = client.chat.completions.create(
request_id=request_id,
model='glm-4.5',
messages=[
{'role': 'user', 'content': '请介绍一下Agent的原理'}
],
top_p=0.7,
temperature=0.9,
thinking={
"type": "disabled",
}
)
print(response)
except zai.core._errors.APIRequestFailedError as err:
print(err)
except zai.core._errors.APIInternalError as err:
print(err)
except zai.core._errors.APIStatusError as err:
print(err)