SamerKharboush commited on
Commit
0a171c5
1 Parent(s): 71f4987

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -45
app.py CHANGED
@@ -55,7 +55,7 @@ else:
55
  if auth[_]["username"] and auth[_]["password"]:
56
  auth_list.append((auth[_]["username"], auth[_]["password"]))
57
  else:
58
- logging.error("请检查auth.json文件中的用户名和密码!")
59
  sys.exit(1)
60
 
61
  gr.Chatbot.postprocess = postprocess
@@ -71,12 +71,12 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
71
  user_api_key = gr.State(my_api_key)
72
  user_question = gr.State("")
73
  outputing = gr.State(False)
74
- topic = gr.State("未命名对话历史记录")
75
 
76
  with gr.Row():
77
  with gr.Column(scale=1):
78
  # gr.HTML(title)
79
- gr.HTML('<h1>YY专用ChatGPT</h1>')
80
  with gr.Column(scale=4):
81
  # gr.HTML('<center><a href="https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>')
82
  pass
@@ -90,19 +90,19 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
90
  with gr.Row():
91
  with gr.Column(scale=12):
92
  user_input = gr.Textbox(
93
- show_label=False, placeholder="在这里输入"
94
  ).style(container=False)
95
  with gr.Column(min_width=70, scale=1):
96
- submitBtn = gr.Button("发送", variant="primary")
97
- cancelBtn = gr.Button("取消", variant="secondary", visible=False)
98
  with gr.Row():
99
  emptyBtn = gr.Button(
100
- "🧹 新的对话",
101
  )
102
- retryBtn = gr.Button("🔄 重新生成")
103
- delFirstBtn = gr.Button("🗑️ 删除最旧对话")
104
- delLastBtn = gr.Button("🗑️ 删除最新对话")
105
- reduceTokenBtn = gr.Button("♻️ 总结对话")
106
 
107
  with gr.Column():
108
  with gr.Column(min_width=50, scale=1):
@@ -115,46 +115,46 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
115
  visible=not HIDE_MY_KEY,
116
  label="API-Key",
117
  )
118
- usageTxt = gr.Markdown("**发送消息** **提交key** 以显示额度", elem_id="usage_display")
119
  model_select_dropdown = gr.Dropdown(
120
- label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0]
121
  )
122
  use_streaming_checkbox = gr.Checkbox(
123
- label="实时传输回答", value=True, visible=enable_streaming_option
124
  )
125
- use_websearch_checkbox = gr.Checkbox(label="使用在线搜索", value=False)
126
  language_select_dropdown = gr.Dropdown(
127
- label="选择回复语言(针对搜索&索引功能)",
128
  choices=REPLY_LANGUAGES,
129
  multiselect=False,
130
  value=REPLY_LANGUAGES[0],
131
  )
132
- index_files = gr.Files(label="上传索引文件", type="file", multiple=True)
133
 
134
  with gr.Tab(label="Prompt"):
135
  systemPromptTxt = gr.Textbox(
136
  show_label=True,
137
- placeholder=f"在这里输入System Prompt...",
138
  label="System prompt",
139
  value=initial_prompt,
140
  lines=10,
141
  ).style(container=False)
142
- with gr.Accordion(label="加载Prompt模板", open=True):
143
  with gr.Column():
144
  with gr.Row():
145
  with gr.Column(scale=6):
146
  templateFileSelectDropdown = gr.Dropdown(
147
- label="选择Prompt模板集合文件",
148
  choices=get_template_names(plain=True),
149
  multiselect=False,
150
  value=get_template_names(plain=True)[0],
151
  ).style(container=False)
152
  with gr.Column(scale=1):
153
- templateRefreshBtn = gr.Button("🔄 刷新")
154
  with gr.Row():
155
  with gr.Column():
156
  templateSelectDropdown = gr.Dropdown(
157
- label="Prompt模板中加载",
158
  choices=load_template(
159
  get_template_names(plain=True)[0], mode=1
160
  ),
@@ -164,40 +164,40 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
164
  )[0],
165
  ).style(container=False)
166
 
167
- with gr.Tab(label="保存/加载"):
168
- with gr.Accordion(label="保存/加载对话历史记录", open=True):
169
  with gr.Column():
170
  with gr.Row():
171
  with gr.Column(scale=6):
172
  historyFileSelectDropdown = gr.Dropdown(
173
- label="从列表中加载对话",
174
  choices=get_history_names(plain=True),
175
  multiselect=False,
176
  value=get_history_names(plain=True)[0],
177
  )
178
  with gr.Column(scale=1):
179
- historyRefreshBtn = gr.Button("🔄 刷新")
180
  with gr.Row():
