-
Notifications
You must be signed in to change notification settings - Fork 0
feat: one-click web multi-CSV analysis + CLI/desktop integrations #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,11 @@ | |
| import json | ||
| from pathlib import Path | ||
| import subprocess | ||
| import tempfile | ||
| from urllib.parse import urlparse | ||
|
|
||
| from .analysis import build_analysis_payload_from_csv_text | ||
| from .multi_csv import analyze_multiple_csv | ||
|
|
||
|
|
||
| UI_DIR = Path(__file__).parent / "ui" | ||
|
|
@@ -75,6 +77,42 @@ def do_POST(self) -> None: | |
| result = build_analysis_payload_from_csv_text(csv_text, question) | ||
| return self._send_json(result) | ||
|
|
||
|
|
||
| if route == "/api/multi-analyze": | ||
| files = payload.get("files", []) | ||
| question = str(payload.get("question", "")).strip() or "다중 CSV를 비교 분석해줘" | ||
| group_column = str(payload.get("group_column", "")).strip() or None | ||
| target_column = str(payload.get("target_column", "")).strip() or None | ||
| if not isinstance(files, list) or not files: | ||
| return self._send_json({"error": "files is required"}, HTTPStatus.BAD_REQUEST) | ||
|
|
||
| with tempfile.TemporaryDirectory(prefix="bitnet_multi_") as td: | ||
| tmp_paths = [] | ||
| for i, f in enumerate(files): | ||
| if not isinstance(f, dict): | ||
| continue | ||
| name = str(f.get("name", f"file_{i}.csv")) | ||
| text = str(f.get("csv_text", "")) | ||
| if not text.strip(): | ||
| continue | ||
| if not name.endswith('.csv'): | ||
| name = f"{name}.csv" | ||
| path = Path(td) / name | ||
| path.write_text(text, encoding="utf-8") | ||
|
Comment on lines
+100
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| tmp_paths.append(path) | ||
|
|
||
| if not tmp_paths: | ||
| return self._send_json({"error": "valid csv_text files are required"}, HTTPStatus.BAD_REQUEST) | ||
|
|
||
| result = analyze_multiple_csv( | ||
| tmp_paths, | ||
| question, | ||
| group_column=group_column, | ||
| target_column=target_column, | ||
| use_cache=False, | ||
| ) | ||
| return self._send_json(result) | ||
|
|
||
| if route == "/api/run": | ||
| model = str(payload.get("model", "")).strip() | ||
| prompt = str(payload.get("prompt", "")).strip() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code reuses the incoming
nameas the on-disk filename, so if two uploaded entries share a basename (for example two differentdata.csvfiles), the later write overwrites the earlier one and both analysis slots end up reading the same content. The request still succeeds, but the multi-file comparison is silently corrupted; append an index/UUID to each temp filename to preserve one file per upload item.Useful? React with 👍 / 👎.