IliaLarchenko commited on
Commit
f035eac
1 Parent(s): 04c9587

Added demo word limit

Browse files
Files changed (1) hide show
  1. api/llm.py +8 -6
api/llm.py CHANGED
@@ -10,6 +10,8 @@ class LLMManager:
10
  self.config = config
11
  self.client = OpenAI(base_url=config.llm.url, api_key=config.llm.key)
12
  self.prompts = prompts
 
 
13
 
14
  def test_connection(self):
15
  try:
@@ -29,8 +31,8 @@ class LLMManager:
29
 
30
  def init_bot(self, problem=""):
31
  system_prompt = self.prompts["coding_interviewer_prompt"]
32
- if os.getenv("IS_DEMO"):
33
- system_prompt += " Keep your responses very short and simple, no more than 100 words."
34
 
35
  return [
36
  {"role": "system", "content": system_prompt},
@@ -45,8 +47,8 @@ class LLMManager:
45
  "Ensure the problem varies each time to provide a wide range of challenges."
46
  )
47
 
48
- if os.getenv("IS_DEMO"):
49
- full_prompt += " Keep your response very short and simple, no more than 200 words."
50
 
51
  try:
52
  response = self.client.chat.completions.create(
@@ -95,8 +97,8 @@ class LLMManager:
95
  transcript = [f"{message['role'].capitalize()}: {message['content']}" for message in chat_history[1:]]
96
 
97
  system_prompt = self.prompts["grading_feedback_prompt"]
98
- if os.getenv("IS_DEMO"):
99
- system_prompt += " Keep your response very short and simple, no more than 200 words."
100
 
101
  try:
102
  response = self.client.chat.completions.create(
 
10
  self.config = config
11
  self.client = OpenAI(base_url=config.llm.url, api_key=config.llm.key)
12
  self.prompts = prompts
13
+ self.is_demo = os.getenv("IS_DEMO")
14
+ self.demo_word_limit = os.getenv("DEMO_WORD_LIMIT")
15
 
16
  def test_connection(self):
17
  try:
 
31
 
32
  def init_bot(self, problem=""):
33
  system_prompt = self.prompts["coding_interviewer_prompt"]
34
+ if self.is_demo:
35
+ system_prompt += f" Keep your responses very short and simple, no more than {self.demo_word_limit} words."
36
 
37
  return [
38
  {"role": "system", "content": system_prompt},
 
47
  "Ensure the problem varies each time to provide a wide range of challenges."
48
  )
49
 
50
+ if self.is_demo:
51
+ full_prompt += f" Keep your response very short and simple, no more than {self.demo_word_limit} words."
52
 
53
  try:
54
  response = self.client.chat.completions.create(
 
97
  transcript = [f"{message['role'].capitalize()}: {message['content']}" for message in chat_history[1:]]
98
 
99
  system_prompt = self.prompts["grading_feedback_prompt"]
100
+ if self.is_demo:
101
+ system_prompt += f" Keep your response very short and simple, no more than {self.demo_word_limit} words."
102
 
103
  try:
104
  response = self.client.chat.completions.create(