Spaces:
Sleeping
Sleeping
File size: 1,380 Bytes
f11bdb0 348670d f11bdb0 028fc71 f11bdb0 028fc71 d13c70b 7058005 f11bdb0 d3fc9db 4d391cb d3fc9db f11bdb0 7058005 f11bdb0 5344fa0 f11bdb0 48fc6d8 f11bdb0 696d098 f11bdb0 37e2bea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
class State:
def __init__(self):
self.context = "This Adrega component is designed to answer questions provided by API"
self.question = "What does this component do?"
state = State()
js = "window.onMessage = (event) => {alert('Test message received: ')}"
def update_values(context, question):
output = context + "\n" + question
state.context = context
state.question = question
return output
def process_message(message):
# Handle incoming messages
state.context = message
return message
with gr.Blocks(js=js) as demo:
with gr.Row():
project_data = gr.Textbox(
label="Project Data",
lines=2,
value=state.context,
elem_id="project_data"
)
question = gr.Textbox(
label="Question",
lines=2,
value=state.question,
elem_id="question"
)
output = gr.Textbox(
label="Output",
elem_id="output"
)
# Add interface for update_values function
update_btn = gr.Button("Update Values")
update_btn.click(
fn=update_values,
inputs=[project_data, question],
outputs=output
)
# Launch the app
demo.launch(
server_name="0.0.0.0",
share=True,
allowed_paths=["*"] # Be careful with this in production
) |