IliaLarchenko commited on
Commit
4e6ea87
1 Parent(s): 83031e2

Simplified demo logic

Browse files
Files changed (2) hide show
  1. api/llm.py +17 -2
  2. docs/instruction.py +5 -5
api/llm.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  from openai import OpenAI
2
 
3
 
@@ -19,8 +21,13 @@ class LLMManager:
19
  return response.choices[0].message.content.strip()
20
 
21
  def init_bot(self, problem=""):
 
 
 
 
 
22
  chat_history = [
23
- {"role": "system", "content": self.prompts["coding_interviewer_prompt"]},
24
  {"role": "system", "content": f"The candidate is solving the following problem: {problem}"},
25
  ]
26
  return chat_history
@@ -32,6 +39,10 @@ class LLMManager:
32
  "The problem should be clearly stated, well-formatted, and solvable within 30 minutes. "
33
  "Ensure the problem varies each time to provide a wide range of challenges."
34
  )
 
 
 
 
35
  response = self.client.chat.completions.create(
36
  model=self.config.llm.name,
37
  messages=[
@@ -74,10 +85,14 @@ class LLMManager:
74
  content = f"{role.capitalize()}: {message['content']}"
75
  transcript.append(content)
76
 
 
 
 
 
77
  response = self.client.chat.completions.create(
78
  model=self.config.llm.name,
79
  messages=[
80
- {"role": "system", "content": self.prompts["grading_feedback_prompt"]},
81
  {"role": "user", "content": f"The original problem to solve: {problem_description}"},
82
  {"role": "user", "content": "\n\n".join(transcript)},
83
  {"role": "user", "content": "Grade the interview based on the transcript provided and give feedback."},
 
1
+ import os
2
+
3
  from openai import OpenAI
4
 
5
 
 
21
  return response.choices[0].message.content.strip()
22
 
23
  def init_bot(self, problem=""):
24
+
25
+ system_prompt = self.prompts["coding_interviewer_prompt"]
26
+ if os.getenv("IS_DEMO"):
27
+ system_prompt += " Keep your responses very short and simple, no more than 100 words."
28
+
29
  chat_history = [
30
+ {"role": "system", "content": system_prompt},
31
  {"role": "system", "content": f"The candidate is solving the following problem: {problem}"},
32
  ]
33
  return chat_history
 
39
  "The problem should be clearly stated, well-formatted, and solvable within 30 minutes. "
40
  "Ensure the problem varies each time to provide a wide range of challenges."
41
  )
42
+
43
+ if os.getenv("IS_DEMO"):
44
+ full_prompt += " Keep your response very short and simple, no more than 200 words."
45
+
46
  response = self.client.chat.completions.create(
47
  model=self.config.llm.name,
48
  messages=[
 
85
  content = f"{role.capitalize()}: {message['content']}"
86
  transcript.append(content)
87
 
88
+ system_prompt = self.prompts["grading_feedback_prompt"]
89
+ if os.getenv("IS_DEMO"):
90
+ system_prompt += " Keep your response very short and simple, no more than 200 words."
91
+
92
  response = self.client.chat.completions.create(
93
  model=self.config.llm.name,
94
  messages=[
95
+ {"role": "system", "content": system_prompt},
96
  {"role": "user", "content": f"The original problem to solve: {problem_description}"},
97
  {"role": "user", "content": "\n\n".join(transcript)},
98
  {"role": "user", "content": "Grade the interview based on the transcript provided and give feedback."},
docs/instruction.py CHANGED
@@ -2,11 +2,11 @@
2
 
3
  instruction = {
4
  "demo": """
5
- <span style="color: red;">
6
- This is a demo version with limited resources, which may respond slower than usual.
7
- It's primarily for demonstration. For optimal performance, please run it locally and use your own OpenAI key or HuggingFace model.
8
- Read the introduction page, or click on the 'Coding' tab to proceed to the interview interface in demo mode.
9
- </span>
10
  """,
11
  "introduction": """
12
  # Welcome to the AI Tech Interviewer Simulator!
 
2
 
3
  instruction = {
4
  "demo": """
5
+ <span style="color: red;">
6
+ This is a demo version utilizing free API access with strict request limits. As a result, the experience may be slow, occasionally buggy, and not of the highest quality. If a model is unavailable, please wait for a minute before retrying. Persistent unavailability may indicate that the request limit has been reached, making the demo temporarily inaccessible.
7
+ For a significantly better experience, please run the service locally and use your own OpenAI key or HuggingFace model.
8
+ </span>
9
+
10
  """,
11
  "introduction": """
12
  # Welcome to the AI Tech Interviewer Simulator!