Commit Graph
42 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 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 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 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
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
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 a03a24be4e feat: add POST /api/score endpoint for Dify real-time scoring
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-22 15:14:19 +08:00
wangweiandCopilot e4d4e4968b feat: add InlineScorer service with LLM client caching
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-22 15:03:43 +08:00
wangweiandCopilot 761faf9c42 feat: add ScoreRequest/ScoreResponse models and SCORE_API_TOKEN setting
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-22 15:00:05 +08:00
wangweiandCopilot 36e5506e2a feat: report_builder uses weighted means; ReportData gains weighted_score_mean
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 17:16:09 +08:00
wangweiandCopilot ce0d2291b0 feat: yaml_patcher and ProfileApplyRequest support metric_weights and doc_weights
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 17:02:21 +08:00
wangweiandCopilot 480f6d66ea feat: use weighted metric means and add weighted_score row to summary.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 16:59:56 +08:00
wangweiandCopilot d371ef7d24 feat: add weighted_score and sample_weight columns to score rows
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 16:53:45 +08:00
wangweiandCopilot 8617eaa5aa feat: add metric_weights and doc_weights to Scenario schema and dataclass
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 16:50:33 +08:00
wangweiandCopilot e0b064587f feat: add metric/doc weight computation module (weights.py)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-06-18 16:47:47 +08:00
wangweiandClaude f5c2dce64a feat(advisor): add optimization advisor module
- rag_eval/advisor/: new package with rules engine, LLM analyzer, writer
  - rules.py: 7-metric diagnostic rules (warning/critical thresholds, top-3 low samples)
  - llm_analyzer.py: Chinese optimization report via judge_model, graceful fallback
  - writer.py: writes optimization_advice.md + log summary
  - __init__.py: run_advisor() entry point (no-op when optimization_advisor=False)
- Scenario.optimization_advisor: new bool field (default False)
- ScenarioModel: same field added, loader.py透传
- RunArtifactPaths.advice_md: new path field
- factory.py: build_models() now public; build_metric_pipeline() accepts pre-built llm/embeddings
- runner.py: lifts llm, passes to pipeline and advisor; calls run_advisor() at end
- siemens online YAML: optimization_advisor: true enabled
- tests: 9 rules tests + 6 writer tests, all pass
- docs: advisor section added to engine-flow.md and architecture.md

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-16 17:06:19 +08:00
wangwei 719c3b4ca4 test: ensure test package structure and all webapp tests pass 2026-06-16 16:27:54 +08:00
wangwei e329f59139 feat: add yaml_patcher service to apply LLM profiles to scenario YAML 2026-06-16 16:21:19 +08:00
wangwei b19054bd66 feat: add /api/llm-profiles CRUD router 2026-06-16 16:18:40 +08:00
wangwei 5d09deb420 feat: add ProfileManager service with JSON persistence 2026-06-16 16:14:31 +08:00
wangwei b98af29449 feat: add LLMProfile pydantic models 2026-06-16 16:10:37 +08:00
Guangfei.Zhao 9cbdc1d95d first commit 2026-06-12 14:02:15 +08:00