Skip to content

GCP integration + v0.3 frontend + intro animation#2

Merged
Vector897 merged 2 commits into
mainfrom
feat/gcp-integration
Jun 27, 2026
Merged

GCP integration + v0.3 frontend + intro animation#2
Vector897 merged 2 commits into
mainfrom
feat/gcp-integration

Conversation

@Vector897

Copy link
Copy Markdown
Owner

Summary

  • Vertex AI Gemini 2.0 Flash wired as judge/scorer via llm.py auto-routing (falls back to OpenRouter when GCP_PROJECT not set)
  • BigQuery corpus layer (backend/app/data/bigquery.py) — whetstone.corpus table auto-provisioned on startup; /api/corpus/search prefers BQ over SQLite when GCP is configured
  • Cloud Run deploymentDockerfile + .dockerignore + .gcloudignore (excludes pdf_env/ symlink that causes WinError 1920 on Windows)
  • Frontend v0.3 — 6/6 hackathon bonuses: persona picker (Hardball/Slippery/Stone Wall), adaptive difficulty badge, voice mode (Web Speech API en-GB), streak counter + sparklines, turning-point replay modal, BonusBar chip row
  • Intro animationfrontend/intro.mp4 served via /intro.mp4 FastAPI route; fullscreen overlay plays before app loads, Skip › button, graceful fallback on video error
  • README.md — English project description with hero image (frontend/demo.png), three-arenas table, tech stack, run/deploy commands, hackathon compliance table
  • SQLite migration — ALTER TABLE adds persona + difficulty columns to existing DBs without destroying data

GCP track checklist

Service Usage
Cloud Run Main app deployment (europe-west2)
Vertex AI Gemini 2.0 Flash as judge/scorer/referee LLM
BigQuery whetstone.corpus — SEC EDGAR + CUAD clause corpus

Test plan

  • uvicorn app.main:app --app-dir backend starts without errors
  • GET /api/health returns gcp.vertex_ai: true when GCP_PROJECT is set
  • Opening http://localhost:8000 shows intro video → Skip → loading bar → Dojo tab
  • Persona picker appears before each session; selection persists in session state
  • Dashboard tab renders without React hook errors
  • GET /api/corpus/search?clause_type=liability_cap returns source: bigquery when BQ is configured

Deploy command

cd D:\Whetstone
gcloud run deploy whetstone \
  --source . --port 8080 --allow-unauthenticated \
  --region europe-west2 \
  --set-env-vars=OPENROUTER_API_KEY=YOUR_KEY,GCP_PROJECT=whetstone-500713,VERTEX_LOCATION=europe-west2

Note: Must be run from D:\Whetstone (not user home dir) to avoid WinError 1920 on pdf_env symlink.

Copilot AI review requested due to automatic review settings June 27, 2026 14:43
@Vector897
Vector897 merged commit ba4e124 into main Jun 27, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds GCP-oriented deployment/documentation updates and a new frontend intro-video experience, while extending backend support for serving static assets and migrating existing SQLite session tables to include persona/difficulty.

Changes:

  • Adds intro video overlay flow in the frontend, with Skip support and boot sequencing after video end/failure.
  • Serves intro.mp4 and demo.png via new FastAPI routes.
  • Updates SQLite initialization to include persona/difficulty columns and attempts to migrate older DBs; adds deployment/docs ignore rules and a new README.

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
README.md New project overview, features, local run + Cloud Run deployment instructions.
frontend/index.html Adds fullscreen intro video overlay and defers app boot until skip/end/error.
backend/app/main.py Adds /intro.mp4 and /demo.png routes to serve frontend assets.
backend/app/db.py Adds schema migration for persona/difficulty columns on existing SQLite DBs.
.gitignore Keeps *.md ignored while explicitly tracking README.md.
.gcloudignore Excludes venvs, large data, and dev/team/docs files from Cloud Build source upload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/app/db.py
Comment on lines +39 to +43
try:
_conn().execute(f"ALTER TABLE sessions ADD COLUMN {col} {coldef}")
_conn().commit()
except Exception:
pass # column already exists
Comment thread frontend/index.html
Comment on lines +925 to +929
// if video can't autoplay (blocked), fall back after 200ms
var playPromise=vv.play();
if(playPromise&&typeof playPromise.catch==="function"){
playPromise.catch(function(){startApp();});
}
@Vector897

Copy link
Copy Markdown
Owner Author

新增:五层防幻觉机制

新增文件 backend/app/engines/grounding.py

五层机制

1. Quote Verification(引用核实)
评分后逐条检查 evidence_quote 是否在实际对话记录中存在。SequenceMatcher 模糊匹配(阈值 0.65)。找不到 → verdict 降为 UNMET,注明 [GROUNDING: quote not found]

2. Trigger Validation(触发条件验证)
对手声称触发让步前,先验证 trigger_claimed 是否与场景 JSON 中的 concession_triggers 语义相关(双重匹配:ratio ≥ 0.45 OR 关键词重叠 ≥ 40%)。不匹配 → 直接拒绝,不进入裁判流程。

3. Self-Consistency Referee(多数投票裁判)
Concession Gate 改为 3 次独立调用,多数票(2:1 以上)才允许让步。返回 _consistency_votes 字段可审计。

4. Score Sanity Check(分数钳位)
dimension_scores 每项钳位到 [0, max]overall_score 钳位到 [0, 100];类型强制转换。

5. Schema Guard(结构守卫)
三套 validator(对手/裁判/评分)。修正 conceded: trueTrue,填充缺失字段,reply 为空时替换占位符。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants