Skip to content

Commit

Permalink
[!] Fixed the error with double assistant -- backend
Browse files Browse the repository at this point in the history
  • Loading branch information
pathfindermilan committed Oct 23, 2024
1 parent 75b65cb commit 9a3cf69
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/console/ai/generate_init_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def generate_next_init_question(last_info_msg_ai, init, applicant, input):
Based on the user data above, generate the next question where you will ask the user to provide you with information that is missing, in this case that is {input}.
DO NOT INCLUDE ANY GREETING TO THE USER, be professional. If there is an information about user name, use the name when you are asking the user with further questions.
Also note that you are voice assistant that is an interviewer and you are asking the user with basic questions to get information about him.
Also note that you are VOICE assistant, so talk like real human who is an interviewer and you are asking the user with basic questions to get information about him.
If ASK IF USER IS READY is equal to 1, ask the user to tell you when he is ready to start with the interview.
Next Question:
Expand Down
4 changes: 2 additions & 2 deletions backend/console/ai/generate_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def generate_next_question(self, text, last_question, n_questions, current_score
Number of Questions Asked: {n_questions}
Current Score: {current_score}
Based on the information above, generate the next interview question. The question should be relevant to the previous question and answer, and appropriate for the current stage of the interview (considering the number of questions asked and the current score).
Be professional, but include some phrases like : "Good answer", "Not bad" or something like that before the genrated question.
Be professional, but include some phrases like : "Good", "Not bad", "Let's start then", "Awesome", "Excelent", "Can be better" or something like that before the genrated question.
Decide the init phrase based on how relevant is Last Question with Human's Answer.
Next Question:
"""

response = openai.chat.completions.create(
model=self.model_name,
messages=[
{"role": "system", "content": "You are a helpful assistant that generates interview questions."},
{"role": "system", "content": "You are a helpful VOICE assistant that generates interview questions."},
{"role": "user", "content": prompt}
],
max_tokens=100,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.1 on 2024-10-23 23:37

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('console', '0007_alter_identity_avatar'),
]

operations = [
migrations.AlterField(
model_name='applicant',
name='email',
field=models.EmailField(max_length=70),
),
migrations.AlterField(
model_name='session',
name='applicant',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='console.applicant'),
),
]
Binary file not shown.
5 changes: 3 additions & 2 deletions backend/console/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Order(models.Model):
status = models.BooleanField(default=False)

class Applicant(models.Model):
email = models.EmailField(max_length=70, blank=False, unique=True)
email = models.EmailField(max_length=70, blank=False)
name = models.TextField(null=True, blank=True, default = '')
skills = models.TextField(null=True, blank=True, default = '')
level = models.TextField(null=True, blank=True, default = '')
Expand Down Expand Up @@ -246,4 +246,5 @@ class Session(models.Model):
MaxValueValidator(100.0)
]
)
applicant = models.OneToOneField(Applicant, on_delete=models.CASCADE)
# applicant = models.OneToOneField(Applicant, on_delete=models.CASCADE)
applicant = models.ForeignKey(Applicant, on_delete = models.CASCADE, related_name='+', blank=False, null = False)
8 changes: 6 additions & 2 deletions backend/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,19 @@ def interview_session_create(request, agent_id):
return Response({"detail": "Email is missing"}, status=status.HTTP_403_FORBIDDEN)

with transaction.atomic():
applicant, _ = Applicant.objects.get_or_create(email = user_email, name = first_name)
applicant, _ = Applicant.objects.get_or_create(email = user_email)
print(applicant)
applicant.name = first_name
applicant.save()

session, session_created = Session.objects.get_or_create(order=order, applicant=applicant)
session.ready = False
session.save()

if session_created:
greeting = order.agent.behaviour.agent_greeting
else:
greeting = f"Hello again, {session.order.identity.agent_name} here. I am your interviewer and you and I have an open interview session. Shall we continue?"
greeting = f"Hello again, {session.order.agent.identity.agent_name} here. I am your interviewer and you and I have an open interview session. Shall we continue?"
session.get_just_happend = True
session.ready = False
session.last_info_msg_ai = greeting
Expand Down

0 comments on commit 9a3cf69

Please sign in to comment.