Untitled

 avatar
unknown
plain_text
a month ago
1.6 kB
8
Indexable
from openai import OpenAI

client = OpenAI(api_key="KEY")

def thematic_analysis_ai_interview(comment):
    messages = [
        {"role": "system", "content": "You are an expert in text analysis and thematic extraction."},
        {
            "role": "user",
            "content": f"""
            Analyze the following comment:
            "{comment}"
            
            Your task is to:
            1. Determine if the comment is related to AI-based interviews, automated hiring systems, or algorithmic recruitment tools.
            2. If yes, provide:
                - A brief summary of the main idea (1-2 sentences).
                - Keywords that represent the main theme.
                - A suggested thematic category.
            3. If no, provide:
                - A 'No' response with a brief explanation of why the comment is not related to these topics.

            Please respond in the following format:
            - Related: Yes/No
            - Summary: ...
            - Keywords: ...
            - Suggested Theme: ...
            - Explanation (if not related): ...
            """
        }
    ]

    try:
        # Call the chat completion endpoint
        response = client.chat.completions.create(
            model="gpt-3.5-turbo",
            messages=messages,
            max_tokens=300,
            temperature=0.5,
        )
        # Access the response content
        return response.choices[0].message.content.strip()
    except Exception as e:
        return f"Error occurred: {str(e)}"

result = thematic_analysis_ai_interview(comment)
print(result)
Editor is loading...
Leave a Comment