1111## ✨ Core Features
1212
1313### 🤖 ** Chat Completions**
14- - ** Standard Chat** : Create chat completions with various models including ` glm-4 ` , ` charglm-3 `
14+ - ** Standard Chat** : Create chat completions with various models including ` glm-4.7 `
1515- ** Streaming Support** : Real-time streaming responses for interactive applications
1616- ** Tool Calling** : Function calling capabilities for enhanced AI interactions
1717- ** Character Role-Playing** : Support for character-based conversations with ` charglm-3 ` model
@@ -105,7 +105,7 @@ client = ZhipuAiClient(api_key="your-api-key")
105105
106106# Create chat completion
107107response = client.chat.completions.create(
108- model = " glm-4" ,
108+ model = " glm-4.7 " ,
109109 messages = [
110110 {" role" : " user" , " content" : " Hello, Z.ai!" }
111111 ]
@@ -169,7 +169,7 @@ client = ZaiClient(api_key="your-api-key")
169169
170170# Create chat completion
171171response = client.chat.completions.create(
172- model = ' glm-4.6 ' ,
172+ model = ' glm-4.7 ' ,
173173 messages = [
174174 {' role' : ' system' , ' content' : ' You are a helpful assistant.' },
175175 {' role' : ' user' , ' content' : ' Tell me a story about AI.' },
@@ -192,7 +192,7 @@ client = ZaiClient(api_key="your-api-key")
192192
193193# Create chat completion
194194response = client.chat.completions.create(
195- model = ' glm-4.6 ' ,
195+ model = ' glm-4.7 ' ,
196196 messages = [
197197 {' role' : ' system' , ' content' : ' You are a helpful assistant.' },
198198 {' role' : ' user' , ' content' : ' What is artificial intelligence?' },
@@ -244,65 +244,6 @@ response = client.chat.completions.create(
244244print (response)
245245```
246246
247- ### Character Role-Playing
248-
249- ``` python
250- from zai import ZaiClient
251-
252- # Initialize client
253- client = ZaiClient(api_key = " your-api-key" )
254-
255- # Create chat completion
256- response = client.chat.completions.create(
257- model = ' charglm-3' ,
258- messages = [{' role' : ' user' , ' content' : ' Hello, how are you doing lately?' }],
259- meta = {
260- ' user_info' : ' I am a film director who specializes in music-themed movies.' ,
261- ' bot_info' : ' You are a popular domestic female singer and actress with outstanding musical talent.' ,
262- ' bot_name' : ' Alice' ,
263- ' user_name' : ' Director' ,
264- },
265- )
266- print (response)
267- ```
268-
269- ### Assistant Conversation
270-
271- ``` python
272- from zai import ZaiClient
273-
274- # Initialize client
275- client = ZaiClient(api_key = " your-api-key" )
276-
277- # Create assistant conversation
278- response = client.assistant.conversation(
279- # You can use 65940acff94777010aa6b796 for testing
280- # or you can create your own assistant_id in Z.ai console
281- assistant_id = ' your own assistant_id' ,
282- model = ' glm-4-assistant' ,
283- messages = [
284- {
285- ' role' : ' user' ,
286- ' content' : [
287- {
288- ' type' : ' text' ,
289- ' text' : ' Help me search for the latest Z.ai product information' ,
290- }
291- ],
292- }
293- ],
294- stream = True ,
295- attachments = None ,
296- metadata = None ,
297- request_id = ' request_1790291013237211136' ,
298- user_id = ' 12345678' ,
299- )
300-
301- for chunk in response:
302- if chunk.choices[0 ].delta.type == ' content' :
303- print (chunk.choices[0 ].delta.content, end = ' ' )
304- ```
305-
306247### Video Generation
307248
308249``` python
@@ -311,7 +252,7 @@ client = ZaiClient(api_key="your-api-key")
311252
312253# Generate video
313254response = client.videos.generations(
314- model = " cogvideox-2 " ,
255+ model = " cogvideox-3 " ,
315256 prompt = " A cat is playing with a ball." ,
316257 quality = " quality" , # Output mode, "quality" for quality priority, "speed" for speed priority
317258 with_audio = True , # Whether to include audio
@@ -338,7 +279,7 @@ client = ZaiClient(api_key="your-api-key")
338279
339280try :
340281 response = client.chat.completions.create(
341- model = " glm-4.6 " ,
282+ model = " glm-4.7 " ,
342283 messages = [
343284 {" role" : " user" , " content" : " Hello, Z.ai!" }
344285 ]
0 commit comments