Denysyk commited on
Commit
5a5c4a3
·
verified ·
1 Parent(s): 54009c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -16,7 +16,7 @@ def init_exam(api_key: str):
16
  if not api_key.strip():
17
  return [{
18
  "role": "assistant",
19
- "content": "⚠️ Please enter your Groq API key first."
20
  }], gr.update(interactive=False)
21
 
22
  try:
@@ -25,7 +25,7 @@ def init_exam(api_key: str):
25
  return [{"role": "assistant", "content": opening}], gr.update(interactive=True)
26
  except Exception as e:
27
  _agent = None
28
- return [{"role": "assistant", "content": f"Error initialising agent: {e}"}], gr.update(interactive=False)
29
 
30
 
31
  def user_message(message: str, history: list):
@@ -38,14 +38,14 @@ def user_message(message: str, history: list):
38
  if _agent is None:
39
  return history + [
40
  {"role": "user", "content": message},
41
- {"role": "assistant", "content": "⚠️ Please click **Start Exam** first."},
42
  ], ""
43
 
44
  # Block messages after exam is finished
45
  if _agent.exam_finished:
46
  return history + [
47
  {"role": "user", "content": message},
48
- {"role": "assistant", "content": "The exam is already finished. Click **▶ Start Exam** to start a new session."},
49
  ], ""
50
 
51
  history = history + [{"role": "user", "content": message}]
@@ -53,7 +53,7 @@ def user_message(message: str, history: list):
53
  try:
54
  reply = _agent.chat(message)
55
  except Exception as e:
56
- reply = f"Agent error: {e}"
57
 
58
  history = history + [{"role": "assistant", "content": reply}]
59
  return history, ""
@@ -138,7 +138,6 @@ with gr.Blocks(title="AI Examiner Agent") as demo:
138
  <br><br>
139
  <strong>Demo students</strong><br>
140
  test@test.com / test<br>
141
- denys.kovalenko@student.lpnu.ua
142
  </div>
143
  """)
144
 
 
16
  if not api_key.strip():
17
  return [{
18
  "role": "assistant",
19
+ "content": "Please enter your Groq API key first."
20
  }], gr.update(interactive=False)
21
 
22
  try:
 
25
  return [{"role": "assistant", "content": opening}], gr.update(interactive=True)
26
  except Exception as e:
27
  _agent = None
28
+ return [{"role": "assistant", "content": f"Error initialising agent: {e}"}], gr.update(interactive=False)
29
 
30
 
31
  def user_message(message: str, history: list):
 
38
  if _agent is None:
39
  return history + [
40
  {"role": "user", "content": message},
41
+ {"role": "assistant", "content": "Please click **Start Exam** first."},
42
  ], ""
43
 
44
  # Block messages after exam is finished
45
  if _agent.exam_finished:
46
  return history + [
47
  {"role": "user", "content": message},
48
+ {"role": "assistant", "content": "The exam is already finished. Click **▶ Start Exam** to start a new session."},
49
  ], ""
50
 
51
  history = history + [{"role": "user", "content": message}]
 
53
  try:
54
  reply = _agent.chat(message)
55
  except Exception as e:
56
+ reply = f"Agent error: {e}"
57
 
58
  history = history + [{"role": "assistant", "content": reply}]
59
  return history, ""
 
138
  <br><br>
139
  <strong>Demo students</strong><br>
140
  test@test.com / test<br>
 
141
  </div>
142
  """)
143