Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions scripts/dev/granite_vlm_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,14 @@ def do_POST(self): # noqa: N802 (http.server API)
int(req.get("max_tokens", 8192)),
)
print(f"page converted in {time.time() - started:.1f}s, {len(text)} chars", flush=True)
# id/created/usage: Python docling validates the response against a
# full OpenAI schema (pydantic OpenAiApiResponse) and rejects a
# payload without them; docling.rs only reads choices[0].
payload = json.dumps(
{
"id": f"chatcmpl-{int(time.time() * 1000)}",
"object": "chat.completion",
"created": int(time.time()),
"model": req.get("model", "granite-docling"),
"choices": [
{
Expand All @@ -116,6 +121,11 @@ def do_POST(self): # noqa: N802 (http.server API)
"finish_reason": "stop",
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
},
}
).encode()
self.send_response(200)
Expand Down
Loading