o
    gg4                     @   s  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,d#ddZ-d#ddZ.e/dkrdZ*dZ0dZ1dZ2dZ3g dZ4g dZ5d Z6d!Z7e.e1e6e7e3e*d"\Z8Z9e:e8 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g ddd}|j| ||d}z||}	|	jd d }
|	j}W ||
fS  tyE } ztd|  W Y d }~d	S d }~ww )
Ntemperaturegroq_api_key
model_name)	skills_dbGoals
Challengesa  
        You are an AI assistant specializing in Training Need Analysis (TNA). 
        Given a company's business goals, challenges, and existing skills database, 
        suggest skill areas for development. 

        **Existing Skills Database:**
        {skills_db}

        **Business Goals:**
        {Goals}

        **Challenges:**
        {Challenges}

        **Objective:**
        - Identify skill gaps.
        - Recommend relevant skill enhancements.
        - Provide justifications for each recommendation.
        - You can also give skills 
        - You may also suggest skills outside the existing database if they align with the business goals and challenges. But make sure you write there that these are exclusive from your skills
        - SUggest minimum 10 skills
        Return your response in a structured format:
        - **Recommended Skills**
        - **JSON Output**
        - **Why These Skills Are Important**
        input_variablestemplate)r   r   r   token_usagetotal_tokens*An error occurred during chat invocation: Nr   r   r   formatinvokeresponse_metadatacontent	Exceptionprint)r   r   r   r   r   r   chatsystem_promptpromptoutputtoken_consumed
skill_treee r5   ;/var/www/eduai.edurigo.com/doc_train/edurigo_ai/Puru/tna.pytna   s     

r7   c              
   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 )Nr   r   r   a  
        You are an AI assistant specializing in Training Need Analysis (TNA). 
        Given a company's business goals, challenges suggest skill areas for development. 

       
        **Business Goals:**
        {Goals}

        **Challenges:**
        {Challenges}

        **Objective:**
        - Identify skill gaps.
        - Recommend relevant skill enhancements.
        - Provide justifications for each recommendation.
        - You can also give skills 
        - SUggest minimum 10 skills
        - ALso provide courses to improve skills 
        - minimum 2 couses with each skills
        Return your response in a structured format:
        - **Recommended Skills**
        - **JSON Output**
        - **Why These Skills Are Important**
        r    )r   r   r#   r$   r%   r&   r'   )r   r   r   r   r   r.   r/   r0   r1   r2   r3   r4   r5   r5   r6   tna2W   s    

r8   c              
   C   s   t |||d}tg ddd}|j| |||d}	z||	}
|
jdi dd}|
j}W ||fS  tyJ } ztd	|  W Y d }~d
S d }~ww )Nr   )r   r   r   courseax  
        You are an AI assistant specializing in Training Need Analysis (TNA). 
        Given a company's business goals, challenges, existing skills database, and available courses, 
        suggest skill areas for development and recommend relevant courses.

        **Existing Skills Database:**
        {skills_db}

        **Business Goals:**
        {Goals}

        **Challenges:**
        {Challenges}

        **Available Courses:**
        {course}

        **Objective:**
        - Identify skill gaps.
        - Recommend relevant skill enhancements.
        - Provide justifications for each recommendation.
        - Suggest at least **10 skills** based on business needs and challenges.
        - Cross-check the **available courses** to suggest the best courses for each recommended skill.
        - If needed, suggest additional skills **outside the existing database** and label them as **(Exclusive Suggestions).**

        **Return your response in a structured format:**
        ```json
        {{
            "Recommended Skills": [...],
            "Skill-Course Mapping": {{
                "Skill1": ["Course1", "Course2"],
                "Skill2": ["Course3", "Course4"]
            }},
            "Why These Skills Are Important": {{
                "Skill1": "Justification...",
                "Skill2": "Justification..."
            }}
        }}
        ```
        r    )r   r   r   r9   r#   r$   r   zError during chat invocation: r&   )	r   r   r(   r)   r*   getr+   r,   r-   )r   r   r   r9   r   r   r   r.   r/   r0   r1   r2   r3   r4   r5   r5   r6   tna3   s    -
