Spaces:
Runtime error
Runtime error
SamerKharboush
commited on
Commit
•
0a171c5
1
Parent(s):
71f4987
Update app.py
Browse files
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("
|
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>
|
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("
|
97 |
-
cancelBtn = gr.Button("
|
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("
|
119 |
model_select_dropdown = gr.Dropdown(
|
120 |
-
label="
|
121 |
)
|
122 |
use_streaming_checkbox = gr.Checkbox(
|
123 |
-
label="
|
124 |
)
|
125 |
-
use_websearch_checkbox = gr.Checkbox(label="
|
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="
|
133 |
|
134 |
with gr.Tab(label="Prompt"):
|
135 |
systemPromptTxt = gr.Textbox(
|
136 |
show_label=True,
|
137 |
-
placeholder=f"
|
138 |
label="System prompt",
|
139 |
value=initial_prompt,
|
140 |
lines=10,
|
141 |
).style(container=False)
|
142 |
-
with gr.Accordion(label="
|
143 |
with gr.Column():
|
144 |
with gr.Row():
|
145 |
with gr.Column(scale=6):
|
146 |
templateFileSelectDropdown = gr.Dropdown(
|
147 |
-
label="
|
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="
|
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="
|
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"
|
185 |
-
label="
|
186 |
-
value="
|
187 |
).style(container=True)
|
188 |
with gr.Column(scale=1):
|
189 |
-
saveHistoryBtn = gr.Button("💾
|
190 |
-
exportMarkdownBtn = gr.Button("📝
|
191 |
-
gr.Markdown("
|
192 |
with gr.Row():
|
193 |
with gr.Column():
|
194 |
downloadFile = gr.File(interactive=True)
|
195 |
|
196 |
-
with gr.Tab(label="
|
197 |
-
gr.Markdown("# ⚠️
|
198 |
-
default_btn = gr.Button("🔙
|
199 |
|
200 |
-
with gr.Accordion("
|
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("
|
219 |
apiurlTxt = gr.Textbox(
|
220 |
show_label=True,
|
221 |
-
placeholder=f"
|
222 |
-
label="API
|
223 |
value="https://api.openai.com/v1/chat/completions",
|
224 |
lines=2,
|
225 |
)
|
226 |
-
changeAPIURLBtn = gr.Button("🔄
|
227 |
proxyTxt = gr.Textbox(
|
228 |
show_label=True,
|
229 |
-
placeholder=f"
|
230 |
-
label="
|
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 |
-
+ "\
|
416 |
+ colorama.Style.RESET_ALL
|
417 |
)
|
418 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
419 |
-
demo.title = "
|
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()
|