Sales Trainer v0.1: corporate sales-training simulator (Flask+Vue, 15 personas, chat simulator, judge, analytics)

- Auth/roles (no self-reg), admin user provision, JWT
- Analyze: sales kit + initial pain-fit from form/upload
- Persona generator: 15 personas (5/tier) w/ pain variety, negotiation, init mode, channel, latent/revealable, wrong_text special
- Chat simulator: per-mode initiation, one-shot, hidden signals, judge-LLM debrief+coaching
- Trainee loop: win/lose board, weak-areas, user-generated personas
- Admin analytics; EN+TH Vue SPA served by Flask
- Deploy: Dockerfile, docker-compose, README, eng-log + HANDOFF
- Tests (mock LLM): m0/m1/routes/e2e all pass
This commit is contained in:
Macky
2026-08-07 15:31:06 +07:00
commit c3d31c06e2
70 changed files with 6135 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
"""File parsing for uploaded documents (pdf / markdown / txt)."""
from __future__ import annotations
from pathlib import Path
class ParseError(Exception):
pass
def parse_pdf(path: Path) -> str:
import fitz # PyMuPDF
try:
doc = fitz.open(path)
except Exception as exc:
raise ParseError(f"cannot open PDF: {exc}") from exc
parts = []
for page in doc:
parts.append(page.get_text())
doc.close()
return "\n".join(parts)
def parse_text(path: Path) -> str:
import chardet
raw = path.read_bytes()
# Try utf-8 first, else detect encoding
try:
return raw.decode("utf-8")
except UnicodeDecodeError:
pass
guess = chardet.detect(raw)
enc = guess.get("encoding") or "utf-8"
try:
return raw.decode(enc, errors="replace")
except Exception:
return raw.decode("utf-8", errors="replace")
def parse_document(path: Path) -> str:
ext = path.suffix.lower().lstrip(".")
if ext == "pdf":
return parse_pdf(path)
return parse_text(path)