181
  with gr.Column(scale=6):
182
  saveFileName = gr.Textbox(
183
  show_label=True,
184
- placeholder=f"设置文件名: 默认为.json,可选为.md",
185
- label="设置保存文件名",
186
- value="对话历史记录",
187
  ).style(container=True)
188
  with gr.Column(scale=1):
189
- saveHistoryBtn = gr.Button("💾 保存对话")
190
- exportMarkdownBtn = gr.Button("📝 导出为Markdown")
191
- gr.Markdown("默认保存于history文件夹")
192
  with gr.Row():
193
  with gr.Column():
194
  downloadFile = gr.File(interactive=True)
195
 
196
- with gr.Tab(label="高级"):
197
- gr.Markdown("# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置")
198
- default_btn = gr.Button("🔙 恢复默认设置")
199
 
200
- with gr.Accordion("参数", open=False):
201
  top_p = gr.Slider(
202
  minimum=-0,
203
  maximum=1.0,
@@ -215,23 +215,23 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
215
  label="Temperature",
216
  )
217
 
218
- with gr.Accordion("网络设置", open=False, visible=False):
219
  apiurlTxt = gr.Textbox(
220
  show_label=True,
221
- placeholder=f"在这里输入API地址...",
222
- label="API地址",
223
  value="https://api.openai.com/v1/chat/completions",
224
  lines=2,
225
  )
226
- changeAPIURLBtn = gr.Button("🔄 切换API地址")
227
  proxyTxt = gr.Textbox(
228
  show_label=True,
229
- placeholder=f"在这里输入代理地址...",
230
- label="代理地址(示例:http://127.0.0.1:10809)",
231
  value="",
232
  lines=2,
233
  )
234
- changeProxyBtn = gr.Button("🔄 设置代理地址")
235
 
236
  gr.Markdown(description)
237
  gr.HTML(footer.format(versions=versions_html()), elem_id="footer")
@@ -412,11 +412,11 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
412
 
413
  logging.info(
414
  colorama.Back.GREEN
415
- + "\n温馨提示:访问 http://localhost:7860 查看界面"
416
  + colorama.Style.RESET_ALL
417
  )
418
  # 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
419
- demo.title = "YY的专用ChatGPT"
420
 
421
  if __name__ == "__main__":
422
  reload_javascript()
 
55
  if auth[_]["username"] and auth[_]["password"]:
56
  auth_list.append((auth[_]["username"], auth[_]["password"]))
57
  else:
58
+ logging.error("Please check the username and password in the auth.json file!")
59
  sys.exit(1)
60
 
61
  gr.Chatbot.postprocess = postprocess
 
71
  user_api_key = gr.State(my_api_key)
72
  user_question = gr.State("")
73
  outputing = gr.State(False)
74
+ topic = gr.State("Conversation history is not named")
75
 
76
  with gr.Row():
77
  with gr.Column(scale=1):
78
  # gr.HTML(title)
79
+ gr.HTML('<h1>SamGPT</h1>')
80
  with gr.Column(scale=4):
81
  # gr.HTML('<center><a href="https://huggingface.co/spaces/JohnSmith9982/ChuanhuChatGPT?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>')
82
  pass
 
90
  with gr.Row():
91
  with gr.Column(scale=12):
92
  user_input = gr.Textbox(
93
+ show_label=False, placeholder="Enter here"
94
  ).style(container=False)
95
  with gr.Column(min_width=70, scale=1):
96
+ submitBtn = gr.Button("Send", variant="primary")
97
+ cancelBtn = gr.Button("Cancel", variant="secondary", visible=False)
98
  with gr.Row():
99
  emptyBtn = gr.Button(
100
+ "🧹 New conversations",
101
  )
102
+ retryBtn = gr.Button("🔄 Rebuild")
103
+ delFirstBtn = gr.Button("🗑️ Delete the oldest conversation")
104
+ delLastBtn = gr.Button("🗑️ Delete the most recent conversation")
105
+ reduceTokenBtn = gr.Button("♻️ Summarize")
106
 
107
  with gr.Column():
108
  with gr.Column(min_width=50, scale=1):
 
115
  visible=not HIDE_MY_KEY,
116
  label="API-Key",
117
  )
118
+ usageTxt = gr.Markdown("**Send Message** or **Submit Key** to show credit", elem_id="usage_display")
119
  model_select_dropdown = gr.Dropdown(
120
+ label="Select the model", choices=MODELS, multiselect=False, value=MODELS[0]
121
  )
122
  use_streaming_checkbox = gr.Checkbox(
123
+ label="Transmit answers in real time", value=True, visible=enable_streaming_option
124
  )
