Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 11 |
-
|
| 12 |
-
|
| 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'"
|