Spaces:
Sleeping
Sleeping
Try get input data
Browse files
app.py
CHANGED
|
@@ -7,21 +7,19 @@ def answer_question(project_data, question):
|
|
| 7 |
return answer
|
| 8 |
|
| 9 |
with gr.Blocks() as demo: # Create a Blocks context
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
inputs=["text", "text"],
|
| 13 |
-
outputs="text"
|
| 14 |
-
)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
iface.update(inputs=['test1', 'test2'])
|
| 22 |
|
| 23 |
-
window.addEventListener(
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
| 7 |
return answer
|
| 8 |
|
| 9 |
with gr.Blocks() as demo: # Create a Blocks context
|
| 10 |
+
project_data = gr.Textbox(label="Project Data", lines=2, value=state.context)
|
| 11 |
+
output = gr.Textbox(label="Output")
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
def on_message(event):
|
| 14 |
+
# Update the textbox value based on the received message
|
| 15 |
+
state.context = event.data
|
| 16 |
+
iface.set_value(project_data, value=state.context)
|
| 17 |
+
iface.set_value(output, value=state.context)
|
|
|
|
| 18 |
|
| 19 |
+
iface.js_code("window.addEventListener("message", on_message);)
|
| 20 |
|
| 21 |
+
iface.launch(
|
| 22 |
+
server_name="0.0.0.0", # Allow external connections
|
| 23 |
+
share=True, # Create public URL
|
| 24 |
+
allowed_paths=["*"], #Allow CORS
|
| 25 |
+
)
|