kavansaun commited on
Commit
6e6dedd
·
verified ·
1 Parent(s): fb7139f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -6,11 +6,18 @@ import uuid
6
 
7
  # Create UI using gradio
8
  with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}") as chatblock:
 
 
 
 
 
 
9
 
10
- def create_id():
11
- id = str(uuid.uuid4())
12
- return id
13
-
 
14
  gr.Markdown(f"<h1><center> Session id: {create_id()} </enter></h1>")
15
 
16
  initial_message = "Please write your prompt here and press 'enter'"
 
6
 
7
  # Create UI using gradio
8
  with gr.Blocks(theme=gr.themes.Monochrome(),css="footer{display:none !important}") as chatblock:
9
+ user_id = gr.Textbox(label="Here is the id textbox", visible=False)
10
+ local_storage = gr.BrowserState([""])
11
+
12
+ @demo.load(outputs=[user_id])
13
+ def generate_id():
14
+ return str(uuid.uuid4())
15
 
16
+ @demo.load(inputs=[local_storage], outputs=[user_id])
17
+ def load_from_local_storage(saved_value):
18
+ print("here is the id", saved_value)
19
+ return saved_value
20
+
21
  gr.Markdown(f"<h1><center> Session id: {create_id()} </enter></h1>")
22
 
23
  initial_message = "Please write your prompt here and press 'enter'"