Skip to content

Commit 13a7121

Browse files
committed
+ storage filename fix
1 parent 1fb5bf6 commit 13a7121

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ curl -X POST "http://localhost:8000/ocr/request" -H "Content-Type: application/j
447447
"prompt": "",
448448
"model": "llama3.1",
449449
"storage_profile": "default",
450-
"storage_filename": "example.pdf"
450+
"storage_filename": "example.md"
451451
}'
452452
```
453453

text_extract_api/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ async def ocr_endpoint(
5858
except ValueError as e:
5959
raise HTTPException(status_code=400, detail=str(e))
6060

61+
filename = storage_filename if storage_filename else file.filename
6162
file_binary = await file.read()
62-
file_format = FileFormat.from_binary(file_binary)
63+
file_format = FileFormat.from_binary(file_binary, filename, file.content_type)
6364

6465
print(
65-
f"Processing Document {file_format.filename} with strategy: {strategy}, ocr_cache: {ocr_cache}, model: {model}, storage_profile: {storage_profile}, storage_filename: {storage_filename}, language: {language}")
66+
f"Processing Document {file_format.filename} with strategy: {strategy}, ocr_cache: {ocr_cache}, model: {model}, storage_profile: {storage_profile}, storage_filename: {storage_filename}, language: {language}, will be saved as: {filename}")
6667

6768
# Asynchronous processing using Celery
6869
task = ocr_task.apply_async(
@@ -153,7 +154,7 @@ async def ocr_request_endpoint(request: OcrRequest):
153154
request_data = request.model_dump()
154155
try:
155156
OcrRequest(**request_data)
156-
file = FileFormat.from_base64(request.file)
157+
file = FileFormat.from_base64(request.file, request.storage_filename)
157158
except ValueError as e:
158159
raise HTTPException(status_code=400, detail=str(e))
159160

0 commit comments

Comments
 (0)