Files
FastDeploy/tests/ci_use/XPU_45T/run_45vl.py
T
Jiaxin Sui 5ff93d4998 [XPU][CI] change VL model to 28B-VL-thinking (#5169)
* Enhance run_ci_xpu.sh with caching and prefill options

* Update model path and configuration in run_ci_xpu.sh

* Add '北朝' keyword to assertion in run_45vl.py

* Enhance process termination logic in run_ci_xpu.sh

* Set timeout for CI_XPU job to 60 minutes

* Remove extra newline in stop_processes function
2025-11-24 16:50:18 +08:00

53 lines
1.8 KiB
Python

# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import openai
def test_45vl():
ip = "0.0.0.0"
xpu_id = int(os.getenv("XPU_ID", "0"))
service_http_port = 8188 + xpu_id * 100 # 服务配置的
client = openai.Client(base_url=f"http://{ip}:{service_http_port}/v1", api_key="EMPTY_API_KEY")
# 非流式对话
response = client.chat.completions.create(
model="default",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example2.jpg"
},
},
{"type": "text", "text": "图片中的文物来自哪个时代?"},
],
},
],
temperature=1,
top_p=0,
max_tokens=70,
stream=False,
)
print(response.choices[0].message.content)
# print(base_response)
assert any(keyword in response.choices[0].message.content for keyword in ["北魏", "北齐", "释迦牟尼", "北朝"])
if __name__ == "__main__":
test_45vl()