Commit Graph
94 Commits
Author SHA1 Message Date
wangweiandCopilot 001fbb0b58 feat(advisor-comparison): add find_previous_run same-scenario lookup
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 16:41:36 +08:00
wangweiandCopilot 9987573e02 feat(advisor-comparison): add AdvisorComparison models and ReportData field
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 16:39:21 +08:00
wangweiandCopilot 8ebf554989 docs: add advisor comparison implementation plan
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 16:37:38 +08:00
wangweiandCopilot 81996f8aa1 docs: add advisor comparison design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 16:28:13 +08:00
wangweiandCopilot 6bad007cd9 feat(token-tracking): add Token usage panel to the report detail page
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 15:40:37 +08:00
wangweiandCopilot 4bb1952348 feat(token-tracking): surface token_usage in ReportData
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 15:14:11 +08:00
wangweiandCopilot 8245c7f9c3 feat(token-tracking): accumulate token usage across session_async calls
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 15:09:30 +08:00
wangweiandCopilot 6a2bbf8239 feat(token-tracking): capture token usage in /api/score/async job runs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 15:03:25 +08:00
wangweiandCopilot 5494840431 feat(token-tracking): wrap CLI evaluator metric scoring in track_token_usage
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:57:19 +08:00
wangweiandCopilot cd044c8416 feat(token-tracking): add Token usage section to summary.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:50:07 +08:00
wangweiandCopilot b50b911de0 feat(token-tracking): add EvaluationResult.token_usage and persist to metadata.json
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:45:58 +08:00
wangweiandCopilot 29e76d021c feat(token-tracking): attach usage hook to advisor's self-created LLM client
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:39:13 +08:00
wangweiandCopilot 613d167e81 feat(token-tracking): add HTTP response hook and attach_usage_hook, wire into build_models
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:36:59 +08:00
wangweiandCopilot 8b896e4e7f feat(token-tracking): add TokenUsageTracker with context-scoped activation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:31:43 +08:00
wangweiandCopilot 54cc58e157 docs: add token usage tracking design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-02 14:05:05 +08:00
wangweiandCopilot 1dec4c8372 Add INFO/DEBUG logging to factory: log resolved base_url per model
build_models now logs: judge=<model>-><url> embedding=<model>-><url>

Makes it easy to confirm which gateway is actually used for each model.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 21:24:59 +08:00
wangweiandCopilot f6e10145cd Fix: build_models resolves separate AsyncOpenAI clients for judge and embedding models
Previously, only the judge_model's profile was looked up and its AsyncOpenAI

client was shared with embedding_factory. When embedding_model has a different

base_url/api_key (e.g. Qwen3-Embedding-4B on SiliconFlow vs gpt-5 on another

gateway), the embedding calls silently used the wrong URL, causing 402/404 errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 21:15:09 +08:00
wangweiandCopilot 3a82d8c487 Update API docs: document judge_language in all score endpoints
- POST /api/score: add judge_language section with default/usage

- POST /api/score/async: mention judge_language in docstring

- POST /api/score/session_async: add to description string + JSON example

- ScoreRequest / SessionScoreRequest: add judge_language to schema example

- request_summary snapshots: include judge_language for observability

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 20:21:04 +08:00
wangweiandCopilot 24a8688a34 Add committed zh judge-prompt cache + enable in Siemens scenarios + docs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 18:15:53 +08:00
wangweiandCopilot 065b0e0f1a Add judge-prompt cache bootstrap script
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 18:04:27 +08:00
wangweiandCopilot 31fe71eb94 Forward judge_language through score, async, and session endpoints
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 18:02:13 +08:00
wangweiandCopilot bd5658c3ac Wire judge-prompt localization into factory and inline scorer
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 17:58:43 +08:00
wangweiandCopilot 555328cb3b Add judge-prompt localizer with graceful fallback and drift detection
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 17:55:26 +08:00
wangwei 4e74e1b247 update for ragas 2026-07-01 17:53:00 +08:00
wangweiandCopilot 2bb804b059 Extract shared build_metric_registry factory (DRY)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 17:52:55 +08:00
wangweiandCopilot 4a646b6b9c Add judge_language config plumbing (settings + scenario + ScoreRequest)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 17:47:21 +08:00
wangweiandCopilot 03e682b89c docs: add Chinese judge-prompt adaptation design spec
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-01 17:32:22 +08:00
wangwei 9828b1d44c update 2026-06-27 14:31:45 +08:00
wangweiandCopilot 1df4010acc fix(llm): resolve score runtime config from saved profiles
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-26 20:34:01 +08:00
wangweiandCopilot 754a30ad59 feat(session-async): add /api/score/session_async with incremental session report aggregation
- New POST /api/score/session_async endpoint: same session_id calls append to one shared report
- New GET /api/score/sessions/{session_id}: returns call_count, metric_means, all job records
- New GET /api/score/session/jobs/{job_id}: individual call status
- SessionScoreJobManager: deterministic run_id from session_id, per-session mutex for CSV append, advisor regenerated on every call
- SessionScoreRequest (extends ScoreRequest + session_id), SessionScoreJobResponse, SessionStatus models added
- 24 new tests, all passing

