o
    Xg                     @   sd  d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlZd dlmZ d dl
mZ d dlmZmZ d d	lmZ d d
lmZmZmZmZ d dlmZ d dlmZ d dl m!Z!m"Z" d dl#m$Z$m%Z%m&Z& d dl'm(Z( d dl)Z)dZ*dZ+dddZ,e-dkrdZ*dZ.dZ/dZ0e,e/e0e*d\Z1Z2e3e2 e3e1 e3e4e1 dS dS )    N)OllamaEmbeddings)FAISS)ChatPromptTemplate)AsyncWebCrawler)ChatGroq)PromptTemplate)StrOutputParserPydanticOutputParser)RunnablePassthrough)PyPDFLoader
TextLoaderDocx2txtLoaderUnstructuredPowerPointLoader)	PdfReader)SemanticChunker)	BaseModelField)ListOptionalDict)urlparse8gsk_igZbGeSv0MAqutmjrX9HWGdyb3FYc1U6fPEfvHFdLNFytjmyPGUHznomic-embed-textmixtral-8x7b-32768c              
   C   s   t |||d}tddgdd}|j| |d}z||}|jd d }	|j}
W |
|	fS  tyD } ztd	|  W Y d }~d
S d }~ww )N)temperaturegroq_api_key
model_name	skills_dbdesignationsa  
You are an expert in skill-to-designation mapping. Your task is to analyze a given set of skills and map them to the most appropriate designations.

### Input Skills:
{skills_db}

### Designations:
{designations}

### Output Format:
{{
  "Designation 1": ["Skill 1", "Skill 2", "Skill 3"],
  "Designation 2": ["Skill 4", "Skill 5"],
  "Designation 3": ["Skill 6", "Skill 7", "Skill 8"]
}}

### Notes:
- Ensure that each skill is mapped only to the most relevant designation(s).
- If a skill fits multiple designations, include it in both.
- Use clear and concise mappings.
- Respond only with the JSON object in the specified format, without any additional text.
- If you found no skills for some designations check does designation at last one more time

### Instructions:
- **Respond only with the JSON object in the specified format.**
- **Do not include any additional text, explanations, or code fences (e.g., ```json).**
- **Ensure that the JSON is properly formatted and valid.**
)input_variablestemplate)r   r   token_usagetotal_tokensz*An error occurred during chat invocation: )Nr   )r   r   formatinvokeresponse_metadatacontent	Exceptionprint)r   r   r   r   r   chatsystem_promptformatted_promptoutputtoken_consumedskill_to_designation_mappinge r/   </var/www/eduai.edurigo.com/skill_map/prod/designation_map.pymap_skills_to_designations   s    !
r1   __main__Infrastructurea}  
      Budgeting,
      Cost Estimation,
    
      Civil Engineering,
      Structural Analysis,
   
      AutoCAD,
      Revit,
    
      Communication,
      Leadership,
      Teamwork,
      Urban Design,
      Water Supply and Distribution
      , SQL, C++ , Management, Housekeeping Management,Front Desk Management,Complaint Handling,Recruitment,Training & Development
    zY
        HR, Developer, Manager, Planner,CEO, Infrastructure Deverloper
        
        )r   r   r   )r   r   )5ostimerandomrejsonrequestslangchain_community.embeddingsr    langchain_community.vectorstoresr   langchain_core.promptsr   crawl4air   asynciolangchain_groqr   r   langchain_core.output_parsersr   r	   langchain_core.runnablesr
   $langchain_community.document_loadersr   r   r   r   PyPDF2r   $langchain_experimental.text_splitterr   pydanticr   r   typingr   r   r   urllib.parser   shutilGROQ_API_KEYOLLAMA_MODELr1   __name__industryskillsetDesignation
skill_treer,   r'   typer/   r/   r/   r0   <module>   sF    
6