Skip to content

Commit f8dd253

Browse files
authored
Fix OCR example (#190)
* Add extension * cleaning
1 parent 6f80af2 commit f8dd253

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

examples/ocr_process_from_url.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
from mistralai import Mistral
2-
import os
31
import json
2+
import os
3+
4+
from mistralai import Mistral
5+
6+
MISTRAL_7B_PDF_URL = "https://arxiv.org/pdf/2310.06825.pdf"
47

5-
MISTRAL_7B_PDF_URL = "https://arxiv.org/pdf/2310.06825"
68

79
def main():
810
api_key = os.environ["MISTRAL_API_KEY"]
911
client = Mistral(api_key=api_key)
1012

1113
# Using an URL
12-
pdf_response = client.ocr.process(document={
13-
"document_url": MISTRAL_7B_PDF_URL,
14-
"type": "document_url",
15-
"document_name": "mistral-7b-pdf",
16-
}, model="mistral-ocr-latest", include_image_base64=True)
14+
pdf_response = client.ocr.process(
15+
document={
16+
"document_url": MISTRAL_7B_PDF_URL,
17+
"type": "document_url",
18+
"document_name": "mistral-7b-pdf",
19+
},
20+
model="mistral-ocr-latest",
21+
include_image_base64=True,
22+
)
1723

1824
# Print the parsed PDF
1925
response_dict = json.loads(pdf_response.model_dump_json())

0 commit comments

Comments
 (0)