in model-gallery/deploy/mllm/openai_client.py [0:0]
def infer_video():
video_url = "https://pai-quickstart-predeploy-hangzhou.oss-cn-hangzhou.aliyuncs.com/modelscope/algorithms/ms-swift/video_demo.mp4"
stream = True
video_base64 = encode_base64_content_from_url(video_url)
chat_completion_from_base64 = client.chat.completions.create(
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "请描述下视频内容"},
{
"type": "video_url",
"video_url": {"url": f"data:video/mp4;base64,{video_base64}"},
},
],
}
],
model=model,
max_completion_tokens=512,
stream=stream,
)
if stream:
for chunk in chat_completion_from_base64:
print(chunk.choices[0].delta.content, end="")
else:
result = chat_completion_from_base64.choices[0].message.content
print(result)