I have built a Python app that uses AI to interview candidates and analyze their behavior. Right now it works but I want to make the conversation flow better using LangGraph. Here is what my current code looks like:
import os
import json
import openai
from personality_data import PERSONALITY_TYPES
# Save chat history to JSON file
def store_chat_history(chat_data):
file_id = os.urandom(4).hex() + '.json'
with open(file_id, 'w') as output_file:
json.dump(chat_data, output_file, indent=2)
return file_id
# Get candidate information at start
def get_candidate_info():
client = openai.OpenAI()
greeting_request = "Create a professional greeting to collect the candidate's full name for an interview session."
ai_response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": greeting_request}]
)
greeting_text = ai_response.choices[0].message.content
full_name = input(f"\nInterviewer: {greeting_text}\nYour answer: ")
print(f"\nInterviewer: Great to meet you {full_name}. We can now begin the assessment.\n")
return full_name
# Collect responses from user
def collect_response(question_text):
user_input = ""
while not user_input:
user_input = input(f"\nInterviewer: {question_text}\n\nYour response: ").strip()
if not user_input:
print("Interviewer: I need you to provide an answer please.")
return user_input
# Start the interview process
candidate_name = get_candidate_info()
My app works for basic questions but I want to add LangGraph so it can make smarter decisions about what questions to ask next based on the candidate’s previous answers. I tried using CrewAI before but it was too complicated for what I need.
What I have done so far:
- Built basic interview functions with CrewAI for talking to candidates
- Started looking into LangGraph but not sure how to connect it properly
- Made functions that can introduce candidates and save their responses using OpenAI
What I need help with:
- Step by step guide to add LangGraph to my current code
- Better ways to organize AI agents for interview tasks
- Should I use something else instead of LangGraph that might be easier
I am pretty new to these AI frameworks so any simple examples or tips would be really helpful. Thanks for any advice you can give me.