from groq_module import chat_with_groq
from agents import speaker_diarization_agent, technical_skill_agent, soft_skill_agent, question_wise_agent, recommendation_agent, summary_agent
from helpers import trim_prompt
import tiktoken


def candidate_evaluation(trans):
    soft_skills = ["communication", "problemsolving", "teamwork", "adaptability", "attitude", "professionalism", "alignmentwithcompanyvalues"]
    print("\n🔹 Token Count:", len(tiktoken.get_encoding("cl100k_base").encode(trans)))

    trans = trim_prompt(trans)
    print("\n🔹 Token Count:", len(tiktoken.get_encoding("cl100k_base").encode(trans)))

    diaraize_prompt = speaker_diarization_agent(trans)
    tech_skill_prompt = technical_skill_agent()
    soft_skill_prompt = soft_skill_agent(soft_skills)
    ques_wise_prompt = question_wise_agent()
    recommendation_prompt = recommendation_agent()
    summary_prompt = summary_agent()

    # structure_trans = chat_with_groq(diaraize_prompt)
    # print("Structure transcription done: ",structure_trans)





    user_input = f'''
    structure_trans = {diaraize_prompt}
    based on the above structure transcription give reponse int the following json format

    make sure if you don't got any valid answer or any tech stack or soft skill then give the response as "No valid answer found" in the json format
    if no questions ask in the interview then give the response as "No questions asked in the interview" in the json format
    if no recommendation found then give the response as "No recommendation found" in the json format
    if no summary found then give the response as "No summary found" in the json format
    {{
    
        'jobRole': identify the job role for which candidate applied out of [web,python,java,app,AI] ,
        'knownSkills': technical skills that candidate knows give the value in the list seperated by comma eg:- [flask, django],
        'technicalSkills': {tech_skill_prompt} ,
        'softSkills': {soft_skill_prompt},
        'questionWise': {ques_wise_prompt},
        'recommendation': {recommendation_prompt},
        'summary': {summary_prompt}
    }}
    '''

    
    response = chat_with_groq(user_input)
    return response