Spaces:
Runtime error
Runtime error
| import json | |
| from .constants import ( | |
| JOB_DESCRIPTION, | |
| RESUME_TEXT | |
| ) | |
| from .constants import ( | |
| CONVERSATIONAL_MODEL_API_ENDPOINT, | |
| QUESTION_RELATED_FEEDBACK_API_ENDPOINT, | |
| QUESTION_RELATED_IDEAL_ANSWER_API_ENDPOINT, | |
| CONVERSATIONAL_MODEL_FEEDBACK_API_ENDPOINT, | |
| JOB_DESCRIPTION, | |
| RESUME_TEXT | |
| ) | |
| from .utils import api_call | |
| def chatbot_api_call(session_id, interview_question, user_input, conversation_mode, conversation_turns_limit, include_company_name, include_resume_text): | |
| print(f"Calling chatbot API with session_id: {session_id}") | |
| data = { | |
| "session_id": session_id, | |
| "job_title": "Senior Product Manager", | |
| "job_description": JOB_DESCRIPTION, | |
| "interview_question": interview_question, | |
| "user_input": user_input, | |
| "conversation_mode": conversation_mode.lower(), | |
| "conversation_turns_limit": conversation_turns_limit | |
| } | |
| if include_company_name: | |
| data["company_name"] = "InnovateTech Solutions" | |
| if include_resume_text: | |
| data["resume_text"] = RESUME_TEXT | |
| response = api_call(CONVERSATIONAL_MODEL_API_ENDPOINT, data) | |
| if response.status_code == 200: | |
| json_response = response.json() | |
| return json_response.get("response"), json_response.get("conversation_end"), json_response.get("chat_memory") | |
| else: | |
| return f"Error: Received status code {response.status_code} from the API" | |
| def feedback_api_call(interview_data, feedback_type, include_resume_text): | |
| data = { | |
| "job_title": "Senior Product Manager", | |
| "interview_data": interview_data, | |
| "feedback_type": feedback_type | |
| } | |
| if include_resume_text: | |
| data["resume_text"] = RESUME_TEXT | |
| response = api_call(QUESTION_RELATED_FEEDBACK_API_ENDPOINT, data) | |
| if response.status_code == 200: | |
| print(response.text) | |
| return json.loads(response.text) | |
| else: | |
| return f"Error: Received status code {response.status_code} from the API" | |
| def ideal_answer_api_call(interview_data_with_feedback, feedback_type, include_resume_text): | |
| data = { | |
| "job_title": "Senior Product Manager", | |
| "interview_data_with_feedback": interview_data_with_feedback, | |
| "feedback_type": feedback_type | |
| } | |
| if include_resume_text: | |
| data["resume_text"] = RESUME_TEXT | |
| response = api_call(QUESTION_RELATED_IDEAL_ANSWER_API_ENDPOINT, data) | |
| if response.status_code == 200: | |
| return response.text | |
| else: | |
| return f"Error: Received status code {response.status_code} from the API" | |
| def conversation_feedback_api_call(interview_data, feedback_type, include_resume_text, include_job_description): | |
| data = { | |
| "job_title": "Senior Product Manager", | |
| "interview_data": interview_data, | |
| "feedback_type": feedback_type | |
| } | |
| if include_resume_text: | |
| data["resume_text"] = RESUME_TEXT | |
| if include_job_description: | |
| data["job_description"] = JOB_DESCRIPTION | |
| response = api_call(CONVERSATIONAL_MODEL_FEEDBACK_API_ENDPOINT, data) | |
| if response.status_code == 200: | |
| return json.loads(response.text) | |
| else: | |
| return f"Error: Received status code {response.status_code} from the API" | |