Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -114,12 +114,15 @@ def perform_ocr_file(file_obj: Any) -> Tuple[str, str, Dict[str, str]]:
|
|
114 |
if file_ext == '.pdf':
|
115 |
try:
|
116 |
with open(file_path, "rb") as f:
|
117 |
-
file_content = f.read()
|
118 |
|
119 |
logger.info(f"Uploading PDF {file_name} to Mistral...")
|
|
|
120 |
uploaded_pdf = client.files.upload(
|
121 |
-
file=
|
122 |
-
|
|
|
|
|
123 |
purpose="ocr"
|
124 |
)
|
125 |
uploaded_file_id = uploaded_pdf.id
|
|
|
114 |
if file_ext == '.pdf':
|
115 |
try:
|
116 |
with open(file_path, "rb") as f:
|
117 |
+
file_content = f.read() # Read the entire file content
|
118 |
|
119 |
logger.info(f"Uploading PDF {file_name} to Mistral...")
|
120 |
+
# Use dictionary format as per documentation
|
121 |
uploaded_pdf = client.files.upload(
|
122 |
+
file={
|
123 |
+
"file_name": file_name,
|
124 |
+
"content": file_content,
|
125 |
+
},
|
126 |
purpose="ocr"
|
127 |
)
|
128 |
uploaded_file_id = uploaded_pdf.id
|