Spaces:
Sleeping
Sleeping
mriusero
commited on
Commit
·
49655be
1
Parent(s):
b0a5efe
core: refacto
Browse files- app.py +5 -62
- src/production/processing.py +0 -1
- src/ui/__init__.py +2 -0
- src/ui/dashboard.py +42 -0
- src/ui/sidebar.py +24 -0
app.py
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
-
import json
|
2 |
-
import pandas as pd
|
3 |
import gradio as gr
|
4 |
|
5 |
-
from src.
|
6 |
-
from src.production.flow import play_fn, stop_fn, reset_fn
|
7 |
|
8 |
custom_theme = gr.themes.Base(
|
9 |
primary_hue="blue",
|
@@ -14,7 +11,7 @@ custom_theme = gr.themes.Base(
|
|
14 |
|
15 |
with gr.Blocks(theme=custom_theme) as demo:
|
16 |
|
17 |
-
#
|
18 |
gr.Markdown("# AI Industrial Efficiency Helper ⚡️")
|
19 |
gr.Markdown("### *AI for efficiency in Industries & Services*")
|
20 |
gr.Markdown(
|
@@ -23,65 +20,11 @@ with gr.Blocks(theme=custom_theme) as demo:
|
|
23 |
You can interact with the chatbot to get insights and assistance on production-related queries.
|
24 |
"""
|
25 |
)
|
26 |
-
|
27 |
-
|
28 |
-
gr.HTML("<div style='margin-bottom: 20px;'></div>")
|
29 |
-
gr.Markdown(
|
30 |
-
"""
|
31 |
-
Ask questions about production processes, equipment, and workflows.
|
32 |
-
The chatbot will provide insights and assistance based on the current production data.
|
33 |
-
"""
|
34 |
-
)
|
35 |
-
gr.HTML("<div style='margin-bottom: 20px;'></div>")
|
36 |
-
gr.Markdown(
|
37 |
-
"""
|
38 |
-
1. **Play** - Start the production simulation and generate synthetic data.
|
39 |
-
2. **Ask Questions** - Interact with the chatbot to get insights on production processes.
|
40 |
-
3. **Ask for Help** - Get assistance with any issues or queries related to production.
|
41 |
-
|
42 |
-
Note: you can click on `stop` or `reset` to control the production simulation.
|
43 |
-
"""
|
44 |
-
)
|
45 |
-
gr.HTML("<div style='margin-bottom: 40px;'></div>")
|
46 |
-
chatbot = gr.ChatInterface(respond, type='messages')
|
47 |
|
48 |
# DASHBOARD
|
49 |
-
|
50 |
-
with gr.Row():
|
51 |
-
with gr.Blocks():
|
52 |
-
play = gr.Button("▶️ Play")
|
53 |
-
stop = gr.Button("⏸️ Pause")
|
54 |
-
reset = gr.Button("🔄 Reset")
|
55 |
-
|
56 |
-
with gr.Row():
|
57 |
-
with gr.Column(scale=3):
|
58 |
-
df_outputs = {
|
59 |
-
"DataFrame 1": pd.DataFrame(),
|
60 |
-
"DataFrame 2": pd.DataFrame(),
|
61 |
-
"DataFrame 3": pd.DataFrame(),
|
62 |
-
"DataFrame 4": pd.DataFrame(),
|
63 |
-
"DataFrame 5": pd.DataFrame(),
|
64 |
-
}
|
65 |
-
json_output = {}
|
66 |
-
|
67 |
-
df_components = [gr.DataFrame(label=df_name, visible=True) for df_name in df_outputs.keys()]
|
68 |
-
json_component = gr.JSON(label="Machine JSON", value=json_output, visible=True)
|
69 |
-
|
70 |
-
play.click(
|
71 |
-
fn=play_fn,
|
72 |
-
inputs=None,
|
73 |
-
outputs=df_components + [json_component]
|
74 |
-
)
|
75 |
-
stop.click(
|
76 |
-
fn=stop_fn,
|
77 |
-
inputs=None,
|
78 |
-
outputs=None
|
79 |
-
)
|
80 |
-
reset.click(
|
81 |
-
fn=reset_fn,
|
82 |
-
inputs=None,
|
83 |
-
outputs=None
|
84 |
-
)
|
85 |
|
86 |
# DESCRIPTION
|
87 |
with gr.Tab("Description"):
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from src.ui import sidebar_ui, dashboard_ui
|
|
|
4 |
|
5 |
custom_theme = gr.themes.Base(
|
6 |
primary_hue="blue",
|
|
|
11 |
|
12 |
with gr.Blocks(theme=custom_theme) as demo:
|
13 |
|
14 |
+
# HEADER
|
15 |
gr.Markdown("# AI Industrial Efficiency Helper ⚡️")
|
16 |
gr.Markdown("### *AI for efficiency in Industries & Services*")
|
17 |
gr.Markdown(
|
|
|
20 |
You can interact with the chatbot to get insights and assistance on production-related queries.
|
21 |
"""
|
22 |
)
|
23 |
+
# CHAT INTERFACE
|
24 |
+
sidebar_ui(width=700, visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# DASHBOARD
|
27 |
+
dashboard_ui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# DESCRIPTION
|
30 |
with gr.Tab("Description"):
|
src/production/processing.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import json
|
2 |
-
import numpy as np
|
3 |
|
4 |
from .metrics.tools import get_tools_metrics
|
5 |
from .metrics.machine import get_machine_metrics
|
|
|
1 |
import json
|
|
|
2 |
|
3 |
from .metrics.tools import get_tools_metrics
|
4 |
from .metrics.machine import get_machine_metrics
|
src/ui/__init__.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
from src.ui.sidebar import sidebar_ui
|
2 |
+
from src.ui.dashboard import dashboard_ui
|
src/ui/dashboard.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
from src.production.flow import play_fn, stop_fn, reset_fn
|
5 |
+
|
6 |
+
def dashboard_ui():
|
7 |
+
with gr.Tab("Dashboard"):
|
8 |
+
with gr.Row():
|
9 |
+
with gr.Blocks():
|
10 |
+
play = gr.Button("▶️ Play")
|
11 |
+
stop = gr.Button("⏸️ Pause")
|
12 |
+
reset = gr.Button("🔄 Reset")
|
13 |
+
|
14 |
+
with gr.Row():
|
15 |
+
with gr.Column(scale=3):
|
16 |
+
json_output = {}
|
17 |
+
json_component = gr.JSON(label="Machine JSON", value=json_output, visible=True)
|
18 |
+
|
19 |
+
df_outputs = {
|
20 |
+
"DataFrame 1": pd.DataFrame(),
|
21 |
+
"DataFrame 2": pd.DataFrame(),
|
22 |
+
"DataFrame 3": pd.DataFrame(),
|
23 |
+
"DataFrame 4": pd.DataFrame(),
|
24 |
+
"DataFrame 5": pd.DataFrame(),
|
25 |
+
}
|
26 |
+
df_components = [gr.DataFrame(label=df_name, visible=False) for df_name in df_outputs.keys()]
|
27 |
+
|
28 |
+
play.click(
|
29 |
+
fn=play_fn,
|
30 |
+
inputs=None,
|
31 |
+
outputs=df_components + [json_component]
|
32 |
+
)
|
33 |
+
stop.click(
|
34 |
+
fn=stop_fn,
|
35 |
+
inputs=None,
|
36 |
+
outputs=None
|
37 |
+
)
|
38 |
+
reset.click(
|
39 |
+
fn=reset_fn,
|
40 |
+
inputs=None,
|
41 |
+
outputs=None
|
42 |
+
)
|
src/ui/sidebar.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from src.chat import respond
|
4 |
+
|
5 |
+
def sidebar_ui(width=700, visible=True):
|
6 |
+
with gr.Sidebar(width=width, visible=visible):
|
7 |
+
gr.Markdown("# Ask Agent")
|
8 |
+
gr.Markdown(
|
9 |
+
"""
|
10 |
+
Ask questions about production processes, equipment, and workflows.
|
11 |
+
The chatbot will provide insights and assistance based on the current production data.
|
12 |
+
"""
|
13 |
+
)
|
14 |
+
gr.Markdown(
|
15 |
+
"""
|
16 |
+
1. **Play** - Start the production simulation and generate synthetic data.
|
17 |
+
2. **Ask Questions** - Interact with the chatbot to get insights on production processes.
|
18 |
+
3. **Ask for Help** - Get assistance with any issues or queries related to production.
|
19 |
+
|
20 |
+
Note: you can click on `stop` or `reset` to control the production simulation.
|
21 |
+
"""
|
22 |
+
)
|
23 |
+
gr.HTML("<div style='margin-bottom: 40px;'></div>")
|
24 |
+
chatbot = gr.ChatInterface(respond, type='messages')
|