GlobalBusinessAdvisors commited on
Commit
ceb5307
1 Parent(s): 77b0cbb

Update ui/gradio_ui.py

Browse files
Files changed (1) hide show
  1. ui/gradio_ui.py +38 -6
ui/gradio_ui.py CHANGED
@@ -1,11 +1,43 @@
1
  import gradio as gr
 
 
2
 
3
- def start_assessment():
4
- return "Welcome to EcoPropertyRetrofitGPT! Begin your property retrofit assessment by answering each question as it appears. Your responses will automatically guide the creation of a comprehensive retrofit plan."
 
 
 
 
 
 
 
5
 
6
  def create_ui():
7
- iface = gr.Interface(fn=start_assessment, inputs=[], outputs="text")
8
- iface.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- if __name__ == "__main__":
11
- create_ui()
 
1
  import gradio as gr
2
+ import httpx
3
+ import asyncio
4
 
5
+ async def async_request(url, params):
6
+ async with httpx.AsyncClient() as client:
7
+ response = await client.get(url, params=params)
8
+ return response.json()
9
+
10
+ async def fetch_data(endpoint, param):
11
+ url = f"https://api.example.com/{endpoint}"
12
+ response = await async_request(url, {"param": param})
13
+ return response
14
 
15
  def create_ui():
16
+ with gr.Blocks() as demo:
17
+ with gr.Tabs():
18
+ with gr.TabItem("Home"):
19
+ gr.Markdown("Welcome to EcoPropertyRetrofitGPT")
20
+
21
+ with gr.TabItem("Data"):
22
+ with gr.Accordion("Fetch Data", open=False):
23
+ param = gr.Textbox(label="Parameter")
24
+ output = gr.JSON(label="Response")
25
+
26
+ def fetch_data_sync(param):
27
+ return asyncio.run(fetch_data("data", param))
28
+
29
+ fetch_button = gr.Button("Fetch Data")
30
+ fetch_button.click(fetch_data_sync, inputs=param, outputs=output)
31
+
32
+ with gr.TabItem("Analysis"):
33
+ with gr.Accordion("Run Analysis", open=False):
34
+ param = gr.Textbox(label="Analysis Parameter")
35
+ output = gr.JSON(label="Analysis Result")
36
+
37
+ def run_analysis_sync(param):
38
+ return asyncio.run(fetch_data("analysis", param))
39
+
40
+ run_button = gr.Button("Run Analysis")
41
+ run_button.click(run_analysis_sync, inputs=param, outputs=output)
42
 
43
+ demo.launch(server_name="0.0.0.0", server_port=8000)