IliaLarchenko commited on
Commit
8d9f6bc
1 Parent(s): 23cd97b

Split LLM answer

Browse files
Files changed (4) hide show
  1. api/audio.py +5 -1
  2. api/llm.py +8 -2
  3. resources/prompts.py +2 -0
  4. ui/coding.py +1 -1
api/audio.py CHANGED
@@ -230,4 +230,8 @@ class TTSManager:
230
  :return: Generator yielding chunks of audio bytes.
231
  """
232
  if len(chat_history) > 0 and chat_history[-1][1]:
233
- yield from self.read_text(chat_history[-1][1])
 
 
 
 
 
230
  :return: Generator yielding chunks of audio bytes.
231
  """
232
  if len(chat_history) > 0 and chat_history[-1][1]:
233
+ n = len(chat_history) - 1
234
+ while n >= 0 and chat_history[n][1]:
235
+ n -= 1
236
+ for i in range(n + 1, len(chat_history)):
237
+ yield from self.read_text(chat_history[i][1])
api/llm.py CHANGED
@@ -130,12 +130,18 @@ class LLMManager:
130
  Send a request to the LLM and update the chat display.
131
  """
132
  chat_history = self.update_chat_history(code, previous_code, chat_history, chat_display)
133
- chat_display.append([None, ""])
134
  chat_history.append({"role": "assistant", "content": ""})
135
  reply = self.get_text(chat_history)
136
  for message in reply:
137
- chat_display[-1][1] = message.split("#NOTES#")[0].strip()
138
  chat_history[-1]["content"] = message
 
 
 
 
 
 
 
139
  yield chat_history, chat_display, code
140
 
141
  def end_interview_prepare_messages(
 
130
  Send a request to the LLM and update the chat display.
131
  """
132
  chat_history = self.update_chat_history(code, previous_code, chat_history, chat_display)
133
+ original_len = len(chat_display)
134
  chat_history.append({"role": "assistant", "content": ""})
135
  reply = self.get_text(chat_history)
136
  for message in reply:
 
137
  chat_history[-1]["content"] = message
138
+ text_to_display = message.split("#NOTES#")[0].strip()
139
+ split_messages = text_to_display.split("\n\n")
140
+ chat_display = chat_display[:original_len]
141
+ for m in split_messages:
142
+ if m.strip():
143
+ chat_display.append([None, m])
144
+
145
  yield chat_history, chat_display, code
146
 
147
  def end_interview_prepare_messages(
resources/prompts.py CHANGED
@@ -27,6 +27,8 @@ You are an AI conducting an interview. Your role is to manage the interview effe
27
  - Make notes when you encounter: mistakes, bugs, incorrect statements, missed important aspects, any other observations.
28
  - There should be no other delimiters in your response. Only #NOTES# is a valid delimiter, everything else will be treated just like text.
29
 
 
 
30
  - You should direct the interview strictly rather than helping the candidate solve the problem.
31
  - Be very concise in your responses. Allow the candidate to lead the discussion, ensuring they speak more than you do.
32
  - Never repeat, rephrase, or summarize candidate responses. Never provide feedback during the interview.
 
27
  - Make notes when you encounter: mistakes, bugs, incorrect statements, missed important aspects, any other observations.
28
  - There should be no other delimiters in your response. Only #NOTES# is a valid delimiter, everything else will be treated just like text.
29
 
30
+ - If you answer is long add double '\n\n' to split it in smaller logical parts, so it will be easier to read for the candidate.
31
+
32
  - You should direct the interview strictly rather than helping the candidate solve the problem.
33
  - Be very concise in your responses. Allow the candidate to lead the discussion, ensuring they speak more than you do.
34
  - Never repeat, rephrase, or summarize candidate responses. Never provide feedback during the interview.
ui/coding.py CHANGED
@@ -110,7 +110,7 @@ def get_problem_solving_ui(llm, tts, stt, default_audio_params, audio_output, na
110
  outputs=[solution_acc, end_btn, audio_input, send_btn],
111
  )
112
 
113
- end_btn.click(
114
  fn=add_interviewer_message(fixed_messages["end"]),
115
  inputs=[chat],
116
  outputs=[chat],
 
110
  outputs=[solution_acc, end_btn, audio_input, send_btn],
111
  )
112
 
113
+ end_btn.click(fn=lambda x: add_candidate_message("Let's stop here.", x), inputs=[chat], outputs=[chat]).success(
114
  fn=add_interviewer_message(fixed_messages["end"]),
115
  inputs=[chat],
116
  outputs=[chat],