Skip to content

[fix] ResumeParserDataclass address can be null #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions edenai_apis/apis/openai/openai_doc_parsing_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import os
import fitz
import fitz
from time import sleep

from edenai_apis.features.ocr import (
Expand All @@ -13,17 +13,19 @@
from edenai_apis.features import OcrInterface
from edenai_apis.utils.exception import ProviderException


def extract_text_from_pdf(pdf_path):
try :
try:
doc = fitz.open(pdf_path)
except :
except:
raise FileNotFoundError
text = ""
for page_num in range(len(doc)):
page = doc.load_page(page_num)
text += page.get_text()
return text


class OpenaiDocParsingApi(OcrInterface):

def __assistant_parser(
Expand All @@ -42,14 +44,13 @@ def __assistant_parser(
model="gpt-4o",
)


input_file_text = extract_text_from_pdf(input_file)

thread = self.client.beta.threads.create(
messages=[
{
"role": "user",
"content": message_text+input_file_text,
"content": message_text + input_file_text,
}
]
)
Expand All @@ -69,7 +70,7 @@ def __assistant_parser(

try:
standardized_response = json.loads(
json.loads(messages.data[0].content[0].json())["text"]["value"]
json.loads(messages.data[0].content[0].json())["text"]["value"]
)
except json.JSONDecodeError as exc:
raise ProviderException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ResumePersonalName(BaseModel):

class ResumePersonalInfo(BaseModel):
name: ResumePersonalName
address: ResumeLocation
address: Optional[ResumeLocation]
self_summary: Optional[StrictStr] # all
objective: Optional[StrictStr] # Hireability
date_of_birth: Optional[StrictStr] # Affinda
Expand Down
Loading