chore(weighted-score): comment out 综合加权得分 display and computation

- report.js: hide 综合加权得分 card in report detail page
- score_jobs.js: hide 综合 chip in async job list
- report_builder.py: overall_ws=None (computation disabled)
- summary.py: weighted_score summary line disabled
- evaluator.py: weighted_score/sample_weight columns no longer written to scores.csv
- score.py /api/score: weighted_score always returns null
- score_job_manager.py + session_score_manager.py: weighted=None
- Updated 3 tests to match new behaviour (6 pre-existing failures unchanged)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-26 16:09:33 +08:00
wangweiandCopilot e1751447df feat(advisor): add 0.85 advisory threshold triggering LLM suggestions
- Add advisory_threshold=0.85 field to MetricRule (higher-is-better metrics)
- diagnose() now emits severity='low' for scores in (warning_threshold, 0.85)
- noise_sensitivity (lower-is-better) keeps its existing two-tier thresholds
- writer.py: severity labels mapped to Chinese (严重/警告/待优化)
- llm_analyzer.py: prompt explains low/warning/critical tiers in Chinese
- Tests: 5 new cases for 'low' severity, updated log summary assertions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-25 11:35:49 +08:00
wangweiandCopilot 4fd515d2d9 feat: async score jobs — POST /api/score/async + 评分记录 page
Each async score job:
- Runs InlineScorer.score() in thread pool
- Writes standard run artifacts (metadata.json, scores.csv, summary.md)
- Runs optimization_advisor => optimization_advice.md
- Result appears in 运行列表 and 报告详情 with full report

New endpoints:
- POST /api/score/async  (202, job_id immediate)
- GET  /api/score/jobs   (list all jobs)
- GET  /api/score/jobs/{id} (single job status)

Frontend:
- 评分记录 nav page with card list
- 5s auto-polling for queued/running jobs
- 查看报告 button navigates to existing 报告详情 page

Dify: change /api/score -> /api/score/async, no response parsing needed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-24 17:24:22 +08:00
wangwei abcd61ec8f docs: add async score jobs implementation plan 2026-06-24 17:08:01 +08:00
wangwei 363e8b0f27 docs: add async score jobs design spec 2026-06-24 17:04:06 +08:00
wangweiandCopilot b870ed8730 feat: make contexts optional in /api/score
When contexts is absent, metrics that require retrieved_contexts
(faithfulness, context_recall, context_precision, noise_sensitivity)
are automatically skipped and appear in skipped_metrics.
Only answer_relevancy, factual_correctness, semantic_similarity
remain computable without contexts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-24 14:42:03 +08:00
wangweiandCopilot 791738bb07 feat: rename project to 'Siemens RAGAS 评估平台' in frontend
- index.html: page title, brand-mark, brand-sub
- server.py: FastAPI app title
- app.css: comment header

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-24 10:20:23 +08:00
wangweiandCopilot 630b70cc2a docs: add project-overview.html — full project documentation
Covers: overview, architecture, modules, data flows (4 flows),
RAGAS metrics (7), API reference, weight config, deployment,
tech stack, directory structure. Self-contained HTML with
Siemens teal theme, sidebar scrollspy, responsive layout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-24 10:17:08 +08:00
wangweiandCopilot a781ba1e4a config: set default judge_model=gpt-5, embedding_model=text-embedding-3-small
gpt-5.4/5.5/5.2/5.4-mini/5.4-nano are incompatible with RAGAS 0.4.3
because they require max_completion_tokens instead of max_tokens.
gpt-5 / gpt-4.1 support max_tokens and json_object mode required by RAGAS.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 15:29:01 +08:00
wangweiandCopilot 2ad2c1ea9d docs: update /api/score example to use gpt-5.4 and text-embedding-3-small
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 15:11:34 +08:00
wangweiandCopilot f8e308b7dc fix: use max_tokens=8 for chat model connectivity test
max_tokens=1 triggers 'min-output limit' errors on gpt-5.x models.
Using 8 tokens is still cheap but satisfies all known model minimums.
Falls back to max_completion_tokens=8 if max_tokens is not supported.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 15:03:27 +08:00
wangweiandCopilot fb420656ec fix: use /embeddings endpoint for embedding models in connectivity test
text-embedding-* and other embedding models must call /embeddings not
/chat/completions. Added _is_embedding_model() heuristic that checks model
name keywords to route to the correct endpoint automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 14:53:32 +08:00
wangweiandCopilot 05419db1f9 fix: support max_completion_tokens for newer models (gpt-5.x) in connectivity test
Newer OpenAI models (gpt-5.4 etc.) reject max_tokens and require
max_completion_tokens. Try max_completion_tokens first, fall back to
max_tokens for older models / compatible APIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 14:51:28 +08:00
wangweiandCopilot 1dc7ab9727 fix: restore LLM profile test connectivity buttons (lost from git)
Frontend test functionality was implemented but never committed to git.
Re-adds:
- profiles.js: testCard(), testForm(), _showTestResult(), test btn in renderCard
- api.js: testProfile(id) and probeConnectivity(body) methods
- index.html: 测试连通性 button + result div in profile form
- app.css: .btn-test and .profile-test-result styles

