o
    =jiY                     @   sB   d dl mZ d dlZd dlmZ eejdZdedefddZ	dS )	    )OpenAIN)settings)api_keytext_contentreturnc              
   C   s   d| dd  d}z!t jjjddddd	|dgd
did}|jd jj}t|W S  t	yF } zt
d|  i W  Y d}~S d}~ww )zM
    Sends the resume text content to OpenAI to extract structured data.
    a  
    You are a resume parser. Extract the following information from the resume text provided below.
    Return the output in a strictly valid JSON format with the following keys:
    - name (string)
    - email (string)
    - phone (string)
    - skills (string, comma-separated)
    - experience_summary (string, brief summary of work experience)
    
    If a field is not found, set it to null.

    Resume Text:
    Ni  z4  # Truncate to avoid token limits if necessary
    zgpt-3.5-turbosystemz<You are a helpful assistant that extracts data from resumes.)rolecontentusertypejson_object)modelmessagesresponse_formatr   z"Error parsing resume with OpenAI: )clientchatcompletionscreatechoicesmessager	   jsonloads	Exceptionprint)r   promptresponser	   e r   F/var/www/html/Resume-Parser/resume-parser-inhouse/services/__init__.pyparse_resume_content   s$   
	r   )
openair   r   databaser   OPENAI_API_KEYr   strdictr   r   r   r   r   <module>   s
    