AI-Driven Interview Question Formulation Agent with Lyzr Automata

harshitlyzr

harshit-lyzr

Posted on March 29, 2024

AI-Driven Interview Question Formulation Agent with Lyzr Automata

In today's competitive job market, preparation is key to landing your dream role. Aspiring candidates often face the daunting task of crafting insightful interview questions that truly assess a candidate's suitability for a position. But fear not! With the power of Lyzr Automata and OpenAI, we've developed the Lyzr Interview Preparation Agent - a cutting-edge tool designed to streamline the interview question formulation process.

Lyzr.ai

Check out the Lyzr.ai community on Discord - hang out with 228 other members and enjoy free voice and text chat.

favicon discord.com

Introduction:
The Lyzr Interview Preparation Agent is a Streamlit web application designed to assist interviewers in generating tailored interview questions for various job descriptions. Leveraging advanced AI models from OpenAI and the intuitive interface of Streamlit, this tool simplifies the task of crafting comprehensive interview questions.

How it Works:
Job Description Input: Simply paste your job description into the text box provided.
AI-Powered Question Generation: Click the "Generate" button and watch the magic happen! The Lyzr Interview Agent analyzes your job description, identifying key skills and requirements. It then crafts a comprehensive list of interview questions designed to assess a candidate's suitability for the role.
Diverse Question Range: The generated questions cover a variety of areas, including:

  • Technical Skills: Drilling down on the specific technical expertise required for the job.
  • Soft Skills: Assessing a candidate's communication, teamwork, and problem-solving abilities.
  • Company Culture Fit: Evaluating how a candidate aligns with the company's values and mission.

Building Your Interview Question Formulation Agent with Lyzr Automata
Imports and Setup:

import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from dotenv import load_dotenv
import os

load_dotenv()
api = os.getenv("OPENAI_API_KEY")
Enter fullscreen mode Exit fullscreen mode

Libraries from lyzr_automata: These libraries seem to be custom modules for working with AI models, agents, and tasks. Potentially related to a specific AI framework.
dotenv and os for environment variable handling (to store the OpenAI API key securely).
load_dotenv() is called to load environment variables from a .env file (likely containing your OpenAI API key).
api = os.getenv("OPENAI_API_KEY") retrieves the API key from the environment variable.

OpenAI Model Configuration:

open_ai_text_completion_model = OpenAIModel(
    api_key=api,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)
Enter fullscreen mode Exit fullscreen mode

open_ai_text_completion_model is created using the OpenAIModel class, likely from lyzr_automata.
It's provided with your API key and sets parameters for the AI model:
"model": "gpt-4-turbo-preview" specifies the AI model to use (likely a large language model from OpenAI).
"temperature": 0.2" controls the randomness of the generated text (lower value means less random).
"max_tokens": 1500" sets the maximum number of words the model can generate.



interview_questions function:

def interview_questions(query):

    interview_agent = Agent(
            role="Interview expert",
            prompt_persona=f"You are an Expert INTERVIEW COACH. Your task is to FORMULATE 30 interview questions that are DIRECTLY TAILORED to a {query}."
        )

    prompt=f"""Your task is to FORMULATE 30 interview questions that are DIRECTLY TAILORED to a {query}.
        1.ANALYZE the job description CAREFULLY, identifying KEY SKILLS, RESPONSIBILITIES, and QUALIFICATIONS required for the role.
        2. DEVELOP a list of questions that ADDRESS each of these key areas, ensuring you probe into the candidate's RELEVANT EXPERIENCE and EXPERTISE.
        3. CREATE behavioral interview questions to ASSESS how candidates have previously HANDLED situations similar to those they might encounter in the target role.
        4. FORMULATE questions that allow candidates to DEMONSTRATE their problem-solving abilities and how they align with the company's VALUES and CULTURE.
        5. ENSURE that your questions also invite candidates to SHARE their professional aspirations and how they see themselves CONTRIBUTING to the company's GROWTH and SUCCESS.
        6. STRUCTURE your questions in a way that they build upon each other, creating a COHERENT and ENGAGING interview flow.
        You MUST craft these questions with the intention of GAUGING both technical competencies and SOFT SKILLS.
        I'm going to tip $300K for a BETTER SOLUTION!
        Now Take a Deep Breath."""

    question_task = Task(
        name="Interview Task",
        model=open_ai_text_completion_model,
        agent=interview_agent,
        instructions=prompt,
    )

    output = LinearSyncPipeline(
        name="Question Pipline",
        completion_message="pipeline completed",
        tasks=[
              question_task
        ],
    ).run()

    answer = output[0]['task_output']

    return answer
Enter fullscreen mode Exit fullscreen mode

This function takes the user-provided query (job description) as input.
It defines an interview_agent object, likely from lyzr_automata, specifying its role as a "Interview expert" (potentially ensuring generated questions are appropriate).
The prompt_persona sets the character the AI should embody while generating questions (an Interview Coach).
It constructs a new prompt string specifically tailored to the query. It mentions the user's job description and reiterates the key points for crafting interview questions.(We use prompts from MagicPrompts)
A question_task object is created using the Task class (likely from lyzr_automata). This task defines the specific job for the AI model.
It sets a name ("Interview Task"), assigns the OpenAI model (open_ai_text_completion_model), the interview agent (interview_agent), and the newly constructed prompt with the user's job description.
A LinearSyncPipeline object is created. This likely manages the execution of the task.
It's named "Question Pipeline" and sets a completion message.
It runs the question_task as part of its tasks list.
The output from the pipeline is retrieved, and the first element's (task_output) is extracted, which contains the AI-generated interview questions based on the user's job description.
The function returns the extracted interview questions (answer).

User Interaction and Output:

if st.button("Generate"):
    solution = interview_questions(query)
    st.markdown(solution)
Enter fullscreen mode Exit fullscreen mode

An "if" statement checks if a button labeled "Generate" is clicked using st.button.
If clicked, the interview_questions function is called with the user's job description (query).
The returned answer (generated interview questions) is displayed using st.markdown.

The Lyzr Interview Preparation Agent represents a significant step forward in interview preparation technology. By harnessing the capabilities of AI and streamlining the question formulation process, this tool empowers interviewers to conduct more effective and insightful interviews. Whether you're a hiring manager, recruiter, or interview coach, the Lyzr Interview Preparation Agent is your ultimate companion in the quest for talent acquisition excellence.
try it now: https://lyzr-interview-agent.streamlit.app/
For more information explore the website: Lyzr


💖 💪 🙅 🚩
harshitlyzr
harshit-lyzr

Posted on March 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related