Backend /probe and /{id}/test endpoints were already present in llm_profiles.py.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 13:58:43 +08:00
wangweiandCopilot 7cc3aff95a fix: hide #view-apidocs when [hidden] attribute is set
#view-apidocs has 'display: flex' in CSS which overrides the browser's
default '[hidden] { display: none }' user-agent style, causing the API
docs iframe to remain visible and bleed into the LLM config page.

Fix: add explicit '#view-apidocs[hidden] { display: none }' rule.
Also exclude apidocs from @media print to prevent iframe printing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 13:34:24 +08:00
wangweiandCopilot ad2651ce27 feat: configure full logging in webmain.py — all API logs to file + console
- RotatingFileHandler: logs/server_YYYY-MM-DD.log (50MB, keep 7 files)
- Console handler: colored timestamp + level + logger name + message
- webapp.* and rag_eval.* loggers captured at configured level
- uvicorn access/error logs also routed to same handlers
- File always captures DEBUG; console level controlled by --log-level arg
- Added --log-level and --log-file CLI arguments to webmain.py

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 11:46:34 +08:00
wangweiandCopilot fb42116616 fix: add setuptools package discovery config to pyproject.toml
Newer setuptools (Linux) raises error when multiple top-level dirs are found.
Explicitly include only rag_eval/apps/webapp and exclude runtime data dirs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 11:29:35 +08:00
wangweiandCopilot a629bd516c chore: add .gitattributes to enforce LF for shell scripts and Python files
Prevents CRLF line endings on .sh files which cause '/usr/bin/env: bash\r'
errors when running on Linux.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 11:22:24 +08:00
wangweiandCopilot ac410e7a5d feat: add detailed logging to all API routes and global access log middleware
Each API module now logs:
- evaluations: trigger (scenario path, task_id), status polls, list
- runs: list (count), detail (run_id, metrics, sample counts)
- scenarios: list (total, valid, error counts)
- pipeline: submit (docs_path, models, max_docs), status polls, list
- llm_profiles: CRUD ops (name, model, id), probe/test (model, ok, latency), apply (patched fields)
- score: already had per-request logging

Global middleware (webapp.access logger):
- Every API request: METHOD path -> status (latency_ms) at INFO
- Static file requests demoted to DEBUG to reduce noise

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 10:35:00 +08:00
wangweiandCopilot 1304fec1c4 fix: change ScoreRequest json_schema_extra from examples list to example dict
Swagger UI Try it out was sending the {summary, value} wrapper as request body
instead of just the value contents, causing 422 errors. The 'example' (singular)
key is correctly used as the schema-level example by Swagger UI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-23 10:03:46 +08:00
wangweiandCopilot 5ced129ff7 feat: add detailed request logging to /api/score and global 422 handler
- Log incoming request (client, content-type, metrics, has_gt) on each /api/score call
- Log scoring result (latency, skipped metrics, scores) on success
- Register global RequestValidationError handler: logs url/content-type/errors
  so 422 causes are visible in server log without checking HTTP response body
- Fix jsonable_encoder for exc.errors() to handle non-serializable ctx objects

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-22 18:14:01 +08:00