r;   __main__Infrastructurea  
      "Budgeting",
      "Cost Estimation",
    
      "Civil Engineering",
      "Structural Analysis",
   
      "AutoCAD",
      "Revit",
    
      "Communication",
      "Leadership",
      "Teamwork",
      "Urban Design",
      "Water Supply and Distribution"
    ab  
    "Python",
    "JavaScript",
    "SQL",
    "C++",
    "React.js",
    "Node.js",
    "Django",
    "Flask",
    "TensorFlow",
    "PyTorch",
    "Docker",
    "Kubernetes",
    "AWS",
    "Google Cloud Platform (GCP)",
    "RESTful APIs",
    "GraphQL",
    "Git",
    "CI/CD Pipelines",
    "Cybersecurity Principles",
    "Data Visualization"
    aC
  
    [
    "Python for Everybody - University of Michigan (Coursera)",
    "JavaScript: Understanding the Weird Parts (Udemy)",
    "The Complete SQL Bootcamp 2024 (Udemy)",
    "Docker for Beginners (Udemy)",
    "Deep Learning Specialization - Andrew Ng (Coursera)",
    "React - The Complete Guide (Udemy)",
    "AWS Certified Solutions Architect - Associate (Udemy)",
    "Introduction to Cyber Security (Udemy)",
    "Git & GitHub for Beginners (Udemy)",
    "Data Visualization with Python (Coursera)",
    "Complete Python Developer in 2024 - Zero to Mastery (Udemy)",
    "The Modern JavaScript Bootcamp (Udemy)",
    "SQL for Data Science - University of California, Davis (Coursera)",
    "Docker Mastery: With Kubernetes & Swarm (Udemy)",
    "TensorFlow for Beginners (Udemy)",
    "Full-Stack Web Development with React (Coursera)",
    "AWS Fundamentals (Coursera)",
    "Cybersecurity Specialization - University of Maryland (Coursera)",
    "Version Control with Git (Coursera)",
    "Data Visualization with Tableau (Udemy)",
    "Python Data Structures - University of Michigan (Coursera)",
    "JavaScript Basics for Beginners (Coursera)",
    "Advanced SQL for Data Scientists (LinkedIn Learning)",
    "Docker Deep Dive (Pluralsight)",
    "Introduction to TensorFlow for AI, ML, and DL (Coursera)",
    "React for Beginners (Scrimba)",
    "AWS Cloud Practitioner Essentials (AWS Training)",
    "The Complete Cyber Security Course (Udemy)",
    "Mastering Git and GitHub (Udemy)",
    "Storytelling with Data (LinkedIn Learning)",
    "Python Programming Masterclass (Udemy)",
    "Eloquent JavaScript (Self-paced Book & Online Exercises)",
    "Databases and SQL for Data Science with Python (Coursera)",
    "Kubernetes and Docker: The Complete Guide (Udemy)",
    "TensorFlow Developer Certificate Training (Udemy)",
    "Modern React with Redux (Udemy)",
    "Architecting with AWS (Pluralsight)",
    "Cybersecurity Essentials (Cisco Networking Academy)",
    "The Git & GitHub Bootcamp (Udemy)",
    "Data Visualization with D3.js (Udacity)",
    "Automate the Boring Stuff with Python (Udemy)",
    "JavaScript Algorithms and Data Structures (freeCodeCamp)",
    "Introduction to SQL (Codecademy)",
    "Docker Essentials: A Developer Introduction (IBM Skills Network)",
    "TensorFlow in Practice (Coursera)",
    "Frontend Development with React (Pluralsight)",
    "AWS Certified DevOps Engineer (A Cloud Guru)",
    "CompTIA Security+ Certification Training (Udemy)",
    "Learn Git & GitHub (Codecademy)",
    "Advanced Data Visualization with Python and Matplotlib (Pluralsight)"
    ]
    )*AdaptabilityzAgile MethodologieszBusiness AcumencCCCCCzCloud ArchitecturezCloud ComputingzCloud MigrationzCloud MonitoringCommunicationzComputer Basic
CreativityzCritical ThinkingCybersecurityzData AnalysiszData EncryptionzData SciencezData VisualizationzDecision MakingEmpathyzIncident ResponsezIndustry Trends
LeadershipzMachine LearningNegotiationzNetwork SecurityParentzProblem SolvingzProgramming LanguageszProject ManagementPyzRisk ManagementzSector ExpertisezSoft SkillszSoftware DevelopmentzSoftware TestingzStakeholder CommunicationTeamworkzTechnology Industry KnowledgeTesterzTime Management	undefinedzVersion Control)z8Python for Everybody - University of Michigan (Coursera)z1JavaScript: Understanding the Weird Parts (Udemy)z&The Complete SQL Bootcamp 2024 (Udemy)zDocker for Beginners (Udemy)z3Deep Learning Specialization - Andrew Ng (Coursera)z"React - The Complete Guide (Udemy)z5AWS Certified Solutions Architect - Associate (Udemy)z"Git & GitHub for Beginners (Udemy)z;Complete Python Developer in 2024 - Zero to Mastery (Udemy)zASQL for Data Science - University of California, Davis (Coursera)z/Docker Mastery: With Kubernetes & Swarm (Udemy)z TensorFlow for Beginners (Udemy)z@Cybersecurity Specialization - University of Maryland (Coursera)z1Kubernetes and Docker: The Complete Guide (Udemy)z-Automate the Boring Stuff with Python (Udemy)zWant to imporve my tech teamz-My tech team is not able to work efficiently )r   r   r   r9   r   )r   r   );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_MODELr7   r8   r;   __name__industryskillsetskillscoursescompetency_namesassigned_courser   	Challenger3   r2   r-   r5   r5   r5   r6   <module>   sR    

;
7C7 