feat: support glm-4.7 model (#56)
This commit is contained in:
parent
84d48d48f7
commit
6d9d9f84a4
13 changed files with 42 additions and 161 deletions
71
README.md
71
README.md
|
|
@ -11,7 +11,7 @@
|
||||||
## ✨ Core Features
|
## ✨ Core Features
|
||||||
|
|
||||||
### 🤖 **Chat Completions**
|
### 🤖 **Chat Completions**
|
||||||
- **Standard Chat**: Create chat completions with various models including `glm-4`, `charglm-3`
|
- **Standard Chat**: Create chat completions with various models including `glm-4.7`
|
||||||
- **Streaming Support**: Real-time streaming responses for interactive applications
|
- **Streaming Support**: Real-time streaming responses for interactive applications
|
||||||
- **Tool Calling**: Function calling capabilities for enhanced AI interactions
|
- **Tool Calling**: Function calling capabilities for enhanced AI interactions
|
||||||
- **Character Role-Playing**: Support for character-based conversations with `charglm-3` model
|
- **Character Role-Playing**: Support for character-based conversations with `charglm-3` model
|
||||||
|
|
@ -105,7 +105,7 @@ client = ZhipuAiClient(api_key="your-api-key")
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "Hello, Z.ai!"}
|
{"role": "user", "content": "Hello, Z.ai!"}
|
||||||
]
|
]
|
||||||
|
|
@ -169,7 +169,7 @@ client = ZaiClient(api_key="your-api-key")
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4.6',
|
model='glm-4.7',
|
||||||
messages=[
|
messages=[
|
||||||
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
||||||
{'role': 'user', 'content': 'Tell me a story about AI.'},
|
{'role': 'user', 'content': 'Tell me a story about AI.'},
|
||||||
|
|
@ -192,7 +192,7 @@ client = ZaiClient(api_key="your-api-key")
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4.6',
|
model='glm-4.7',
|
||||||
messages=[
|
messages=[
|
||||||
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
||||||
{'role': 'user', 'content': 'What is artificial intelligence?'},
|
{'role': 'user', 'content': 'What is artificial intelligence?'},
|
||||||
|
|
@ -244,65 +244,6 @@ response = client.chat.completions.create(
|
||||||
print(response)
|
print(response)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Character Role-Playing
|
|
||||||
|
|
||||||
```python
|
|
||||||
from zai import ZaiClient
|
|
||||||
|
|
||||||
# Initialize client
|
|
||||||
client = ZaiClient(api_key="your-api-key")
|
|
||||||
|
|
||||||
# Create chat completion
|
|
||||||
response = client.chat.completions.create(
|
|
||||||
model='charglm-3',
|
|
||||||
messages=[{'role': 'user', 'content': 'Hello, how are you doing lately?'}],
|
|
||||||
meta={
|
|
||||||
'user_info': 'I am a film director who specializes in music-themed movies.',
|
|
||||||
'bot_info': 'You are a popular domestic female singer and actress with outstanding musical talent.',
|
|
||||||
'bot_name': 'Alice',
|
|
||||||
'user_name': 'Director',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
print(response)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Assistant Conversation
|
|
||||||
|
|
||||||
```python
|
|
||||||
from zai import ZaiClient
|
|
||||||
|
|
||||||
# Initialize client
|
|
||||||
client = ZaiClient(api_key="your-api-key")
|
|
||||||
|
|
||||||
# Create assistant conversation
|
|
||||||
response = client.assistant.conversation(
|
|
||||||
# You can use 65940acff94777010aa6b796 for testing
|
|
||||||
# or you can create your own assistant_id in Z.ai console
|
|
||||||
assistant_id='your own assistant_id',
|
|
||||||
model='glm-4-assistant',
|
|
||||||
messages=[
|
|
||||||
{
|
|
||||||
'role': 'user',
|
|
||||||
'content': [
|
|
||||||
{
|
|
||||||
'type': 'text',
|
|
||||||
'text': 'Help me search for the latest Z.ai product information',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
stream=True,
|
|
||||||
attachments=None,
|
|
||||||
metadata=None,
|
|
||||||
request_id='request_1790291013237211136',
|
|
||||||
user_id='12345678',
|
|
||||||
)
|
|
||||||
|
|
||||||
for chunk in response:
|
|
||||||
if chunk.choices[0].delta.type == 'content':
|
|
||||||
print(chunk.choices[0].delta.content, end='')
|
|
||||||
```
|
|
||||||
|
|
||||||
### Video Generation
|
### Video Generation
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
@ -311,7 +252,7 @@ client = ZaiClient(api_key="your-api-key")
|
||||||
|
|
||||||
# Generate video
|
# Generate video
|
||||||
response = client.videos.generations(
|
response = client.videos.generations(
|
||||||
model="cogvideox-2",
|
model="cogvideox-3",
|
||||||
prompt="A cat is playing with a ball.",
|
prompt="A cat is playing with a ball.",
|
||||||
quality="quality", # Output mode, "quality" for quality priority, "speed" for speed priority
|
quality="quality", # Output mode, "quality" for quality priority, "speed" for speed priority
|
||||||
with_audio=True, # Whether to include audio
|
with_audio=True, # Whether to include audio
|
||||||
|
|
@ -338,7 +279,7 @@ client = ZaiClient(api_key="your-api-key")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4.6",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "Hello, Z.ai!"}
|
{"role": "user", "content": "Hello, Z.ai!"}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
68
README_CN.md
68
README_CN.md
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
[English Readme](README.md)
|
[English Readme](README.md)
|
||||||
|
|
||||||
[Z.ai 开放平台](https://docs.z.ai/)官方 Python SDK,帮助开发者快速集成 Z.ai 强大的人工智能能力到Python应用中。
|
[智谱开放平台](https://docs.bigmodel.cn/)官方 Python SDK,帮助开发者快速集成智谱强大的人工智能能力到Python应用中。
|
||||||
|
|
||||||
## ✨ 核心功能
|
## ✨ 核心功能
|
||||||
|
|
||||||
### 🤖 **对话补全**
|
### 🤖 **对话补全**
|
||||||
- **标准对话**: 支持 `glm-4`、`charglm-3` 等多种模型的对话补全
|
- **标准对话**: 支持 `glm-4.7` 等多种模型的对话补全
|
||||||
- **流式支持**: 实时流式响应,适用于交互式应用
|
- **流式支持**: 实时流式响应,适用于交互式应用
|
||||||
- **工具调用**: 函数调用能力,增强 AI 交互体验
|
- **工具调用**: 函数调用能力,增强 AI 交互体验
|
||||||
- **角色扮演**: 支持基于 `charglm-3` 模型的角色对话
|
- **角色扮演**: 支持基于 `charglm-3` 模型的角色对话
|
||||||
|
|
@ -107,7 +107,7 @@ client = ZhipuAiClient(api_key="your-api-key")
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4.6",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "Hello, Z.ai!"}
|
{"role": "user", "content": "Hello, Z.ai!"}
|
||||||
]
|
]
|
||||||
|
|
@ -250,64 +250,6 @@ response = client.chat.completions.create(
|
||||||
print(response)
|
print(response)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 角色扮演
|
|
||||||
|
|
||||||
```python
|
|
||||||
from zai import ZaiClient
|
|
||||||
|
|
||||||
# 初始化客户端
|
|
||||||
client = ZaiClient(api_key="your-api-key")
|
|
||||||
|
|
||||||
# 创建对话
|
|
||||||
response = client.chat.completions.create(
|
|
||||||
model='charglm-3',
|
|
||||||
messages=[{'role': 'user', 'content': 'Hello, how are you doing lately?'}],
|
|
||||||
meta={
|
|
||||||
'user_info': 'I am a film director who specializes in music-themed movies.',
|
|
||||||
'bot_info': 'You are a popular domestic female singer and actress with outstanding musical talent.',
|
|
||||||
'bot_name': 'Alice',
|
|
||||||
'user_name': 'Director',
|
|
||||||
},
|
|
||||||
)
|
|
||||||
print(response)
|
|
||||||
```
|
|
||||||
|
|
||||||
### 智能体对话
|
|
||||||
|
|
||||||
```python
|
|
||||||
from zai import ZaiClient
|
|
||||||
|
|
||||||
# Initialize client
|
|
||||||
client = ZaiClient(api_key="your-api-key")
|
|
||||||
|
|
||||||
# Create assistant conversation
|
|
||||||
response = client.assistant.conversation(
|
|
||||||
# 你可使用 65940acff94777010aa6b796 作为测试ID
|
|
||||||
assistant_id='你的assistant_id',
|
|
||||||
model='glm-4-assistant',
|
|
||||||
messages=[
|
|
||||||
{
|
|
||||||
'role': 'user',
|
|
||||||
'content': [
|
|
||||||
{
|
|
||||||
'type': 'text',
|
|
||||||
'text': 'Help me search for the latest Z.ai product information',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
],
|
|
||||||
stream=True,
|
|
||||||
attachments=None,
|
|
||||||
metadata=None,
|
|
||||||
request_id='request_1790291013237211136',
|
|
||||||
user_id='12345678',
|
|
||||||
)
|
|
||||||
|
|
||||||
for chunk in response:
|
|
||||||
if chunk.choices[0].delta.type == 'content':
|
|
||||||
print(chunk.choices[0].delta.content, end='')
|
|
||||||
```
|
|
||||||
|
|
||||||
### 视频生成
|
### 视频生成
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
@ -317,7 +259,7 @@ client = ZaiClient() # 请填写您自己的APIKey
|
||||||
|
|
||||||
# 提交生成任务
|
# 提交生成任务
|
||||||
response = client.videos.generations(
|
response = client.videos.generations(
|
||||||
model="cogvideox-2", # 使用的视频生成模型
|
model="cogvideox-3", # 使用的视频生成模型
|
||||||
image_url=image_url, # 提供的图片URL地址或者 Base64 编码
|
image_url=image_url, # 提供的图片URL地址或者 Base64 编码
|
||||||
prompt="让画面动起来",
|
prompt="让画面动起来",
|
||||||
quality="speed", # 输出模式,"quality"为质量优先,"speed"为速度优先
|
quality="speed", # 输出模式,"quality"为质量优先,"speed"为速度优先
|
||||||
|
|
@ -344,7 +286,7 @@ client = ZaiClient(api_key="your-api-key") # 请填写您自己的APIKey
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4.6",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "你好, Z.ai !"}
|
{"role": "user", "content": "你好, Z.ai !"}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ def completion():
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4.6',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
||||||
temperature=1.0,
|
temperature=1.0,
|
||||||
)
|
)
|
||||||
|
|
@ -19,7 +19,7 @@ def completion_with_stream():
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4.6',
|
model='glm-4.7',
|
||||||
messages=[
|
messages=[
|
||||||
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
||||||
{'role': 'user', 'content': 'Tell me a story about AI.'},
|
{'role': 'user', 'content': 'Tell me a story about AI.'},
|
||||||
|
|
@ -38,7 +38,7 @@ def completion_with_websearch():
|
||||||
|
|
||||||
# Create chat completion
|
# Create chat completion
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4.6',
|
model='glm-4.7',
|
||||||
messages=[
|
messages=[
|
||||||
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
||||||
{'role': 'user', 'content': 'What is artificial intelligence?'},
|
{'role': 'user', 'content': 'What is artificial intelligence?'},
|
||||||
|
|
@ -66,7 +66,7 @@ def completion_with_mcp_server_url():
|
||||||
|
|
||||||
# Create chat completion with MCP server URL
|
# Create chat completion with MCP server URL
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
stream=False,
|
stream=False,
|
||||||
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
|
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
|
||||||
tools=[
|
tools=[
|
||||||
|
|
@ -95,7 +95,7 @@ def completion_with_mcp_server_label():
|
||||||
|
|
||||||
# Create chat completion with MCP server label
|
# Create chat completion with MCP server label
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
stream=False,
|
stream=False,
|
||||||
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
|
messages=[{'role': 'user', 'content': 'Hello, please introduce GPT?'}],
|
||||||
tools=[
|
tools=[
|
||||||
|
|
@ -208,7 +208,7 @@ def audio_transcription():
|
||||||
|
|
||||||
# Create audio transcription
|
# Create audio transcription
|
||||||
response = client.audio.transcriptions.create(
|
response = client.audio.transcriptions.create(
|
||||||
model='glm-4',
|
model='glm-asr-2512',
|
||||||
file='audio.mp3',
|
file='audio.mp3',
|
||||||
)
|
)
|
||||||
print(response.text)
|
print(response.text)
|
||||||
|
|
@ -217,7 +217,7 @@ def ofZai():
|
||||||
client = ZaiClient()
|
client = ZaiClient()
|
||||||
print(client.base_url)
|
print(client.base_url)
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
||||||
temperature=0.7,
|
temperature=0.7,
|
||||||
)
|
)
|
||||||
|
|
@ -227,7 +227,7 @@ def ofZhipu():
|
||||||
client = ZhipuAiClient()
|
client = ZhipuAiClient()
|
||||||
print(client.base_url)
|
print(client.base_url)
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
messages=[{'role': 'user', 'content': 'Hello, Z.ai!'}],
|
||||||
temperature=0.7,
|
temperature=0.7,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ def parse_function_call(model_response, messages):
|
||||||
"tool_call_id": tool_call.id
|
"tool_call_id": tool_call.id
|
||||||
})
|
})
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4", # Specify the model name to use
|
model="glm-4.7", # Specify the model name to use
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
)
|
)
|
||||||
|
|
@ -99,7 +99,7 @@ messages.append({"role": "system", "content": "Do not assume or guess the values
|
||||||
messages.append({"role": "user", "content": "Help me check the flights from Beijing to Guangzhou on January 23."})
|
messages.append({"role": "user", "content": "Help me check the flights from Beijing to Guangzhou on January 23."})
|
||||||
|
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4", # Specify the model name to use
|
model="glm-4.7", # Specify the model name to use
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
)
|
)
|
||||||
|
|
@ -110,7 +110,7 @@ parse_function_call(response, messages)
|
||||||
|
|
||||||
messages.append({"role": "user", "content": "What is the price of flight 8321?"})
|
messages.append({"role": "user", "content": "What is the price of flight 8321?"})
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4", # Specify the model name to use
|
model="glm-4.7", # Specify the model name to use
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ def stream_web_search_example():
|
||||||
}]
|
}]
|
||||||
client = ZaiClient()
|
client = ZaiClient()
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4-air",
|
model="glm-4.7",
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
stream=True
|
stream=True
|
||||||
|
|
@ -35,7 +35,7 @@ def sync_example():
|
||||||
print("=== GLM-4 Synchronous Example ===")
|
print("=== GLM-4 Synchronous Example ===")
|
||||||
client = ZaiClient()
|
client = ZaiClient()
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4-plus",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": "You are a helpful assistant who provides professional, accurate, and insightful advice."},
|
{"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."},
|
{"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."},
|
||||||
|
|
@ -47,7 +47,7 @@ def async_example():
|
||||||
print("=== GLM-4 Async Example ===")
|
print("=== GLM-4 Async Example ===")
|
||||||
client = ZaiClient()
|
client = ZaiClient()
|
||||||
response = client.chat.asyncCompletions.create(
|
response = client.chat.asyncCompletions.create(
|
||||||
model="glm-4-plus",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
import time
|
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ class ZaiSampler(SamplerBase):
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
model: str = "glm-4.5",
|
model: str = "glm-4.7",
|
||||||
api_key: str = '',
|
api_key: str = '',
|
||||||
system_message: Optional[str] = None,
|
system_message: Optional[str] = None,
|
||||||
temperature: float = 0.0,
|
temperature: float = 0.0,
|
||||||
|
|
@ -4,7 +4,7 @@ def main():
|
||||||
client = ZhipuAiClient()
|
client = ZhipuAiClient()
|
||||||
# create chat completion with tool calls and streaming
|
# create chat completion with tool calls and streaming
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
model="glm-4.6",
|
model="glm-4.7",
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "user", "content": "How is the weather in Beijing and Shanghai? Please provide the answer in Celsius."},
|
{"role": "user", "content": "How is the weather in Beijing and Shanghai? Please provide the answer in Celsius."},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from zai import ZaiClient, ZhipuAiClient
|
from zai import ZaiClient, ZhipuAiClient
|
||||||
import time
|
import time
|
||||||
import os
|
|
||||||
|
|
||||||
def voice_clone():
|
def voice_clone():
|
||||||
# Initialize client
|
# Initialize client
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "zai-sdk"
|
name = "zai-sdk"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
description = "A SDK library for accessing big model apis from Z.ai"
|
description = "A SDK library for accessing big model apis from Z.ai"
|
||||||
authors = ["Z.ai"]
|
authors = ["Z.ai"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
__title__ = 'Z.ai'
|
__title__ = 'Z.ai'
|
||||||
__version__ = '0.1.0'
|
__version__ = '0.2.0'
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ def test_completions_temp0(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
||||||
top_p=0.7,
|
top_p=0.7,
|
||||||
temperature=0,
|
temperature=0,
|
||||||
|
|
@ -42,7 +42,7 @@ def test_completions_temp1(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
||||||
top_p=0.7,
|
top_p=0.7,
|
||||||
temperature=1,
|
temperature=1,
|
||||||
|
|
@ -68,7 +68,7 @@ def test_completions_top0(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
||||||
top_p=0,
|
top_p=0,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
|
|
@ -94,7 +94,7 @@ def test_completions_top1(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
||||||
top_p=1,
|
top_p=1,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
|
|
@ -120,7 +120,7 @@ def test_completions(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4', # Fill in the model name to call
|
model='glm-4.7', # Fill in the model name to call
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
|
@ -170,7 +170,7 @@ def test_completions_disenable_web_search(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4', # Fill in the model name to call
|
model='glm-4.7', # Fill in the model name to call
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
|
@ -221,7 +221,7 @@ def test_completions_enable_web_search(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4', # Fill in the model name to call
|
model='glm-4.7', # Fill in the model name to call
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
|
@ -272,7 +272,7 @@ def test_completions_sensitive_word_check(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4', # Fill in the model name to call
|
model='glm-4.7', # Fill in the model name to call
|
||||||
stream=True,
|
stream=True,
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
|
|
@ -467,7 +467,7 @@ def test_completions_vis(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
messages=[{'role': 'user', 'content': 'tell me a joke'}],
|
||||||
top_p=1,
|
top_p=1,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ def test_chat_completion_with_thinking(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4.5',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': '请介绍一下Agent的原理,并给出详细的推理过程'}],
|
messages=[{'role': 'user', 'content': '请介绍一下Agent的原理,并给出详细的推理过程'}],
|
||||||
top_p=0.7,
|
top_p=0.7,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
|
|
@ -39,7 +39,7 @@ def test_chat_completion_without_thinking(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4.5',
|
model='glm-4.7',
|
||||||
messages=[{'role': 'user', 'content': '请介绍一下Agent的原理'}],
|
messages=[{'role': 'user', 'content': '请介绍一下Agent的原理'}],
|
||||||
top_p=0.7,
|
top_p=0.7,
|
||||||
temperature=0.9,
|
temperature=0.9,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ def test_completions_vlm_thinking(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4.1v-thinking-flash', # Fill in the model name to call
|
model='glm-4.6v', # Fill in the model name to call
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
|
@ -53,7 +53,7 @@ def test_completions_vlm_thinking_stream(logging_conf):
|
||||||
print(f'request_id:{request_id}')
|
print(f'request_id:{request_id}')
|
||||||
response = client.chat.completions.create(
|
response = client.chat.completions.create(
|
||||||
request_id=request_id,
|
request_id=request_id,
|
||||||
model='glm-4.1v-thinking-flash', # Fill in the model name to call
|
model='glm-4.6v', # Fill in the model name to call
|
||||||
messages=[
|
messages=[
|
||||||
{
|
{
|
||||||
'role': 'user',
|
'role': 'user',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue