Chuan Hu commited on
Commit
d593331
·
unverified ·
2 Parent(s): d260cf4 82a9b9c

Merge pull request #24 from MZhao-ouo/main

Browse files
Files changed (1) hide show
  1. ChuanhuChatbot.py +8 -1
ChuanhuChatbot.py CHANGED
@@ -16,6 +16,13 @@ if my_api_key == "empty":
16
  print("Please give a api key!")
17
  sys.exit(1)
18
 
 
 
 
 
 
 
 
19
  def parse_text(text):
20
  lines = text.split("\n")
21
  for i,line in enumerate(lines):
@@ -174,7 +181,7 @@ def set_apikey(new_api_key, myKey):
174
 
175
 
176
  with gr.Blocks() as demo:
177
- keyTxt = gr.Textbox(show_label=True, placeholder=f"在这里输入你的API-key...", value=str(my_api_key[:4] + "..." + my_api_key[-4:]), label="API Key").style(container=True)
178
  chatbot = gr.Chatbot().style(color_map=("#1D51EE", "#585A5B"))
179
  context = gr.State([])
180
  systemPrompt = gr.State(update_system(initial_prompt))
 
16
  print("Please give a api key!")
17
  sys.exit(1)
18
 
19
+ if my_api_key == "":
20
+ initial_keytxt = None
21
+ elif len(str(my_api_key)) == 51:
22
+ initial_keytxt = "默认api-key(未验证):" + str(my_api_key[:4] + "..." + my_api_key[-4:])
23
+ else:
24
+ initial_keytxt = "默认api-key无效,请重新输入"
25
+
26
  def parse_text(text):
27
  lines = text.split("\n")
28
  for i,line in enumerate(lines):
 
181
 
182
 
183
  with gr.Blocks() as demo:
184
+ keyTxt = gr.Textbox(show_label=True, placeholder=f"在这里输入你的OpenAI API-key...", value=initial_keytxt, label="API Key").style(container=True)
185
  chatbot = gr.Chatbot().style(color_map=("#1D51EE", "#585A5B"))
186
  context = gr.State([])
187
  systemPrompt = gr.State(update_system(initial_prompt))