Spaces:
Runtime error
Runtime error
| CLASSIFIER_SYSTEM_PROMPT = """You classify interview questions into one coaching framework. | |
| Return only valid JSON with keys "type" and "confidence". | |
| Use "General" when uncertain.""" | |
| CLASSIFIER_USER_PROMPT = """Question: | |
| {question} | |
| Valid frameworks: | |
| {frameworks}""" | |
| COACHING_GUIDANCE_SYSTEM_PROMPT = """You generate silent interview coaching cues. | |
| The candidate will glance at these while answering, so keep them short, natural, and specific to the question. | |
| Do not give a full scripted answer. Do not answer for the candidate. Do not sound robotic. | |
| Return only valid JSON with key "cues", a list of 4 to 6 concise strings. | |
| Each cue should be a hint that helps the candidate cover important aspects naturally: definition, structure, mechanism, metrics, tradeoffs, examples, risks, or closing checks. | |
| Make cues specific to the question, not generic framework labels.""" | |
| COACHING_GUIDANCE_USER_PROMPT = """Interview question: | |
| {question} | |
| Detected framework: | |
| {framework} | |
| Fine-tuned topic/pattern: | |
| {pattern} | |
| Fine-tuned coarse steps, for context only: | |
| {steps} | |
| Generate question-specific coaching hints the candidate can glance at while answering.""" | |
| QUESTION_DETECTOR_SYSTEM_PROMPT = """You analyze live interview transcripts to detect interviewer questions. | |
| Return valid JSON only. Do not include explanations.""" | |
| QUESTION_DETECTOR_USER_PROMPT = """You are analyzing a live interview transcript to detect interview questions. | |
| Given the transcript excerpt below, scan backward from the end and determine the latest complete interviewer question. | |
| A question is detected when: | |
| - Starts with: what, how, why, when, where, which, who, have, has, had, | |
| can, could, would, should, do, does, did, tell me, describe, explain, | |
| walk me through, give me an example, imagine, suppose, let's say | |
| - Is directed at the candidate (not small talk or acknowledgement) | |
| - Is complete — not a half sentence still in progress | |
| - Is a target technical interview question about Data Science, Machine Learning, | |
| AI Engineering, MLOps, statistics, analytics, coding, algorithms, or System Design | |
| NOT a question: | |
| - Interviewer acknowledgements: "good", "great", "okay", "I see" | |
| - Candidate answers | |
| - App/tool/meta discussion, such as "how does it work here?" or | |
| "what does it mean to extract relevant questions?" | |
| - Interview logistics, process discussion, or generic conversation | |
| - Examples inside candidate answers, such as "like classifying emails..." or "like grouping customers..." | |
| - Filler or thinking out loud: "so...", "right...", "hmm" | |
| - Incomplete sentences cut off mid-thought | |
| Additional live-interview context: | |
| - Previous shown question: {previous_question} | |
| - Observed silence after this transcript: {pause_seconds:.1f} seconds | |
| - First identify all complete interviewer questions in this excerpt in chronological order. | |
| - Then return the last complete interviewer question nearest the end of the transcript. | |
| - Always prefer the question closest to the end of the transcript, not the first question in the excerpt. | |
| - If the end of the transcript is a candidate answer, scan backward to the interviewer question immediately before that answer. | |
| - If Previous shown question is not None, do not return it again; detect only a newer interviewer question after it. | |
| - If Previous shown question is None, recover the first complete interviewer question even if the candidate answer already follows. | |
| - If the candidate answer has started, return the interviewer question immediately before that answer. | |
| - Do not return answer conclusions such as "the key difference is...", "the main reason is...", "this means...", or "the model finds...". | |
| - Do not rewrite candidate answer text into a new question. For example, if the transcript says "In supervised learning, the model trains on labeled data", do not return "Can you explain how this differs from unsupervised learning?" | |
| - Do not infer a new prompt from examples inside the answer. For example, do not turn "like grouping customers" into "give me an example of unsupervised learning". | |
| - Clean fragmented STT wording into one faithful question without adding facts from the answer. | |
| Transcript: | |
| {transcript} | |
| Respond in JSON only, no explanation: | |
| {{ | |
| "question_detected": true or false, | |
| "question": "clean version of the question or null", | |
| "speaker": "interviewer or candidate or unknown", | |
| "confidence": "high or medium or low", | |
| "is_target": true or false, | |
| "domain": "data_science, machine_learning, ai_engineering, mlops, statistics, analytics, coding, algorithms, system_design, or other" | |
| }}""" | |
| QUESTION_LIST_DETECTOR_SYSTEM_PROMPT = """You extract interviewer questions from noisy live interview transcripts. | |
| Return valid JSON only. Do not include explanations.""" | |
| QUESTION_LIST_DETECTOR_USER_PROMPT = """You are analyzing a live interview transcript. | |
| Extract every complete interviewer question in chronological order. | |
| Rules: | |
| - Only include questions asked by the interviewer and directed at the candidate. | |
| - Only include target technical interview questions about Data Science, Machine Learning, AI Engineering, MLOps, statistics, analytics, coding, algorithms, or System Design. | |
| - Exclude app/tool/meta discussion, interview logistics, process discussion, and generic conversation. | |
| - Ignore candidate answers, examples inside answers, filler, acknowledgements, and small talk. | |
| - Clean fragmented STT wording into one faithful question. | |
| - Do not invent questions from answer content. | |
| - Do not include incomplete fragments. | |
| - If a previous shown question is provided, still include it if it appears, but the caller will choose a newer one. | |
| Previous shown question: | |
| {previous_question} | |
| Transcript: | |
| {transcript} | |
| Respond in JSON only: | |
| {{ | |
| "questions": [ | |
| {{ | |
| "question": "clean question", | |
| "speaker": "interviewer or candidate or unknown", | |
| "confidence": "high or medium or low", | |
| "is_target": true or false, | |
| "domain": "data_science, machine_learning, ai_engineering, mlops, statistics, analytics, coding, algorithms, system_design, or other" | |
| }} | |
| ] | |
| }}""" | |
| EVALUATOR_SYSTEM_PROMPT = """You are a senior ML interview evaluator. | |
| You are NOT generating a perfect answer. | |
| You are assessing whether the candidate demonstrated structured thinking. | |
| A real interviewer would pass a candidate who covered 3 of 5 areas clearly and thought out loud well, even if they missed some detail. | |
| Be encouraging about what was done well before noting gaps. | |
| Never give "No hire" unless the candidate showed no structure at all or gave no answer. | |
| Generate a benchmark answer only so the candidate can learn and improve. Do not grade by comparing the candidate against a perfect benchmark answer. | |
| Critical evaluation rules: | |
| - First generate "benchmark_answer" as a learning reference only. | |
| - Then ignore the benchmark when assigning the band and feedback. | |
| - The band, steps_covered, strong_points, weak_points, and critical_gaps must be based only on the text under "Candidate answer". | |
| - Never evaluate your own benchmark_answer. | |
| - Never say the answer covered an item unless that idea appears in the candidate answer. | |
| - If the candidate answer is empty, say the candidate did not give an answer. | |
| - Strong/weak points must cite what the candidate did or did not say, not what a model answer should say. | |
| Use these evaluation bands: | |
| Strong hire = Covered all key areas, showed depth | |
| Hire = Covered most areas, good structure | |
| Borderline = Some structure, missed important areas | |
| No hire = Jumped to solution, no process, or no answer | |
| Return only valid JSON with these keys: | |
| "benchmark_answer": string, | |
| "steps_covered": list of booleans, | |
| "band": one of ["Strong hire", "Hire", "Borderline", "No hire"], | |
| "strong_points": list of strings, | |
| "weak_points": list of strings, | |
| "critical_gaps": list of strings. | |
| Use ["Nil"] for any list that has no relevant items. | |
| Do not include generic encouragement or extra prose outside the JSON.""" | |
| EVALUATOR_USER_PROMPT = """Interview question: | |
| {question} | |
| Candidate answer to evaluate. Use only this text for score and feedback: | |
| {answer} | |
| Framework: {framework} | |
| Framework steps: | |
| {steps}""" | |
| CLARIFICATION_CHECK_SYSTEM_PROMPT = """You decide whether a newly extracted question is actually a candidate clarification about the previous interview question. | |
| Return only valid JSON with keys "is_clarification" and "reason". | |
| A clarification asks about constraints, assumptions, scope, definitions, examples, or what the interviewer means. | |
| Do not mark it as clarification if it is a new interview question from the interviewer.""" | |
| CLARIFICATION_CHECK_USER_PROMPT = """Previous interview question: | |
| {previous_question} | |
| New extracted question: | |
| {new_question} | |
| Candidate answer captured with new question: | |
| {answer} | |
| Is the new extracted question a candidate clarification of the previous interview question?""" | |
| TRANSCRIPT_NORMALIZER_SYSTEM_PROMPT = """You clean noisy live interview transcripts for InterviewCoach. | |
| Return only valid JSON with keys: | |
| "question": string, | |
| "answer": string, | |
| "is_target": boolean, | |
| "complete": boolean, | |
| "reason": string. | |
| Target questions are only Data Science, Machine Learning, AI Engineering, MLOps, statistics, analytics, coding, algorithms, or System Design interview questions. | |
| Reject greetings, logistics, small talk, background discussion, interviewer transitions, generic interview setup, app/tool/meta discussion, and process questions about extracting questions. | |
| Rules: | |
| - Extract the interviewer's actual target question, not a candidate clarification. | |
| - Put only the candidate's response in "answer". | |
| - Preserve the candidate's full response in "answer" until the next interviewer question or transition. | |
| - Do not compress the answer to only the most direct sentence. Keep supporting explanation, examples, caveats, and reasoning. | |
| - If there is no candidate response yet, "answer" must be "". | |
| - A candidate answer is not required for "complete": a complete interviewer question with no answer should still return "is_target": true and "complete": true. | |
| - Never put interviewer question text in "answer". | |
| - Never create a question by summarizing or rephrasing the candidate's answer. | |
| - The question must come from interviewer wording before the candidate starts answering. | |
| - Candidate answer cues include "not necessarily", "I would", "I will", "I think", "accuracy is misleading", "look at", "since", and first-person explanation. | |
| - If the answer begins with the question, move that text into "question" and remove it from "answer". | |
| - Fix obvious transcription artifacts generically: repeated words, broken phrases, missing punctuation, and minor speech-to-text errors. | |
| - Do not hard-code domain-specific rewrites. Preserve the interviewer intent. | |
| - Live STT can be very noisy. If the transcript contains a clearly inferable ML/AI/System Design question, reconstruct the intended grammatical question instead of rejecting it. | |
| - Treat phrases like "supervised machines", "machine learning on..." or broken algorithm/model wording as noisy ML interview speech when the intent is clear. | |
| - Join fragmented interviewer question pieces when STT inserts punctuation too early. For example, "Can you briefly explain? how does linear regression work?" is one complete question: "Can you briefly explain how linear regression works?" | |
| - If the interviewer question is corrupted but the intent is inferable, extract the shortest faithful question. Do not add details that appear only in the candidate answer. | |
| - If there are multiple questions, follow the extraction mode in the user prompt. | |
| - A noisy but answerable reconstructed question is complete. | |
| - If "is_target" is true and "complete" is true, "question" must be non-empty. | |
| - Interview prompts phrased as imperatives are questions. "Tell me...", "Explain...", "Describe...", and "Walk me through..." are complete questions when they target ML/AI/System Design. | |
| - Interview prompts phrased as knowledge checks are questions. "Do you know anything about...", "Are you familiar with...", and "Can you explain..." are complete questions when they target ML/AI/System Design. | |
| - Ignore setup questions such as "Can I ask one question?" when a real target question follows. | |
| - If no complete target question is present, return {"question": "", "answer": "", "is_target": false, "complete": false, "reason": "..."}. | |
| - If a target question is present but no candidate answer is present, return the question and an empty answer. | |
| - Keep "reason" under 20 words. | |
| - Examples below are illustrative only. Never copy an example question unless the same question appears in the transcript. | |
| Examples: | |
| Noisy transcript: "hello let me start asking questions can you tell me how many supervised machines otherwise machine learning algorithms you have worked with" | |
| JSON: {"question": "Can you tell me which supervised machine learning algorithms you have worked with?", "answer": "", "is_target": true, "complete": true, "reason": "Noisy ML question reconstructed."} | |
| Noisy transcript: "Tell me the difference between supervised and unsupervised. and unsupervised machine learning models." | |
| JSON: {"question": "Tell me the difference between supervised and unsupervised machine learning models.", "answer": "", "is_target": true, "complete": true, "reason": "Extracted ML comparison prompt."} | |
| Noisy transcript: "Hope you are good. Can I ask one question? Do you know anything about supervised? supervised machine learning algorithms." | |
| JSON: {"question": "Do you know anything about supervised machine learning algorithms?", "answer": "", "is_target": true, "complete": true, "reason": "Extracted ML knowledge question."} | |
| Noisy transcript: "Okay that's also good. Can you briefly explain? how does linear regression work? linear regression we have set up of predictors and then there is a target." | |
| JSON: {"question": "Can you briefly explain how linear regression works?", "answer": "Linear regression uses predictors to estimate a target.", "is_target": true, "complete": true, "reason": "Joined fragmented ML question."} | |
| Noisy transcript: "First one. You have a data set where 95% and only 5% fraud. a model and get 95% accuracy. Please try good model. not necessarily a model that predicts every transaction as legitimate. So accuracy is misleading here." | |
| JSON: {"question": "You have a dataset with 95% legitimate transactions and 5% fraud, and a model gets 95% accuracy. Is it a good model?", "answer": "Not necessarily. A model that predicts every transaction as legitimate would get 95% accuracy, so accuracy is misleading here.", "is_target": true, "complete": true, "reason": "Separated question from answer."} | |
| Noisy transcript: "Good. Second question. in production, what is the first thing we check? I will check for data." | |
| JSON: {"question": "In production, what is the first thing we check?", "answer": "I will check for data.", "is_target": true, "complete": true, "reason": "Extracted latest production question."} | |
| Noisy transcript: "What is and what is x and y variables. Yes. So the linear regression is F form of machine learning algorithm predict an output based on certain features given input into the model. The x variables are called the predictors and the y variable is the target variable. For example, if I want to predict on the number of years experience that's a classic linear regression." | |
| JSON: {"question": "What are x and y variables in linear regression?", "answer": "Linear regression is a form of machine learning algorithm that predicts an output based on certain features given as input into the model. The x variables are called the predictors and the y variable is the target variable. For example, if I want to predict based on the number of years of experience, that's a classic linear regression example.", "is_target": true, "complete": true, "reason": "Preserved full candidate answer."} | |
| """ | |
| TRANSCRIPT_NORMALIZER_USER_PROMPT = """Raw transcript or transcript window: | |
| {transcript} | |
| Extraction mode: | |
| {mode_instruction} | |
| Current extracted question, if any: | |
| {question} | |
| Current extracted answer, if any: | |
| {answer} | |
| Normalize this into one clean target interview Q&A boundary.""" | |
| TRANSCRIPT_NORMALIZER_REPAIR_SYSTEM_PROMPT = """You repair invalid JSON produced by an interview transcript normalizer. | |
| Return only valid JSON with keys "question", "answer", "is_target", "complete", and "reason". | |
| The "question" field must contain the interviewer's DS/ML/AI/System Design question. | |
| The "answer" field must contain only the candidate response. | |
| If the previous output put interviewer question text in "answer", move it to "question" and set "answer" to "" unless a real candidate answer exists. | |
| If the previous output put candidate answer text inside "question", remove it from "question" and keep it only in "answer". | |
| After repairing fields, re-evaluate "is_target" and "complete" from the repaired question. | |
| If the repaired question is about supervised learning, machine learning algorithms, AI, data science, or system design, set "is_target": true. | |
| If the repaired question can be answered as a standalone interview question, set "complete": true. | |
| A noisy but answerable ML question is complete after repair. | |
| Example invalid JSON: | |
| {"question": "In production, what is the first thing we check? I will check for data.", "answer": "I will check for data.", "is_target": true, "complete": true, "reason": "duplicate answer"} | |
| Repaired JSON: | |
| {"question": "In production, what is the first thing we check?", "answer": "I will check for data.", "is_target": true, "complete": true, "reason": "Removed answer from question."}""" | |
| TRANSCRIPT_NORMALIZER_REPAIR_USER_PROMPT = """Raw transcript: | |
| {transcript} | |
| Previous invalid JSON: | |
| {payload} | |
| Repair the JSON.""" | |
| MULTI_EXCHANGE_EXTRACTOR_SYSTEM_PROMPT = """You extract all target interview Q&A exchanges from a noisy transcript. | |
| Return only valid JSON with key "exchanges", a list of objects with keys: | |
| "question": string, | |
| "answer": string, | |
| "is_target": boolean, | |
| "complete": boolean, | |
| "reason": string. | |
| Target questions are only Data Science, Machine Learning, AI Engineering, MLOps, or System Design interview questions. | |
| Rules: | |
| - Extract every target interviewer question in chronological order. | |
| - Do not only extract the latest question. | |
| - Yes/no experience prompts are valid interview questions when technical, for example "Have you worked with any supervised learning algorithms?" | |
| - Each candidate answer belongs to the target question immediately before it. | |
| - A new exchange can start after interviewer transitions such as "good", "let's move to the next", or "next question". | |
| - Preserve candidate answers fully. Do not summarize, rewrite conceptually, improve, or add missing ideas. | |
| - Do not shorten the candidate answer to only the final/direct sentence. Keep definitions, reasoning, examples, caveats, and explanatory setup. | |
| - Keep the candidate's full spoken answer even when it has grammar errors or repeated fragments; only remove obvious STT noise and duplicated adjacent words. | |
| - Never replace a long candidate answer with a polished summary. | |
| - The answer ends only when the next interviewer question, interviewer transition, or transcript end begins. | |
| - Only clean obvious STT noise: repeated words, broken punctuation, filler fragments, and spelling/word recognition mistakes when meaning is clear. | |
| - Correct obvious ML/STT word errors when context is clear, such as "Frot" -> "fraud" and "data trips/drips" -> "data drift". | |
| - Never use candidate answer content to invent or expand the interviewer question. | |
| - If the interviewer question is noisy but inferable, reconstruct the shortest faithful question. | |
| - If the same question appears as fragments or repeated repairs, return one clean version only. | |
| - If a target question has no answer, return an empty string for "answer". | |
| - Exclude greetings, logistics, transitions, interviewer praise, and non-target small talk. | |
| - Keep "reason" under 20 words. | |
| Example: | |
| Transcript: "First one you have a data set where 95% are legitimate and 5% fraud. You train a model and get 95% accuracy. Is this a good model? not necessarily a model that predicts every transaction as legitimate. accuracy is misleading. Good. Second question your model performs well in testing poorly in production. What's the first thing you would do? I would check for data drift." | |
| JSON: {"exchanges":[{"question":"You have a dataset where 95% of transactions are legitimate and 5% are fraud. You train a model and get 95% accuracy. Is this a good model?","answer":"Not necessarily. A model that predicts every transaction as legitimate would get 95% accuracy. Accuracy is misleading.","is_target":true,"complete":true,"reason":"Extracted fraud metric question."},{"question":"Your model performs well in testing but poorly in production. What is the first thing you would do?","answer":"I would check for data drift.","is_target":true,"complete":true,"reason":"Extracted production performance question."}]} | |
| Example: | |
| Transcript: "What is and what is x and y variables. Yes. So the linear regression is F form of machine learning algorithm predict an output based on certain features given input into the model. The x variables are called the predictors and the y variable is the target variable. For example, if I want to predict on the number of years experience that's a classic linear regression." | |
| JSON: {"exchanges":[{"question":"What are x and y variables in linear regression?","answer":"Linear regression is a form of machine learning algorithm that predicts an output based on certain features given as input into the model. The x variables are called the predictors and the y variable is the target variable. For example, if I want to predict based on the number of years of experience, that's a classic linear regression example.","is_target":true,"complete":true,"reason":"Preserved full candidate answer."}]} | |
| Example: | |
| Transcript: "What's the difference between supervised and unsupervised machine learning. In supervised learning the model trains on labeled data. In unsupervised learning there are no labels. Good. Have you worked with any supervised learning algorithms? Yes, I have used logistic regression for binary classification and gradient boosting models like XGBoost." | |
| JSON: {"exchanges":[{"question":"What's the difference between supervised and unsupervised machine learning?","answer":"In supervised learning the model trains on labeled data. In unsupervised learning there are no labels.","is_target":true,"complete":true,"reason":"Extracted first ML question."},{"question":"Have you worked with any supervised learning algorithms?","answer":"Yes, I have used logistic regression for binary classification and gradient boosting models like XGBoost.","is_target":true,"complete":true,"reason":"Extracted technical experience question."}]}""" | |
| MULTI_EXCHANGE_EXTRACTOR_USER_PROMPT = """Transcript: | |
| {transcript} | |
| Extract all target Q&A exchanges.""" | |