Spaces:
Sleeping
Sleeping
Nyha15 commited on
Commit Β·
cd765a0
1
Parent(s): f4a5012
Removed LLM call
Browse files
app.py
CHANGED
|
@@ -98,7 +98,7 @@ class ComputeAgent(MCPAgent):
|
|
| 98 |
def _load(self, params):
|
| 99 |
url = params.get("url", "").strip()
|
| 100 |
if not url or url.lower() == "default":
|
| 101 |
-
url = "https://raw.githubusercontent.com/
|
| 102 |
try:
|
| 103 |
self.df = pd.read_csv(url)
|
| 104 |
return {
|
|
@@ -144,7 +144,7 @@ class ComputeAgent(MCPAgent):
|
|
| 144 |
res = self._corr(m.content)
|
| 145 |
self.send_message(m.sender, "correlation_result", res)
|
| 146 |
|
| 147 |
-
# βββ InterpretAgent
|
| 148 |
class InterpretAgent(MCPAgent):
|
| 149 |
def __init__(self):
|
| 150 |
super().__init__("InterpretAgent", "Interprets & reports (no LLM)")
|
|
@@ -199,30 +199,32 @@ class DataAnalystDuo:
|
|
| 199 |
self.I.connect(self.C)
|
| 200 |
|
| 201 |
def run(self, url):
|
|
|
|
| 202 |
self.I.send_message("ComputeAgent", "request_data_load", {"url": url})
|
| 203 |
self.C.process(); self.I.process()
|
|
|
|
| 204 |
self.I.send_message("ComputeAgent", "request_statistics", {})
|
| 205 |
self.C.process(); self.I.process()
|
|
|
|
| 206 |
self.I.send_message("ComputeAgent", "request_correlation", {})
|
| 207 |
self.C.process(); self.I.process()
|
|
|
|
| 208 |
self.C.send_message("InterpretAgent", "request_report", {"report_title": "Analysis Report"})
|
| 209 |
self.I.process(); self.C.process()
|
| 210 |
-
return
|
| 211 |
-
|
| 212 |
-
"interpret_history": self.I.get_history()
|
| 213 |
-
}
|
| 214 |
|
| 215 |
# βββ Gradio app entrypoint βββββββββββββββββββββββββββββββββ
|
| 216 |
def run_analysis(url: str):
|
| 217 |
-
|
| 218 |
-
return
|
| 219 |
|
| 220 |
demo = gr.Interface(
|
| 221 |
fn=run_analysis,
|
| 222 |
inputs=gr.Textbox(label="CSV URL", placeholder="https://..."),
|
| 223 |
outputs=[
|
| 224 |
gr.JSON(label="Compute & Data-Load History"),
|
| 225 |
-
gr.JSON(label="Interpret & Report History")
|
| 226 |
],
|
| 227 |
title="Data Analyst Duo",
|
| 228 |
description="Load a CSV URL and see compute + interpretation steps"
|
|
@@ -230,5 +232,8 @@ demo = gr.Interface(
|
|
| 230 |
|
| 231 |
if __name__ == "__main__":
|
| 232 |
port = int(os.environ.get("PORT", 7860))
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
def _load(self, params):
|
| 99 |
url = params.get("url", "").strip()
|
| 100 |
if not url or url.lower() == "default":
|
| 101 |
+
url = "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
|
| 102 |
try:
|
| 103 |
self.df = pd.read_csv(url)
|
| 104 |
return {
|
|
|
|
| 144 |
res = self._corr(m.content)
|
| 145 |
self.send_message(m.sender, "correlation_result", res)
|
| 146 |
|
| 147 |
+
# βββ InterpretAgent (stubs) βββββββββββββββββββββββββββββββββ
|
| 148 |
class InterpretAgent(MCPAgent):
|
| 149 |
def __init__(self):
|
| 150 |
super().__init__("InterpretAgent", "Interprets & reports (no LLM)")
|
|
|
|
| 199 |
self.I.connect(self.C)
|
| 200 |
|
| 201 |
def run(self, url):
|
| 202 |
+
# 1) load data
|
| 203 |
self.I.send_message("ComputeAgent", "request_data_load", {"url": url})
|
| 204 |
self.C.process(); self.I.process()
|
| 205 |
+
# 2) stats
|
| 206 |
self.I.send_message("ComputeAgent", "request_statistics", {})
|
| 207 |
self.C.process(); self.I.process()
|
| 208 |
+
# 3) correlation
|
| 209 |
self.I.send_message("ComputeAgent", "request_correlation", {})
|
| 210 |
self.C.process(); self.I.process()
|
| 211 |
+
# 4) report
|
| 212 |
self.C.send_message("InterpretAgent", "request_report", {"report_title": "Analysis Report"})
|
| 213 |
self.I.process(); self.C.process()
|
| 214 |
+
# return two separate objects
|
| 215 |
+
return self.C.get_history(), self.I.get_history()
|
|
|
|
|
|
|
| 216 |
|
| 217 |
# βββ Gradio app entrypoint βββββββββββββββββββββββββββββββββ
|
| 218 |
def run_analysis(url: str):
|
| 219 |
+
compute_hist, interpret_hist = DataAnalystDuo().run(url)
|
| 220 |
+
return compute_hist, interpret_hist
|
| 221 |
|
| 222 |
demo = gr.Interface(
|
| 223 |
fn=run_analysis,
|
| 224 |
inputs=gr.Textbox(label="CSV URL", placeholder="https://..."),
|
| 225 |
outputs=[
|
| 226 |
gr.JSON(label="Compute & Data-Load History"),
|
| 227 |
+
gr.JSON(label="Interpret & Report History"),
|
| 228 |
],
|
| 229 |
title="Data Analyst Duo",
|
| 230 |
description="Load a CSV URL and see compute + interpretation steps"
|
|
|
|
| 232 |
|
| 233 |
if __name__ == "__main__":
|
| 234 |
port = int(os.environ.get("PORT", 7860))
|
| 235 |
+
demo.launch(
|
| 236 |
+
server_name="0.0.0.0",
|
| 237 |
+
server_port=port,
|
| 238 |
+
share=True
|
| 239 |
+
)
|