import gradio as gr import requests import os import re from dotenv import load_dotenv load_dotenv() def get_feedback( education: str, experiences: str, projects: str, skills: str, description: str ): headers = { 'accept': 'application/json', 'Content-Type': 'application/json' } resume = { "education": education, "experience": experiences, "project": projects, "skill": skills, "description": description } model_config = { "max_new_tokens": 512, "top_p": 0.9, "temperature": 0.4, "do_sample": True } payload = { "resume": resume, "generation": model_config } results = requests.post( os.getenv("ENDPOINT_URI"), headers=headers, json=payload ).json() outputs = results["review"] # return outputs strengths, weaknesses, improvements = re.split("strengths\n|weaknesses\n|improvements\n", outputs)[1:] return strengths.rstrip(), weaknesses.rstrip(), improvements.rstrip() with gr.Blocks(theme=gr.themes.Base(font=[gr.themes.GoogleFont("Poppins")])) as demo: gr.Markdown( """
ReviceGraph
A demo application that provides review on a resume against the job market using the G-Retriever framework, an LLM powered by a Knowledge Graph.
*Currently, ReviceGraph only supports the English language.
""" ) with gr.Row(equal_height=True): with gr.Column(): gr.Markdown("### Input") education = gr.Textbox( label="Education", lines=2, placeholder="e.g. Bachelor Degree of Mathematics at Institut Teknologi Sepuluh Nopember", info="The candidate's formal education." ) experience = gr.Textbox( label="Experiences", lines=2, placeholder="e.g. Data Scientist Intern at Bank Rakyat Indonesia", info="The candidate's work experience and job descriptions. Could be intenship experience or professional experience." ) project = gr.Textbox( label="Projects", lines=2, placeholder="e.g. Chatbot for Customer Service using LLM", info="Projects completed by the candidate and their description. Could be college project or internship project" ) skill = gr.Textbox( label="Skills", lines=2, placeholder="e.g. Python, Pytorch, Machine Learning, Deep Learning", info="Skills possessed by the candidate. Could be technical skill, concept skill, or soft skill." ) description = gr.Textbox( label="Description", lines=2, placeholder="e.g. I want to pursue my career as machine learning engineer", info="Candidate career orientation" ) submit = gr.Button("Get Feedback") with gr.Column(): # feedback = gr.Textbox(label="Feedback", interactive=False, lines=18) gr.Markdown("### Output") strengths = gr.Textbox( label="Strengths", lines=7, interactive=False, info="Potential reasons for the candidate to be accepted." ) weaknesses = gr.Textbox( label="Weaknesses", lines=7, interactive=False, info="Potential reasons for the candidate to be rejected." ) improvements = gr.Textbox( label="Improvements", lines=7, interactive=False, info="Recommendation for improvement on candidate's skills, experiences, or projects based on their weaknesses." ) # with gr.Column(): # max_new_tokens = gr.Slider( # minimum=256, # maximum=512, # value=512, # step=1.0, # info="Maximum number of tokens or words", # label="Maximum Output Length", # interactive=True # ) # top_p = gr.Slider( # minimum=0, # maximum=1, # value=0.9, # step=0.01, # label="Top P", # interactive=True # ) # temperature = gr.Slider( # minimum=0.01, # maximum=1, # value=0.4, # step=0.01, # info="Define how creative the model to generates feedback.\nThe optimal value is 0.4.", # label="Temperature", # interactive=True # ) submit.click( fn=get_feedback, inputs=[education, experience, project, skill, description], #, max_new_tokens, temperature, top_p], outputs=[strengths, weaknesses, improvements], # outputs=feedback, show_progress=True ) if __name__ == "__main__": demo.launch()