Skip to content

Commit f6ec3f2

Browse files
wellenzhengzhengweijun
andauthored
chore: thinking (#18)
Co-authored-by: zhengweijun <[email protected]>
1 parent 508eaf4 commit f6ec3f2

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,14 @@
4141
- **Web Search**: Integrated web search capabilities
4242
- **File Management**: Upload, download, and manage files
4343
- **Batch Operations**: Efficient batch processing for multiple requests
44-
- **Knowledge Base**: Knowledge management and retrieval
4544
- **Content Moderation**: Built-in content safety and moderation
4645
- **Image Generation**: AI-powered image creation
47-
- **Fine-tuning**: Custom model training capabilities
4846

4947
## 📦 Installation
5048

5149
### Requirements
5250

53-
- **Python**: 3.9+
51+
- **Python**: 3.8+
5452
- **Package Manager**: pip
5553

5654
### Install via pip

README_CN.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@
4141
- **网络搜索**: 集成的网络搜索功能
4242
- **文件管理**: 上传、下载和管理文件
4343
- **批量操作**: 多请求的高效批量处理
44-
- **知识库**: 知识管理和检索
4544
- **内容审核**: 内置内容安全和审核
4645
- **图像生成**: AI 驱动的图像创建
47-
- **模型微调**: 自定义模型训练功能
4846

4947
## 📦 安装
5048

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import logging
2+
import logging.config
3+
import time
4+
5+
import zai
6+
from zai import ZaiClient
7+
8+
def test_chat_completion_with_thinking(logging_conf):
9+
logging.config.dictConfig(logging_conf) # type: ignore
10+
client = ZaiClient() # Fill in your own API Key
11+
try:
12+
# Generate request_id
13+
request_id = time.time()
14+
print(f'request_id:{request_id}')
15+
response = client.chat.completions.create(
16+
request_id=request_id,
17+
model='glm-4.5',
18+
messages=[
19+
{'role': 'user', 'content': '请介绍一下Agent的原理,并给出详细的推理过程'}
20+
],
21+
top_p=0.7,
22+
temperature=0.9,
23+
)
24+
print(response)
25+
26+
except zai.core._errors.APIRequestFailedError as err:
27+
print(err)
28+
except zai.core._errors.APIInternalError as err:
29+
print(err)
30+
except zai.core._errors.APIStatusError as err:
31+
print(err)
32+
33+
def test_chat_completion_without_thinking(logging_conf):
34+
logging.config.dictConfig(logging_conf) # type: ignore
35+
client = ZaiClient() # Fill in your own API Key
36+
try:
37+
# Generate request_id
38+
request_id = time.time()
39+
print(f'request_id:{request_id}')
40+
response = client.chat.completions.create(
41+
request_id=request_id,
42+
model='glm-4.5',
43+
messages=[
44+
{'role': 'user', 'content': '请介绍一下Agent的原理'}
45+
],
46+
top_p=0.7,
47+
temperature=0.9,
48+
thinking={
49+
"type": "disabled",
50+
}
51+
)
52+
print(response)
53+
54+
except zai.core._errors.APIRequestFailedError as err:
55+
print(err)
56+
except zai.core._errors.APIInternalError as err:
57+
print(err)
58+
except zai.core._errors.APIStatusError as err:
59+
print(err)

0 commit comments

Comments
 (0)