-
Notifications
You must be signed in to change notification settings - Fork 270
/
glm4v.py
31 lines (29 loc) · 824 Bytes
/
glm4v.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from openai import OpenAI
client = OpenAI(
api_key="EMPTY",
base_url="http://192.168.0.59:7891/v1",
)
stream = client.chat.completions.create(
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片是什么地方?"
},
{
"type": "image_url",
"image_url": {
# Either an url or base64
"url": "http://djclub.cdn.bcebos.com/uploads/images/pageimg/20230325/64-2303252115313.jpg"
}
}
]
}
],
model="glm-4v-9b",
stream=True,
)
for part in stream:
print(part.choices[0].delta.content or "", end="", flush=True)