Spaces:
Sleeping
Sleeping
mriusero
commited on
Commit
·
9ef3aa7
1
Parent(s):
60ed03c
feat: prod status tool
Browse files- chroma_db/chroma.sqlite3 +1 -1
- chroma_db/d365f4bc-8099-45f4-bdc0-9c299960820d/length.bin +1 -1
- data/status.json +1 -0
- src/agent/mistral_agent.py +3 -0
- src/agent/tools/__init__.py +2 -1
- src/agent/tools/check_production.py +23 -0
- src/ui/dashboard.py +4 -1
- src/ui/sidebar.py +3 -16
- tools.json +12 -0
chroma_db/chroma.sqlite3
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 876544
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3c22a0779e0202064899929479438a5e3b44c945776e95d7c2e4a82cf37c0952
|
3 |
size 876544
|
chroma_db/d365f4bc-8099-45f4-bdc0-9c299960820d/length.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 40000
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f11db32cb916fca1af5c42ae827128c3d54709e1b2f7fa688d8dc1e206b18f1b
|
3 |
size 40000
|
data/status.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{}
|
src/agent/mistral_agent.py
CHANGED
@@ -7,6 +7,7 @@ from src.agent.tools import (
|
|
7 |
calculate_sum,
|
8 |
retrieve_knowledge,
|
9 |
visit_webpage,
|
|
|
10 |
)
|
11 |
|
12 |
load_dotenv()
|
@@ -22,6 +23,7 @@ class MistralAgent:
|
|
22 |
"calculate_sum": calculate_sum,
|
23 |
"retrieve_knowledge": retrieve_knowledge,
|
24 |
"visit_webpage": visit_webpage,
|
|
|
25 |
}
|
26 |
self.tools = self.get_tools()
|
27 |
|
@@ -33,5 +35,6 @@ class MistralAgent:
|
|
33 |
calculate_sum,
|
34 |
retrieve_knowledge,
|
35 |
visit_webpage,
|
|
|
36 |
]
|
37 |
).get('tools')
|
|
|
7 |
calculate_sum,
|
8 |
retrieve_knowledge,
|
9 |
visit_webpage,
|
10 |
+
get_production_status,
|
11 |
)
|
12 |
|
13 |
load_dotenv()
|
|
|
23 |
"calculate_sum": calculate_sum,
|
24 |
"retrieve_knowledge": retrieve_knowledge,
|
25 |
"visit_webpage": visit_webpage,
|
26 |
+
"get_production_status": get_production_status,
|
27 |
}
|
28 |
self.tools = self.get_tools()
|
29 |
|
|
|
35 |
calculate_sum,
|
36 |
retrieve_knowledge,
|
37 |
visit_webpage,
|
38 |
+
get_production_status,
|
39 |
]
|
40 |
).get('tools')
|
src/agent/tools/__init__.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
from .calculator import calculate_sum
|
2 |
from .retrieve_knowledge import retrieve_knowledge
|
3 |
-
from .visit_webpage import visit_webpage
|
|
|
|
1 |
from .calculator import calculate_sum
|
2 |
from .retrieve_knowledge import retrieve_knowledge
|
3 |
+
from .visit_webpage import visit_webpage
|
4 |
+
from .check_production import get_production_status
|
src/agent/tools/check_production.py
CHANGED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from src.agent.utils.tooling import tool
|
2 |
+
|
3 |
+
@tool
|
4 |
+
def get_production_status() -> str:
|
5 |
+
"""
|
6 |
+
This tool retrieves the current production status including various metrics such as operating time, unplanned stops, quality rates, availability, and performance indicators.
|
7 |
+
"""
|
8 |
+
try:
|
9 |
+
with open("data/status.json", "r") as f:
|
10 |
+
json_string = f.read()
|
11 |
+
|
12 |
+
result = "## Production status:\n\n"
|
13 |
+
result += json_string
|
14 |
+
result += "\n\n## Description:\n"
|
15 |
+
# result += """
|
16 |
+
# These data represent various performance and efficiency metrics related to a manufacturing or production process. They include time-based measurements such as total operating time, unplanned stops, and net productive time. Additionally, quality rates assess the percentage of products meeting specifications, often broken down by different tools or stations. Availability and operating rates indicate the proportion of scheduled production time that the equipment is actually running. Key performance indicators such as Overall Equipment Effectiveness (OEE), Mean Time Between Failures (MTBF), and Mean Time To Repair (MTTR) provide insights into equipment reliability and maintenance efficiency. Finally, process capability indices (Cp and Cpk) evaluate the precision and consistency of the tools used in production, considering both position and orientation parameters.
|
17 |
+
# """
|
18 |
+
result += "\n\nWARNING:\n If all metrics are null, it means that the production is not running or has not started yet."
|
19 |
+
return result
|
20 |
+
|
21 |
+
except Exception as e:
|
22 |
+
print(f"Error getting production status: {e}")
|
23 |
+
return None
|
src/ui/dashboard.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import asyncio
|
2 |
from functools import partial
|
|
|
3 |
|
4 |
import gradio as gr
|
5 |
import pandas as pd
|
@@ -17,7 +18,6 @@ def hash_dataframe(df):
|
|
17 |
"""Computes a simple hash to detect changes in the DataFrame."""
|
18 |
return pd.util.hash_pandas_object(df).sum()
|
19 |
|
20 |
-
|
21 |
async def dataflow(state):
|
22 |
"""
|
23 |
Main function that updates data if necessary.
|
@@ -178,6 +178,9 @@ async def on_tick(state, displays):
|
|
178 |
for df, display in zip(tool_dfs, displays[:-1]):
|
179 |
tool_plots.extend(display.refresh(df=df))
|
180 |
|
|
|
|
|
|
|
181 |
return tool_plots + general_plots + [state]
|
182 |
|
183 |
def dashboard_ui(state):
|
|
|
1 |
import asyncio
|
2 |
from functools import partial
|
3 |
+
import json
|
4 |
|
5 |
import gradio as gr
|
6 |
import pandas as pd
|
|
|
18 |
"""Computes a simple hash to detect changes in the DataFrame."""
|
19 |
return pd.util.hash_pandas_object(df).sum()
|
20 |
|
|
|
21 |
async def dataflow(state):
|
22 |
"""
|
23 |
Main function that updates data if necessary.
|
|
|
178 |
for df, display in zip(tool_dfs, displays[:-1]):
|
179 |
tool_plots.extend(display.refresh(df=df))
|
180 |
|
181 |
+
with open("data/status.json", "w") as f:
|
182 |
+
json.dump(state["status"], f, indent=4)
|
183 |
+
|
184 |
return tool_plots + general_plots + [state]
|
185 |
|
186 |
def dashboard_ui(state):
|
src/ui/sidebar.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
|
3 |
from src.agent.stream import respond
|
4 |
|
5 |
-
|
6 |
def sidebar_ui(state, width=700, visible=True):
|
7 |
with gr.Sidebar(width=width, visible=visible):
|
8 |
gr.Markdown("# Ask Agent")
|
@@ -40,29 +39,17 @@ def sidebar_ui(state, width=700, visible=True):
|
|
40 |
stop_btn=True,
|
41 |
save_history=True,
|
42 |
examples=[
|
43 |
-
|
44 |
["How is the production process going?"],
|
45 |
["What are the common issues faced in production?"],
|
46 |
-
|
47 |
# ["Can you provide insights on equipment performance?"],
|
48 |
# ["How can I optimize the workflow in the production area?"],
|
49 |
# ["How do I troubleshoot a specific piece of equipment?"],
|
50 |
# ["What are the best practices for maintaining production efficiency?"]
|
51 |
],
|
52 |
-
|
53 |
-
cache_examples=False # désactive le cache si les réponses varient
|
54 |
)
|
55 |
-
#with gr.TabItem("Documentation", visible=True):
|
56 |
-
# md_output = gr.Markdown("📄 La documentation s'affichera ici.")
|
57 |
-
|
58 |
-
#textbox=gr.MultimodalTextbox(file_types=[".png", ".pdf"], sources=["upload", "microphone"]),
|
59 |
-
#additional_inputs=[gr.Textbox("Système", label="System prompt"), gr.Slider(0, 1)],
|
60 |
-
#additional_inputs_accordion="Options avancées",
|
61 |
-
#flagging_mode="manual",
|
62 |
-
#flagging_options=["👍", "👎"],
|
63 |
-
#title="Mon Chatbot",
|
64 |
-
#description="Testez un modèle multimodal",
|
65 |
-
|
66 |
sessions_state = gr.JSON(
|
67 |
label="Sessions State",
|
68 |
visible=True,
|
|
|
2 |
|
3 |
from src.agent.stream import respond
|
4 |
|
|
|
5 |
def sidebar_ui(state, width=700, visible=True):
|
6 |
with gr.Sidebar(width=width, visible=visible):
|
7 |
gr.Markdown("# Ask Agent")
|
|
|
39 |
stop_btn=True,
|
40 |
save_history=True,
|
41 |
examples=[
|
42 |
+
# ["What is the sum of 1+1 ?"],
|
43 |
["How is the production process going?"],
|
44 |
["What are the common issues faced in production?"],
|
45 |
+
["Can you explain me Cp & Cpk KPIs ?"],
|
46 |
# ["Can you provide insights on equipment performance?"],
|
47 |
# ["How can I optimize the workflow in the production area?"],
|
48 |
# ["How do I troubleshoot a specific piece of equipment?"],
|
49 |
# ["What are the best practices for maintaining production efficiency?"]
|
50 |
],
|
51 |
+
cache_examples=False
|
|
|
52 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
sessions_state = gr.JSON(
|
54 |
label="Sessions State",
|
55 |
visible=True,
|
tools.json
CHANGED
@@ -59,5 +59,17 @@
|
|
59 |
]
|
60 |
}
|
61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
]
|
|
|
59 |
]
|
60 |
}
|
61 |
}
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"type": "function",
|
65 |
+
"function": {
|
66 |
+
"name": "get_production_status",
|
67 |
+
"description": "This tool retrieves the current production status including various metrics such as operating time, unplanned stops, quality rates, availability, and performance indicators.",
|
68 |
+
"parameters": {
|
69 |
+
"type": "object",
|
70 |
+
"properties": {},
|
71 |
+
"required": []
|
72 |
+
}
|
73 |
+
}
|
74 |
}
|
75 |
]
|