chengzhiedu commited on
Commit
c87676b
·
1 Parent(s): c2ab585

chore(ui): modefied theme, error message and placeholder

Browse files
Files changed (3) hide show
  1. app/main.py +15 -12
  2. app/ui/components.py +3 -2
  3. app/utils/utils.py +5 -5
app/main.py CHANGED
@@ -164,7 +164,8 @@ with gr.Blocks(
164
  }, 1000);
165
  </script>
166
  """,
167
- analytics_enabled=False # Add this
 
168
  ) as demo:
169
  # password UI popup
170
  with gr.Group(visible=True) as password_popup:
@@ -214,17 +215,19 @@ with gr.Blocks(
214
  outputs=[chatbot, textbox, hidden_list, prompt_input]
215
  )
216
 
217
- quick_response.click(
218
- response_handler.handle_quick_response_click,
219
- quick_response,
220
- prompt_input
221
- )
222
-
223
- hidden_list.change(
224
- response_handler.handle_quick_response_samples,
225
- hidden_list,
226
- quick_response
227
- )
 
 
228
 
229
  # Update chat selector when page loads
230
  demo.load(
 
164
  }, 1000);
165
  </script>
166
  """,
167
+ analytics_enabled=False, # Add this
168
+ theme=gr.themes.Soft()
169
  ) as demo:
170
  # password UI popup
171
  with gr.Group(visible=True) as password_popup:
 
215
  outputs=[chatbot, textbox, hidden_list, prompt_input]
216
  )
217
 
218
+ # for K camp test path, allow users to start directly
219
+ # quick_response.click(
220
+ # response_handler.handle_quick_response_click,
221
+ # quick_response,
222
+ # prompt_input
223
+ # )
224
+
225
+ # for K camp test path, allow users to start directly
226
+ # hidden_list.change(
227
+ # response_handler.handle_quick_response_samples,
228
+ # hidden_list,
229
+ # quick_response
230
+ # )
231
 
232
  # Update chat selector when page loads
233
  demo.load(
app/ui/components.py CHANGED
@@ -25,7 +25,8 @@ def create_prompt_input() -> gr.Textbox:
25
  label="用戶需求",
26
  submit_btn=True,
27
  render=False,
28
- scale=1
 
29
  )
30
 
31
  def create_quick_response(samples) -> gr.Dataset:
@@ -60,4 +61,4 @@ def create_hidden_list() -> gr.JSON:
60
  value=[[]],
61
  render=False,
62
  visible=False
63
- )
 
25
  label="用戶需求",
26
  submit_btn=True,
27
  render=False,
28
+ scale=1,
29
+ placeholder="請輸入您的問題"
30
  )
31
 
32
  def create_quick_response(samples) -> gr.Dataset:
 
61
  value=[[]],
62
  render=False,
63
  visible=False
64
+ )
app/utils/utils.py CHANGED
@@ -11,19 +11,19 @@ def print_assistant_info(assistant):
11
  """Print key information about an assistant object."""
12
  # Get model
13
  model = assistant.model
14
-
15
  # Get description (limited to 2 lines)
16
  desc_lines = assistant.description.split('\n')[:2]
17
  desc = '\n'.join(desc_lines)
18
  if len(desc) > 150: # Truncate if too long
19
  desc = desc[:147] + "..."
20
-
21
  # Get instructions (limited to 2 lines)
22
  instr_lines = assistant.instructions.split('\n')[:2]
23
  instr = '\n'.join(instr_lines)
24
  if len(instr) > 150: # Truncate if too long
25
  instr = instr[:147] + "..."
26
-
27
  # Print information
28
  print(f"Assistant ID: {assistant.id}")
29
  print(f"Name: {assistant.name}")
@@ -33,9 +33,9 @@ def print_assistant_info(assistant):
33
  print(f"Tools: {[tool.type for tool in assistant.tools]}")
34
  print(f"Response Format: {assistant.response_format}")
35
  print(f"Created at: {assistant.created_at}")
36
-
37
  def check_password(username, input_password):
38
  if input_password == CORRECT_PASSWORD:
39
  return gr.update(visible=False), gr.update(visible=True), "", username
40
  else:
41
- return gr.update(visible=True), gr.update(visible=False), gr.update(value="密码错误。hint: channel name", visible=True), username
 
11
  """Print key information about an assistant object."""
12
  # Get model
13
  model = assistant.model
14
+
15
  # Get description (limited to 2 lines)
16
  desc_lines = assistant.description.split('\n')[:2]
17
  desc = '\n'.join(desc_lines)
18
  if len(desc) > 150: # Truncate if too long
19
  desc = desc[:147] + "..."
20
+
21
  # Get instructions (limited to 2 lines)
22
  instr_lines = assistant.instructions.split('\n')[:2]
23
  instr = '\n'.join(instr_lines)
24
  if len(instr) > 150: # Truncate if too long
25
  instr = instr[:147] + "..."
26
+
27
  # Print information
28
  print(f"Assistant ID: {assistant.id}")
29
  print(f"Name: {assistant.name}")
 
33
  print(f"Tools: {[tool.type for tool in assistant.tools]}")
34
  print(f"Response Format: {assistant.response_format}")
35
  print(f"Created at: {assistant.created_at}")
36
+
37
  def check_password(username, input_password):
38
  if input_password == CORRECT_PASSWORD:
39
  return gr.update(visible=False), gr.update(visible=True), "", username
40
  else:
41
+ return gr.update(visible=True), gr.update(visible=False), gr.update(value="密碼錯誤。hint: channel name", visible=True), username