chore: thinking (#18)
Co-authored-by: zhengweijun <weijun.zheng@aminer.cn>
This commit is contained in:
parent
508eaf4f4c
commit
f6ec3f2189
3 changed files with 60 additions and 5 deletions
|
|
@ -41,16 +41,14 @@
|
|||
- **Web Search**: Integrated web search capabilities
|
||||
- **File Management**: Upload, download, and manage files
|
||||
- **Batch Operations**: Efficient batch processing for multiple requests
|
||||
- **Knowledge Base**: Knowledge management and retrieval
|
||||
- **Content Moderation**: Built-in content safety and moderation
|
||||
- **Image Generation**: AI-powered image creation
|
||||
- **Fine-tuning**: Custom model training capabilities
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
### Requirements
|
||||
|
||||
- **Python**: 3.9+
|
||||
- **Python**: 3.8+
|
||||
- **Package Manager**: pip
|
||||
|
||||
### Install via pip
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@
|
|||
- **网络搜索**: 集成的网络搜索功能
|
||||
- **文件管理**: 上传、下载和管理文件
|
||||
- **批量操作**: 多请求的高效批量处理
|
||||
- **知识库**: 知识管理和检索
|
||||
- **内容审核**: 内置内容安全和审核
|
||||
- **图像生成**: AI 驱动的图像创建
|
||||
- **模型微调**: 自定义模型训练功能
|
||||
|
||||
## 📦 安装
|
||||
|
||||
|
|
|
|||
59
tests/integration_tests/test_thinking.py
Normal file
59
tests/integration_tests/test_thinking.py
Normal 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)
|
||||
Loading…
Reference in a new issue