65 Commits

Author SHA1 Message Date
Willem Jiang
8d9d767051
feat(eval): add report quality evaluation module and UI integration (#776)
* feat(eval): add report quality evaluation module

Addresses issue #773 - How to evaluate generated report quality objectively.

This module provides two evaluation approaches:
1. Automated metrics (no LLM required):
   - Citation count and source diversity
   - Word count compliance per report style
   - Section structure validation
   - Image inclusion tracking

2. LLM-as-Judge evaluation:
   - Factual accuracy scoring
   - Completeness assessment
   - Coherence evaluation
   - Relevance and citation quality checks

The combined evaluator provides a final score (1-10) and letter grade (A+ to F).

Files added:
- src/eval/__init__.py
- src/eval/metrics.py
- src/eval/llm_judge.py
- src/eval/evaluator.py
- tests/unit/eval/test_metrics.py
- tests/unit/eval/test_evaluator.py

* feat(eval): integrate report evaluation with web UI

This commit adds the web UI integration for the evaluation module:

Backend:
- Add EvaluateReportRequest/Response models in src/server/eval_request.py
- Add /api/report/evaluate endpoint to src/server/app.py

Frontend:
- Add evaluateReport API function in web/src/core/api/evaluate.ts
- Create EvaluationDialog component with grade badge, metrics display,
  and optional LLM deep evaluation
- Add evaluation button (graduation cap icon) to research-block.tsx toolbar
- Add i18n translations for English and Chinese

The evaluation UI allows users to:
1. View quick metrics-only evaluation (instant)
2. Optionally run deep LLM-based evaluation for detailed analysis
3. See grade (A+ to F), score (1-10), and metric breakdown

* feat(eval): improve evaluation reliability and add LLM judge tests

- Extract MAX_REPORT_LENGTH constant in llm_judge.py for maintainability
- Add comprehensive unit tests for LLMJudge class (parse_response,
  calculate_weighted_score, evaluate with mocked LLM)
- Pass reportStyle prop to EvaluationDialog for accurate evaluation criteria
- Add researchQueries store map to reliably associate queries with research
- Add getResearchQuery helper to retrieve query by researchId
- Remove unused imports in test_metrics.py

* fix(eval): use resolveServiceURL for evaluate API endpoint

The evaluateReport function was using a relative URL '/api/report/evaluate'
which sent requests to the Next.js server instead of the FastAPI backend.
Changed to use resolveServiceURL() consistent with other API functions.

* fix: improve type accuracy and React hooks in evaluation components

- Fix get_word_count_target return type from Optional[Dict] to Dict since it always returns a value via default fallback
- Fix useEffect dependency issue in EvaluationDialog using useRef to prevent unwanted re-evaluations
- Add aria-label to GradeBadge for screen reader accessibility
2025-12-25 21:55:48 +08:00
Qiyuan Jiao
829cb39b25
fix: Optimize the performance of stream data processing and add anti-… (#642)
* fix: Optimize the performance of stream data processing and add anti-shake and batch update mechanisms

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* 修复消息批量更新重复问题

- 将 pendingUpdates 从数组改为 Map,使用 message.id 作为键
- 避免在16ms窗口内多次更新同一消息导致的重复处理
- 优化了批量更新性能,减少冗余的映射操作

* fix lint error

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2025-10-22 23:08:18 +08:00
Willem Jiang
1a16677d1a
fix: unescape markdown-escaped characters in math formulas to fix #608 (#637)
When editing reports, tiptap-markdown escapes special characters (*, _, [, ])
which corrupts LaTeX formulas. This fix:

1. Adds unescapeLatexInMath() function to reverse markdown escaping within
   math delimiters ($...$ and 94410...94410)
2. Applies the unescape function in the editor's onChange callback to clean
   the markdown before storing it
3. Adds comprehensive tests covering edge cases and round-trip scenarios

The fix ensures formulas like $(f * g)[n]$ remain unescaped when editing,
preventing display errors after save/reload.
2025-10-21 10:06:31 +08:00
Willem Jiang
58c1743ed5 fix: resolve math formula display abnormal after editing report
This fix addresses the issue where math formulas become corrupted or
incorrectly displayed after editing the generated report in the editor.

**Root Cause:**
The issue occurred due to incompatibility between markdown processing
in the display component and the Tiptap editor:
1. Display component used \[\] and \(\) LaTeX delimiters
2. Tiptap Mathematics extension expects $ and 70868 delimiters
3. tiptap-markdown didn't have built-in math node serialization
4. Math syntax was lost/corrupted during editor save operations

**Solution Implemented:**
1. Created MathematicsWithMarkdown extension that adds markdown
   serialization support to Tiptap's Mathematics nodes
2. Added math delimiter normalization functions:
   - normalizeMathForEditor(): Converts LaTeX delimiters to $/70868
   - normalizeMathForDisplay(): Standardizes all delimiters to 70868
3. Updated Markdown component to use new normalization
4. Updated ReportEditor to normalize content before loading

**Changes:**
- web/src/components/editor/math-serializer.ts (new)
- web/src/components/editor/extensions.tsx
- web/src/components/editor/index.tsx
- web/src/components/deer-flow/markdown.tsx
- web/src/core/utils/markdown.ts
- web/tests/markdown-math-editor.test.ts (new)
- web/tests/markdown-katex.test.ts

**Testing:**
- Added 15 comprehensive tests for math normalization round-trip
- All tests passing (math editor + existing katex tests)
- Verified TypeScript compilation and linting

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-10-15 08:52:50 +08:00
Willem Jiang
2a6455c436
feature: add formula rander in the markdown (#611)
* feature: add formula rander in the markdown

* fixed the lint errors
2025-10-11 23:05:09 +08:00
HagonChan
c214999606
feat: add strategic_investment report style (#595)
* add strategic_investment mode

* make format

* make lint

* fix: repair
lint-frontend
2025-09-24 09:50:36 +08:00
lele3436
26a587c24e
fix: frontend supports chinese for listing datasets in RAG (#582)
* fix-web-rag

* Update resource-suggestion.tsx
2025-09-14 20:19:56 +08:00
道心坚定韩道友
f17e5bd6c8
FIX/Adapt message box to handle long text in frontend (#466)
* fix:ui

* fix:ui bug

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2025-08-21 10:31:54 +08:00
orifake
e6ba1fcd82
fix: JSON parse error in link.tsx (#448)
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2025-07-20 14:14:18 +08:00
Willem Jiang
2121510f63
fix:catch toolCalls doesn't return validate json (#405)
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
2025-07-12 23:31:43 +08:00
vvky
5abf8c1f5e
fix: correctly remove outermost code block markers in model responses (fix markdown rendering issue) (#386)
* fix: correctly remove outermost code block markers in frontend

* fix: correctly remove outermost quote block markers in 'dropMarkdownQuote'

* fix: correctly remove outermost quote block markers in 'dropMarkdownQuote'

* fix: correctly remove outermost quote block markers in 'dropMarkdownQuote'

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2025-07-12 22:19:30 +08:00
johnny0120
e1187d7d02
feat: add i18n support and add Chinese (#372)
* feat: add i18n support and add Chinese

* fix: resolve conflicts

* Update en.json with cancle settings

* Update zh.json with settngs cancle

---------

Co-authored-by: johnny0120 <15564476+johnny0120@users.noreply.github.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
Co-authored-by: Willem Jiang <143703838+willem-bd@users.noreply.github.com>
2025-07-12 15:18:28 +08:00
JeffJiang
52dfdd83ae
fix: next server fetch error (#374) 2025-06-27 14:23:04 +08:00
JeffJiang
03e6a1a6e7
fix: mcp config styles (#320) 2025-06-13 18:01:19 +08:00
LeoJiaXin
397ac57235
fix: input text not clear when click submit button (#303) 2025-06-11 11:11:48 +08:00
DanielWalnut
1cd6aa0ece
feat: implement enhance prompt (#294)
* feat: implement enhance prompt

* add unit test

* fix prompt

* fix: fix eslint and compiling issues

* feat: add border-beam animation

* fix: fix importing issues

---------

Co-authored-by: Henry Li <henry1943@163.com>
2025-06-08 19:41:59 +08:00
DanielWalnut
0e22c373af
feat: support to adjust writing style (#290)
* feat: implment backend for adjust report style

* feat: add web part

* fix test cases

* fix: fix typing

---------

Co-authored-by: Henry Li <henry1943@163.com>
2025-06-07 20:48:39 +08:00
JeffJiang
4ddd659d8d
feat: rag retrieving tool call result display (#263)
* feat: local search tool call result display

* chore: add file copyright

* fix: miss edit plan interrupt feedback

* feat: disable pasting html into input box
2025-05-29 19:52:34 +08:00
JeffJiang
7e9fbed918
fix: editing plan style (#261) 2025-05-29 10:46:05 +08:00
JeffJiang
fcbc7f1118
revert: scroll container display change (#258) 2025-05-28 19:23:32 +08:00
JeffJiang
d14fb262ea
fix: message block width (#257) 2025-05-28 19:11:20 +08:00
JeffJiang
9888098f8a
fix: message input box reflow (#252) 2025-05-28 16:38:28 +08:00
JeffJiang
462752b462
feat: RAG Integration (#238)
* feat: add rag provider and retriever

* feat: retriever tool

* feat: add retriever tool to the researcher node

* feat: add rag http apis

* feat: new message input supports resource mentions

* feat: new message input component support resource mentions

* refactor: need_web_search to need_search

* chore: RAG integration docs

* chore: change example api host

* fix: user message color in dark mode

* fix: mentions style

* feat: add local_search_tool to researcher prompt

* chore: research prompt

* fix: ragflow page size and reporter with

* docs: ragflow integration and add acknowledgment projects

* chore: format
2025-05-28 14:13:46 +08:00
Leo Hui
a43db94fb6
feat: refactor crawler trust link style (#166)
* feat: refactor crawler trust link style

* feat: enhance link credibility checks in Markdown and related components
2025-05-15 17:17:10 +08:00
JeffJiang
8802eea0ba
fix: report editor styles (#163)
* fix: report editor styles
2025-05-15 15:18:01 +08:00
JeffJiang
86295ed195
fix: hallucination link warn (#158) 2025-05-15 10:58:24 +08:00
JeffJiang
bf4820c68f
Check the output links are hallucinations from AI (#139)
* feat: check output links if a hallucination from AI
2025-05-15 10:39:53 +08:00
Leo Hui
a14ca92c36
refactor: extract link and image components for Markdown rendering (#119) 2025-05-14 10:45:34 +08:00
Henry Li
b2c9e5f893 fix: img with empty URL 2025-05-13 09:35:06 +08:00
Henry Li
4ae9508c54 fix: fix compiling issues 2025-05-13 08:57:09 +08:00
Henry Li
cadf6b5bcf
feat: use number ticker to display star count (#89) 2025-05-12 23:15:43 +08:00
Henry Li
07f965f0df refactor: rename to animated 2025-05-12 11:59:24 +08:00
Henry Li
28b65d7a93 feat: Enhance markdown's anti-shake 2025-05-12 11:59:24 +08:00
Nonoroazoro
9260c84005
fix: auto-scrolling to the bottom occasionally fails when toggling research (#7) 2025-05-08 19:49:56 +08:00
Li Xin
40c947f15e refactor: move to landing/components 2025-05-02 21:23:55 +08:00
Li Xin
cdb1492cef feat: remove TooltipProvider 2025-05-02 17:24:07 +08:00
Li Xin
ad2a9ccd70 chore: add slider 2025-05-02 17:23:45 +08:00
Li Xin
fdfc607747 refactor: extract components folder 2025-05-02 10:43:14 +08:00
Li Xin
aeca7a5707 chore: update replays 2025-05-01 22:41:37 +08:00
Li Xin
2e9fb26f6b fix: fix eslint 2025-04-30 09:42:13 +08:00
Li Xin
8a11f07b82 chore: add shine-border 2025-04-29 15:47:39 +08:00
Hui Xuejie
24b42ab466 style(page): adjust the footer text style and layout of the case study section 2025-04-29 14:00:37 +08:00
Shi Tianxin
35eef5fe11 style(page): adjust grid layout and visibility classes 2025-04-29 11:08:54 +08:00
Li Xin
198e53b327 feat: change scale of hovering state 2025-04-28 17:00:54 +08:00
Jiang Feng
53d5b68ac8 feat: disable ai ask in replay mode 2025-04-28 10:29:36 +08:00
Jiang Feng
777f3171f7 refactor: rearrange the bubble menus 2025-04-28 10:29:35 +08:00
Jiang Feng
f35131da19 feat: enhance ResearchBlock tab functionality 2025-04-28 10:29:35 +08:00
Jiang Feng
0e10362639 refactor: comment out unused "Fix grammar" option in AI selector commands 2025-04-28 10:29:35 +08:00
Jiang Feng
906df61d81 feat: use tailwindcss-typography as markdown styling 2025-04-28 10:29:35 +08:00
Jiang Feng
741e2f0e62 feat: add tiptap table extension 2025-04-28 10:29:35 +08:00