125
+ use_websearch_checkbox = gr.Checkbox(label="Use online search", value=False)
126
  language_select_dropdown = gr.Dropdown(
127
+ label="Select the reply language (for the Search & Index feature.)",
128
  choices=REPLY_LANGUAGES,
129
  multiselect=False,
130
  value=REPLY_LANGUAGES[0],
131
  )
132
+ index_files = gr.Files(label="Upload the index file", type="file", multiple=True)
133
 
134
  with gr.Tab(label="Prompt"):
135
  systemPromptTxt = gr.Textbox(
136
  show_label=True,
137
+ placeholder=f"Enter here System Prompt...",
138
  label="System prompt",
139
  value=initial_prompt,
140
  lines=10,
141
  ).style(container=False)
142
+ with gr.Accordion(label="Load the Prompt template", open=True):
143
  with gr.Column():
144
  with gr.Row():
145
  with gr.Column(scale=6):
146
  templateFileSelectDropdown = gr.Dropdown(
147
+ label="Select the Prompt template collection file",
148
  choices=get_template_names(plain=True),
149
  multiselect=False,
150
  value=get_template_names(plain=True)[0],
151
  ).style(container=False)
152
  with gr.Column(scale=1):
153
+ templateRefreshBtn = gr.Button("🔄 flushed")
154
  with gr.Row():
155
  with gr.Column():
156
  templateSelectDropdown = gr.Dropdown(
157
+ label="Load from the Prompt template",
158
  choices=load_template(
159
  get_template_names(plain=True)[0], mode=1
160
  ),
 
164
  )[0],
165
  ).style(container=False)
166
 
167
+ with gr.Tab(label="Save/Load"):
168
+ with gr.Accordion(label="Save/load conversation history", open=True):
169
  with gr.Column():
170
  with gr.Row():
171
  with gr.Column(scale=6):
172
  historyFileSelectDropdown = gr.Dropdown(
173
+ label="Load the conversation from the list",
174
  choices=get_history_names(plain=True),
175
  multiselect=False,
176
  value=get_history_names(plain=True)[0],
177
  )
178
  with gr.Column(scale=1):
179
+ historyRefreshBtn = gr.Button("🔄 flushed")
180
  with gr.Row():
181
  with gr.Column(scale=6):
182
  saveFileName = gr.Textbox(
183
  show_label=True,
184
+ placeholder=f"Set the file name: The default is.json,Optional.md",
185
+ label="Set the save file name",
186
+ value="Conversation history",
187
  ).style(container=True)
188
  with gr.Column(scale=1):
189
+ saveHistoryBtn = gr.Button("💾 Save the conversation")
190
+ exportMarkdownBtn = gr.Button("📝 Export as Markdown")
191
+ gr.Markdown("By default, it is saved in the history folder")
192
  with gr.Row():
193
  with gr.Column():
194
  downloadFile = gr.File(interactive=True)
195
 
196
+ with gr.Tab(label="Senior"):
197
+ gr.Markdown("# ⚠️ Be sure to change it with caution ⚠️\n\nIf it is not available, restore the default settings")
198
+ default_btn = gr.Button("🔙 Restore the default settings")
199
 
200
+ with gr.Accordion("parameter", open=False):
201
  top_p = gr.Slider(
202
  minimum=-0,
203
  maximum=1.0,
 
215
  label="Temperature",
216
  )
217
 
218
+ with gr.Accordion("Network settings", open=False, visible=False):
219
  apiurlTxt = gr.Textbox(
220
  show_label=True,
221
+ placeholder=f"Enter the API address here...",
222
+ label="API address",
223
  value="https://api.openai.com/v1/chat/completions",
224
  lines=2,
225
  )
226
+ changeAPIURLBtn = gr.Button("🔄 Switch the API address")
227
  proxyTxt = gr.Textbox(
228
  show_label=True,
229
+ placeholder=f"Enter the proxy address here...",
230
+ label="Proxy address (Example:http://127.0.0.1:10809)",
231
  value="",
232
  lines=2,
233
  )
234
+ changeProxyBtn = gr.Button("🔄 Set the proxy address")
235
 
236
  gr.Markdown(description)
237
  gr.HTML(footer.format(versions=versions_html()), elem_id="footer")
 
412
 
413
  logging.info(
414
  colorama.Back.GREEN
415
+ + "\nTips: Visit http://localhost:7860 to view the interface"
416
  + colorama.Style.RESET_ALL
417
  )
418
  # 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
419
+ demo.title = "SamGPT"
420
 
421
  if __name__ == "__main__":
422
  reload_javascript()