Spaces:
Runtime error
Runtime error
File size: 3,220 Bytes
72af144 8508e0f 66a9f93 8508e0f 66a9f93 8508e0f 72af144 8508e0f 7b91819 8508e0f 7b91819 8508e0f a172d36 8508e0f 66a9f93 a172d36 8508e0f 72af144 8508e0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 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"
|