# HOST YOUR OPENAI COMPATIBLE API WITH THE FOLLOWING COMMAND in VLLM:# export VLLM_USE_V1=1# vllm serve reducto/RolmOCR from openai import OpenAIimport base64 client = OpenAI(api_key="123", base_url="http://localhost:8000/v1") model = "reducto/RolmOCR-7b" def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode("utf-8") def ocr_page_with_rolm(img_base64): response = client.chat.completions.create( model=model, messages=[ { "role": "user", "content": [ { "type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_base64}"}, }, { "type": "text", "text": "Return the plain text representation of this document as if you were reading it naturally.\n", }, ], } ], temperature=0.2, max_tokens=4096 ) return response.choices[0].message.content test_img_path = "path/to/image.png"img_base64 = encode_image(test_img_path)print(ocr_page_with_rolm(img_base64))