Spaces:
Running
Running
UI state recovery
Browse files
app.py
CHANGED
@@ -167,6 +167,8 @@ def export_history(h, s):
|
|
167 |
pass
|
168 |
|
169 |
with gr.Blocks(delete_cache=(86400, 86400)) as demo:
|
|
|
|
|
170 |
gr.Markdown("# Amazon™️ Bedrock™️ Chat™️ (Nils' Version™️) feat. Mistral™️ AI & Anthropic™️ Claude™️")
|
171 |
|
172 |
with gr.Accordion("Startup"):
|
@@ -192,6 +194,46 @@ with gr.Blocks(delete_cache=(86400, 86400)) as demo:
|
|
192 |
dl_settings_button = gr.Button("Download Settings")
|
193 |
ul_settings_button = gr.Button("Upload Settings")
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
load_button.click(load_settings, js="""
|
196 |
() => {
|
197 |
let elems = ['#aws_access textarea', '#aws_secret textarea', '#aws_token textarea', '#system_prompt textarea', '#temp input', '#max_tokens input', '#model', '#region'];
|
|
|
167 |
pass
|
168 |
|
169 |
with gr.Blocks(delete_cache=(86400, 86400)) as demo:
|
170 |
+
settings_state = gr.BrowserState({})
|
171 |
+
|
172 |
gr.Markdown("# Amazon™️ Bedrock™️ Chat™️ (Nils' Version™️) feat. Mistral™️ AI & Anthropic™️ Claude™️")
|
173 |
|
174 |
with gr.Accordion("Startup"):
|
|
|
194 |
dl_settings_button = gr.Button("Download Settings")
|
195 |
ul_settings_button = gr.Button("Upload Settings")
|
196 |
|
197 |
+
@demo.load(inputs=[settings_state],
|
198 |
+
outputs=[aws_access, aws_secret, aws_token, system_prompt,
|
199 |
+
temp, max_tokens, model, region, python_use])
|
200 |
+
def load_from_browser_storage(saved_values):
|
201 |
+
if not saved_values:
|
202 |
+
return (aws_access.value, aws_secret.value, aws_token.value,
|
203 |
+
system_prompt.value, temp.value, max_tokens.value,
|
204 |
+
model.value, region.value, python_use.value)
|
205 |
+
return (saved_values.get('aws_access', aws_access.value),
|
206 |
+
saved_values.get('aws_secret', aws_secret.value),
|
207 |
+
saved_values.get('aws_token', aws_token.value),
|
208 |
+
saved_values.get('system_prompt', system_prompt.value),
|
209 |
+
saved_values.get('temp', temp.value),
|
210 |
+
saved_values.get('max_tokens', max_tokens.value),
|
211 |
+
saved_values.get('model', model.value),
|
212 |
+
saved_values.get('region', region.value),
|
213 |
+
saved_values.get('python_use', python_use.value))
|
214 |
+
|
215 |
+
@gr.on(
|
216 |
+
[aws_access.change, aws_secret.change, aws_token.change,
|
217 |
+
system_prompt.change, temp.change, max_tokens.change,
|
218 |
+
model.change, region.change, python_use.change],
|
219 |
+
inputs=[aws_access, aws_secret, aws_token, system_prompt,
|
220 |
+
temp, max_tokens, model, region, python_use],
|
221 |
+
outputs=[settings_state]
|
222 |
+
)
|
223 |
+
def save_to_browser_storage(acc, sec, tok, prompt, temperature,
|
224 |
+
tokens, mdl, reg, py_use):
|
225 |
+
return {
|
226 |
+
'aws_access': acc,
|
227 |
+
'aws_secret': sec,
|
228 |
+
'aws_token': tok,
|
229 |
+
'system_prompt': prompt,
|
230 |
+
'temp': temperature,
|
231 |
+
'max_tokens': tokens,
|
232 |
+
'model': mdl,
|
233 |
+
'region': reg,
|
234 |
+
'python_use': py_use
|
235 |
+
}
|
236 |
+
|
237 |
load_button.click(load_settings, js="""
|
238 |
() => {
|
239 |
let elems = ['#aws_access textarea', '#aws_secret textarea', '#aws_token textarea', '#system_prompt textarea', '#temp input', '#max_tokens input', '#model', '#region'];
|