Spaces:
Runtime error
Runtime error
Commit ·
fa0698f
1
Parent(s): 2b0770b
refactor: Update feedback API endpoint and enhance HTML tag handling
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ from constants import JOB_DESCRIPTION, RESUME_TEXT
|
|
| 10 |
|
| 11 |
API_KEY = os.getenv("API_KEY")
|
| 12 |
CHATBOT_API_ENDPOINT = "https://talent-interview-prep-conversational-model.multimodal.dev/"
|
| 13 |
-
|
| 14 |
|
| 15 |
# Predefined questions
|
| 16 |
questions = {
|
|
@@ -70,10 +70,12 @@ def chatbot_api_call(interview_question, user_input, conversation_mode, conversa
|
|
| 70 |
return "Error: Unable to reach the API or invalid response received."
|
| 71 |
|
| 72 |
def remove_html_tags(text):
|
|
|
|
| 73 |
soup = BeautifulSoup(text, "html.parser")
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
-
def
|
| 77 |
headers = {
|
| 78 |
"x-api-key": API_KEY,
|
| 79 |
"Content-Type": "application/json"
|
|
@@ -81,13 +83,12 @@ def feedback_api_call(interview_question, user_input, feedback_type="standard"):
|
|
| 81 |
|
| 82 |
data = {
|
| 83 |
"job_title": "Senior Product Manager",
|
| 84 |
-
"
|
| 85 |
-
"answer": user_input,
|
| 86 |
"feedback_type": feedback_type
|
| 87 |
}
|
| 88 |
|
| 89 |
try:
|
| 90 |
-
response = requests.post(
|
| 91 |
|
| 92 |
if response.status_code == 200:
|
| 93 |
return response.text
|
|
@@ -250,7 +251,7 @@ def create_demo():
|
|
| 250 |
if conversation_mode == 'Interviewer':
|
| 251 |
current_turns += 1
|
| 252 |
updated_label = f"Conversation turns: {current_turns}"
|
| 253 |
-
feedback = remove_html_tags(
|
| 254 |
else:
|
| 255 |
updated_label = "Multimodal Coach Agent"
|
| 256 |
feedback = ""
|
|
|
|
| 10 |
|
| 11 |
API_KEY = os.getenv("API_KEY")
|
| 12 |
CHATBOT_API_ENDPOINT = "https://talent-interview-prep-conversational-model.multimodal.dev/"
|
| 13 |
+
QUESTION_RELATED_FEEDBACK_API_ENDPOINT = "https://talent-interview-prep-question-related-feedback.multimodal.dev/"
|
| 14 |
|
| 15 |
# Predefined questions
|
| 16 |
questions = {
|
|
|
|
| 70 |
return "Error: Unable to reach the API or invalid response received."
|
| 71 |
|
| 72 |
def remove_html_tags(text):
|
| 73 |
+
text = text.replace("</p>", "\n")
|
| 74 |
soup = BeautifulSoup(text, "html.parser")
|
| 75 |
+
cleaned_text = soup.get_text().strip('"').replace('\\"', '"')
|
| 76 |
+
return cleaned_text
|
| 77 |
|
| 78 |
+
def question_related_feedback_api_call(interview_conversation, feedback_type="standard"):
|
| 79 |
headers = {
|
| 80 |
"x-api-key": API_KEY,
|
| 81 |
"Content-Type": "application/json"
|
|
|
|
| 83 |
|
| 84 |
data = {
|
| 85 |
"job_title": "Senior Product Manager",
|
| 86 |
+
"interview_conversation": interview_conversation,
|
|
|
|
| 87 |
"feedback_type": feedback_type
|
| 88 |
}
|
| 89 |
|
| 90 |
try:
|
| 91 |
+
response = requests.post(QUESTION_RELATED_FEEDBACK_API_ENDPOINT, headers=headers, json=data)
|
| 92 |
|
| 93 |
if response.status_code == 200:
|
| 94 |
return response.text
|
|
|
|
| 251 |
if conversation_mode == 'Interviewer':
|
| 252 |
current_turns += 1
|
| 253 |
updated_label = f"Conversation turns: {current_turns}"
|
| 254 |
+
feedback = remove_html_tags(question_related_feedback_api_call(chat_memory['messages'][:-1], feedback_type.lower())).strip()
|
| 255 |
else:
|
| 256 |
updated_label = "Multimodal Coach Agent"
|
| 257 |
feedback = ""
|