feat: update model name
This commit is contained in:
62
test_vllm_connection.py
Normal file
62
test_vllm_connection.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""Quick test to verify PaddleOCR-VL connection."""
|
||||
|
||||
from openai import OpenAI
|
||||
import base64
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
# Create test image
|
||||
test_image = np.ones((100, 300, 3), dtype=np.uint8) * 255
|
||||
cv2.putText(test_image, "x^2 = 4", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 0), 2)
|
||||
|
||||
# Encode to base64
|
||||
success, encoded_image = cv2.imencode(".png", test_image)
|
||||
if not success:
|
||||
print("Failed to encode image")
|
||||
exit(1)
|
||||
|
||||
image_base64 = base64.b64encode(encoded_image.tobytes()).decode("utf-8")
|
||||
image_url = f"data:image/png;base64,{image_base64}"
|
||||
|
||||
# Test connection
|
||||
client = OpenAI(
|
||||
api_key="EMPTY",
|
||||
base_url="http://100.115.184.74:8001/v1",
|
||||
timeout=3600
|
||||
)
|
||||
|
||||
print("Testing PaddleOCR-VL connection...")
|
||||
print(f"Server: http://100.115.184.74:8001/v1")
|
||||
print(f"Model: PaddleOCR-VL-0.9B")
|
||||
print("-" * 60)
|
||||
|
||||
try:
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {"url": image_url}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Formula Recognition:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model="PaddleOCR-VL-0.9B",
|
||||
messages=messages,
|
||||
temperature=0.0,
|
||||
)
|
||||
|
||||
print("✅ SUCCESS!")
|
||||
print(f"Response: {response.choices[0].message.content}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ FAILED: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user