sanbo commited on
Commit
0dcbf45
·
1 Parent(s): f4bda8e

update sth. at 2024-11-18 23:50:10

Browse files
Files changed (1) hide show
  1. app.py +38 -3
app.py CHANGED
@@ -83,14 +83,49 @@ def build_interface():
83
  """
84
  构建 Gradio 界面布局,包括文本聊天、chatgpt-4o-mini 和图像生成模块。
85
  """
86
- with gr.Blocks(css=".gradio-container {background-color: #f0f4f8; font-family: Arial, sans-serif;}") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  gr.Markdown("<h1 style='text-align: center; color: #4A90E2;'>智能助手</h1>")
88
  status_output = gr.Textbox(label="服务状态", value=service_status, interactive=False, elem_id="status_output")
89
 
90
  # 文本聊天模块
91
  with gr.Tab("Llama3.2-11B"):
92
  chatbox_input = gr.Textbox(label="输入你的问题", placeholder="请提问...", elem_id="chatbox_input")
93
- chatbox_output = gr.Textbox(label="回答", interactive=False, elem_id="chatbox_output")
94
  chatbox_button = gr.Button("发送", elem_id="chatbox_button")
95
 
96
  def chat_handler(user_input):
@@ -103,7 +138,7 @@ def build_interface():
103
  with gr.Tab("gpt4o"):
104
  system_prompt_input = gr.Textbox(label="自定义系统提示词", placeholder="输入系统提示词...", elem_id="system_prompt_input")
105
  chatgpt_input = gr.Textbox(label="输入你的问题", placeholder="请提问...", elem_id="chatgpt_input")
106
- chatgpt_output = gr.Textbox(label="回答", interactive=False, elem_id="chatgpt_output")
107
  chatgpt_button = gr.Button("发送", elem_id="chatgpt_button")
108
 
109
  def chatgpt_handler(system_prompt, user_input):
 
83
  """
84
  构建 Gradio 界面布局,包括文本聊天、chatgpt-4o-mini 和图像生成模块。
85
  """
86
+ with gr.Blocks(css="""
87
+ @media (prefers-color-scheme: dark) {
88
+ .gradio-container {
89
+ background-color: #1e1e1e;
90
+ color: #ffffff;
91
+ font-family: Arial, sans-serif;
92
+ }
93
+ .tab-title {
94
+ color: #ffffff;
95
+ }
96
+ .gr-button {
97
+ background-color: #4A90E2;
98
+ color: white;
99
+ }
100
+ .gr-button:hover {
101
+ background-color: #357ABD;
102
+ }
103
+ }
104
+ @media (prefers-color-scheme: light) {
105
+ .gradio-container {
106
+ background-color: #ffffff;
107
+ color: #000000;
108
+ font-family: Arial, sans-serif;
109
+ }
110
+ .tab-title {
111
+ color: #000000;
112
+ }
113
+ .gr-button {
114
+ background-color: #4A90E2;
115
+ color: white;
116
+ }
117
+ .gr-button:hover {
118
+ background-color: #357ABD;
119
+ }
120
+ }
121
+ """) as demo:
122
  gr.Markdown("<h1 style='text-align: center; color: #4A90E2;'>智能助手</h1>")
123
  status_output = gr.Textbox(label="服务状态", value=service_status, interactive=False, elem_id="status_output")
124
 
125
  # 文本聊天模块
126
  with gr.Tab("Llama3.2-11B"):
127
  chatbox_input = gr.Textbox(label="输入你的问题", placeholder="请提问...", elem_id="chatbox_input")
128
+ chatbox_output = gr.Markdown(label="回答", interactive=False, elem_id="chatbox_output") # 使用 Markdown 输出
129
  chatbox_button = gr.Button("发送", elem_id="chatbox_button")
130
 
131
  def chat_handler(user_input):
 
138
  with gr.Tab("gpt4o"):
139
  system_prompt_input = gr.Textbox(label="自定义系统提示词", placeholder="输入系统提示词...", elem_id="system_prompt_input")
140
  chatgpt_input = gr.Textbox(label="输入你的问题", placeholder="请提问...", elem_id="chatgpt_input")
141
+ chatgpt_output = gr.Markdown(label="回答", interactive=False, elem_id="chatgpt_output") # 使用 Markdown 输出
142
  chatgpt_button = gr.Button("发送", elem_id="chatgpt_button")
143
 
144
  def chatgpt_handler(system_prompt, user_input):