Skip to content

Commit 3342800

Browse files
authored
Merge pull request #108 from CatchTheTornado/feature/107-model-not-required
2 parents 3cce141 + 1477f15 commit 3342800

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

text_extract_api/extract/tasks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def ocr_task(
2323
filename: str,
2424
file_hash: str,
2525
ocr_cache: bool,
26-
prompt: str,
27-
model: str,
28-
language: str,
29-
storage_profile: str,
26+
prompt: Optional[str] = None,
27+
model: Optional[str] = None,
28+
language: Optional[str] = None,
29+
storage_profile: Optional[str] = None,
3030
storage_filename: Optional[str] = None,
3131
):
3232
"""
@@ -85,7 +85,7 @@ def ocr_task(
8585

8686
if storage_profile:
8787
if not storage_filename:
88-
storage_filename = filename.replace('.pdf', '.md')
88+
storage_filename = filename.replace('.', '_') + '.pdf'
8989

9090
storage_manager = StorageManager(storage_profile)
9191
storage_manager.save(filename, storage_filename, extracted_text)

text_extract_api/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def ocr_endpoint(
7878
async def ocr_upload_endpoint(
7979
strategy: str = Form(...),
8080
prompt: str = Form(None),
81-
model: str = Form(...),
81+
model: str = Form(None),
8282
file: UploadFile = File(...),
8383
ocr_cache: bool = Form(...),
8484
storage_profile: str = Form('default'),
@@ -104,7 +104,7 @@ class OllamaPullRequest(BaseModel):
104104
class OcrRequest(BaseModel):
105105
strategy: str = Field(..., description="OCR strategy to use")
106106
prompt: Optional[str] = Field(None, description="Prompt for the Ollama model")
107-
model: str = Field(..., description="Model to use for the Ollama endpoint")
107+
model: Optional[str] = Field(None, description="Model to use for the Ollama endpoint")
108108
file: FileField = Field(..., description="Base64 encoded document file")
109109
ocr_cache: bool = Field(..., description="Enable OCR result caching")
110110
storage_profile: Optional[str] = Field('default', description="Storage profile to use")
@@ -126,7 +126,7 @@ def validate_storage_profile(cls, v):
126126
class OcrFormRequest(BaseModel):
127127
strategy: str = Field(..., description="OCR strategy to use")
128128
prompt: Optional[str] = Field(None, description="Prompt for the Ollama model")
129-
model: str = Field(..., description="Model to use for the Ollama endpoint")
129+
model: Optional[str] = Field(None, description="Model to use for the Ollama endpoint")
130130
ocr_cache: bool = Field(..., description="Enable OCR result caching")
131131
storage_profile: Optional[str] = Field('default', description="Storage profile to use")
132132
storage_filename: Optional[str] = Field(None, description="Storage filename to use")

0 commit comments

Comments
 (0)