Commit Graph

7462 Commits

Author SHA1 Message Date
Jin Hai
b8d06d02e6 Go: add stats (#17061)
### Summary

Add LLM token stats framework

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-18 21:02:07 +08:00
Harsh Kashyap
cafbbd467d fix(api): honor include_parsing_status in List Datasets endpoint (#16913)
Fixes #16855.

## Problem

`ListDatasetReq` declares `include_parsing_status: bool = False` but
`dataset_api_service.list_datasets` ignored the flag, so callers passing
`include_parsing_status=true` got `null` for every parsing-status field.
The helper that produces the counts
(`DocumentService.get_parsing_status_by_kb_ids`) already existed and
returned the documented shape; it just wasn't being called.

## Fix

Read the flag in `list_datasets`, call the helper only when truthy, and
attach per-kb counts to each record before serialisation. The flag
follows the same string-coercion idiom already used for `desc` in this
function.

When the flag is false or absent, no new field is added to the response,
so the change is non-breaking and additive. Existing callers see
byte-identical responses.

## Tests

New file
`test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py`
(7 tests, all passing):

-
`test_list_datasets_without_include_parsing_status_does_not_call_helper`
- `test_list_datasets_with_include_parsing_status_true_attaches_counts`
- `test_list_datasets_with_include_parsing_status_string_true`
- `test_list_datasets_with_include_parsing_status_false_skips_helper`
-
`test_list_datasets_with_include_parsing_status_string_false_skips_helper`
-
`test_list_datasets_with_empty_kb_list_skips_helper_even_when_flag_true`
-
`test_list_datasets_with_include_parsing_status_missing_kb_gets_empty_dict`

```
$ uv run pytest test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py -v
============================== 7 passed in 0.19s ==============================
```

## Files changed

- `api/apps/services/dataset_api_service.py` (+15)
-
`test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py`
(new)

## Follow-up (out of scope)

Register the `parsing_status` field in the OpenAPI response schema at
`api/apps/restful_apis/dataset_api.py` so Swagger / generated clients
document it.

Co-authored-by: Harsh23Kashyap <harsh@example.com>
2026-07-18 20:50:00 +08:00
zcxGGmu
afc12b2bff fix: preserve mineru cross-page table positions (#17017)
## Summary
- Read MinerU `_middle.json` alongside the content-list output.
- Preserve each matched table block as a separate PDF position tag so
cross-page tables expose all highlighted ranges.
- Keep enrichment limited to table outputs and require the first-page
bbox anchor before adding matching continuation blocks.

## Tests
-
`/Users/zq/.config/superpowers/worktrees/ragflow/issue-16992-pdf-table-coordinates/.venv/bin/python
-m pytest --confcutdir=test/unit_test/deepdoc/parser
test/unit_test/deepdoc/parser/test_mineru_parser.py -q`
-
`/Users/zq/.config/superpowers/worktrees/ragflow/issue-16992-pdf-table-coordinates/.venv/bin/ruff
check deepdoc/parser/mineru_parser.py
test/unit_test/deepdoc/parser/test_mineru_parser.py`
-
`/Users/zq/.config/superpowers/worktrees/ragflow/issue-16992-pdf-table-coordinates/.venv/bin/python
-m py_compile deepdoc/parser/mineru_parser.py
test/unit_test/deepdoc/parser/test_mineru_parser.py`
- `git diff --check`

Closes #16883

---------

Co-authored-by: zq <zhouquan1511@163.com>
2026-07-18 20:48:52 +08:00
Andrew Chen
b7a3a2760f fix(metadata): Infinity push-down must reject multi-valued-unsafe negative ops (≠, not in) (#16943)
### What problem does this PR solve?

The Elasticsearch and Infinity metadata push-down translators are meant
to be
interchangeable pre-filters that both mirror the in-memory `meta_filter`
fallback — the shared test section is even titled
*"is_pushdown_supported
pre-check (same logic for both backends)"*. But the two
`is_pushdown_supported`
implementations diverge:

- `common/metadata_es_filter.py` defines
`MULTIVALUE_UNSAFE_NEGATIVE_OPS = frozenset({"≠", "not in"})` and
refuses
  push-down for those operators.
- `common/metadata_infinity_filter.py` has **no such guard** and pushes
them
  down.

**Why the guard exists:** `meta_fields.<key>` can hold a JSON array, and
the
in-memory `meta_filter` matches a document when **any** of its values
satisfies
the predicate (per-value-bucket semantics). A document whose `tag` is
`[a, b]`
therefore still matches `tag ≠ a` — bucket `b` satisfies it. The
Infinity
push-down emits `NOT JSON_CONTAINS(meta_fields, '$.tag', '"a"')`, which
means
*"the array contains no `a` at all"*, so it **silently drops** that
document.
Same divergence for `not in`. The result: `tag ≠ a` / `tag not in (...)`
under-counts results for any document that has the excluded value
alongside
others, but only on the Infinity backend.

This is on a live production path:
`DocMetadataService._filter_doc_ids_by_metadata_infinity`
(`api/db/services/doc_metadata_service.py:948`) calls this exact
`is_pushdown_supported` as the sole gate before building the Infinity
SQL,
mirroring the ES branch at line 880 which uses the guarded ES version.

Reproduction (both real modules, no services needed):

```python
>>> from common import metadata_es_filter as es, metadata_infinity_filter as inf
>>> f = [{"op": "≠", "key": "tag", "value": "a"}]
>>> es.is_pushdown_supported(f), inf.is_pushdown_supported(f)
(False, True)   # ES falls back to in-memory (correct); Infinity pushes down (wrong)
```

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

### Fix

Add the same `MULTIVALUE_UNSAFE_NEGATIVE_OPS` set to
`metadata_infinity_filter` and reject those operators in
`is_pushdown_supported`, so a single such filter forces the whole
request to
the in-memory path — the only place the per-bucket semantics are
reproduced.
`not contains` is intentionally still allowed, matching the ES backend
(`all(not contains)` == `not any(contains)`, which the push-down
expresses
correctly on multi-valued fields). The `≠` / `not in` translators
themselves
are unchanged — they remain correct for the in-memory-fallback path;
only the
push-down eligibility gate is fixed.

### Testing

- Confirmed `is_pushdown_supported([{op}])` now returns `False` for `≠`
and
  `not in` on **both** backends (previously ES=False, Infinity=True).
- Added `test_pushdown_check_rejects_multivalue_unsafe_negative_ops`,
which
asserts both backends reject these ops. Confirmed red→green: it fails
against
  the pre-fix Infinity module, passes after.
- `ruff check` / `ruff format --check` clean.

### Note on overlap

Open PR #16833 also edits
`test/unit_test/common/test_metadata_filter.py`, but
only **appends** at the end of the file (line 640+) and changes
`metadata_es_filter.py` / `metadata_utils.py`, not the Infinity module —
no
overlap with this change.

### Disclosure

AI-assisted (Claude Code): the divergence was surfaced by an AI-assisted
review
pass, but I independently reproduced it against the real modules,
confirmed the
production call path, and verified the fix and test before submitting.

Signed-off-by: Andrew Chen <48723787+chuenchen309@users.noreply.github.com>
Signed-off-by: chuenchen309 <48723787+chuenchen309@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 18:47:25 +08:00
Haruko386
efc675cf50 fix: forget to take reference/prompt in pipeline final (#17032)
### Summary

As title:

fixed: 
<img width="3710" height="2036"
alt="img_v3_0213m_b4b79593-43cd-4dd3-a1dc-ce8a6b34645g"
src="https://github.com/user-attachments/assets/5045f2d2-cef1-4f91-9d3b-c79da78a6716"
/>
2026-07-18 18:45:57 +08:00
Hz_
8945f66814 fix(go-agent): handle await response prompts correctly (#17044)
## Summary

- Prevent downstream agents from reusing stale `sys.query` values.
- Resolve Await Response tips from the current canvas state and honor
`enable_tips`.

## Testing

- `bash build.sh --test ./internal/agent/component/...`
- `bash build.sh --test ./internal/agent/canvas/...`
2026-07-18 18:44:00 +08:00
Haruko386
4a134e6035 Go: add tools for xiaomi provider (#17054)
### Summary

As title

<img width="3716" height="2033" alt="image"
src="https://github.com/user-attachments/assets/09aac6c5-0352-4656-a89b-ae1bcacf4ef1"
/>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-18 18:43:15 +08:00
Yash Raj Pandey
20a7c7d17a Fix: Q&A CSV parser splices wrong text when a field opens with a quote (#16881)
### Problem

Parsing a Q&A `.csv` can splice unrelated text into the wrong answers
(reported in #16791).

### Root cause

The `.csv` branch of `rag/app/qa.py`'s `chunk()` builds records with
`csv.reader(lines, delimiter=delimiter)` (default `quotechar='"'`), but
then indexes `lines[i]` by the reader's *record* index in `answer +=
"\n" + lines[i]`. When a line's field opens with a `"`, `csv.reader`
treats it as an unclosed quoted field and merges several physical lines
into one record. From there the record index permanently desyncs from
the physical line numbers, so `lines[i]` returns the wrong line and
unrelated Q&A content gets appended to the wrong answer.

### Reproduction (stdlib only)

```python
import csv
lines = 'Q1,A1\n"quoted answer start\ncontinues here,extra\nQ2,A2\n'.split("\n")
list(csv.reader(lines, delimiter=","))
# record 1 swallows 3 physical lines: ['quoted answer startcontinues here,extraQ2,A2']
# -> the reader index no longer matches lines[i]

list(csv.reader(lines, delimiter=",", quoting=csv.QUOTE_NONE))
# one physical line per record; index stays aligned
```

### Fix

Pass `quoting=csv.QUOTE_NONE` so one physical line maps to one record,
keeping the reader index aligned with `lines[i]` (the surrounding code
already relies on that 1:1 mapping).

Fixes #16791.

---------

Signed-off-by: Yash Raj Pandey <yashpn62@gmail.com>
Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
2026-07-18 18:31:43 +08:00
zcxGGmu
a7b193d77b fix: align pdf table structure coordinates (#17016)
### What problem does this PR solve?

Table structure recognition rows, columns, headers, and spans are
produced in cropped table image coordinates, while OCR boxes are matched
later in page-cumulative coordinates. Comparing those boxes without
normalization can skip or misassign table row and column metadata.

Closes #16992.

### What is changed?

- Map TSR components from cropped or rotated table-image coordinates
back into page-cumulative coordinates before matching OCR boxes.
- Reuse one inverse rotation transform for rotated OCR boxes and TSR
components.
- Keep TSR layout ids in the same `table-N` form used by table OCR
boxes.
- Sort columns by mapped page x-coordinate after coordinate
normalization.
- Add focused unit coverage for page offsets, zoom scaling, and
90/180/270 degree rotated tables.

### Type of change

- [x] Bug fix
- [x] Test coverage

### How has this been tested?

- `uv run --group test pytest
test/unit_test/deepdoc/parser/test_pdf_parser_table_coordinates.py -q`
- `uv run --no-sync --group test pytest
--confcutdir=test/unit_test/deepdoc/parser
test/unit_test/deepdoc/parser/test_pdf_parser_table_coordinates.py -q`
- `uv run ruff check deepdoc/parser/pdf_parser.py
test/unit_test/deepdoc/parser/test_pdf_parser_table_coordinates.py`
- `uv run --no-sync python -m py_compile deepdoc/parser/pdf_parser.py
test/unit_test/deepdoc/parser/test_pdf_parser_table_coordinates.py`
- `git diff --check`

A later dependency-sync attempt was blocked while resolving the
`en-core-web-sm` wheel from GitHub, and the repository-level unit-test
conftest can try to download missing NLTK `wordnet` data when it is not
already present locally. The focused parser test above does not require
that data fixture.

---------

Co-authored-by: zq <zhouquan1511@163.com>
2026-07-18 18:22:33 +08:00
Jack
10c00a9614 Feat: add built in DSL file API (#17003)
### Summary

1. list and get by id API for builtin DSL
2. add DSL default component param values validation
3. remove all hard code keys for parser config
2026-07-18 11:00:08 +08:00
zcxGGmu
1c0432a816 Fix centered PDF title reading order (#17009) 2026-07-18 01:31:27 +08:00
deadtrickster
982b9c7b25 fix(deepdoc): recover word boundaries for non-Latin scripts; skip OCR fallback the recogniser can't serve (#16958) 2026-07-18 00:36:25 +08:00
Jin Hai
8ebdc02cf6 Go: add LLM usage (#17049)
### Summary

```
RAGFlow(api/default)> CHAT WITH 'glm-4-flash@new_test@zhipu-ai' MESSAGE '30 words describes LLM';
Answer: Hello! I'm ChatGLM, an AI assistant. Feel free to ask me any questions or request help with any tasks.
Input tokens: 5
Output tokens: 28
Time: 12.748241
```

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-17 21:28:43 +08:00
Wang Qi
c420de0dc5 Security fix: CVE-2025-21521 (#17046) 2026-07-17 19:35:20 +08:00
maoyifeng
6cc30bcd91 CI: modify testcase to p3 (#17047)
### Summary

CI: modify longtime testcase to p3
2026-07-17 19:24:32 +08:00
euvre
7ec2e9171b fix(web): add missing provider homepage links in Available models panel (#17040) 2026-07-17 17:36:15 +08:00
euvre
6da5085073 feat: add chat-level TTS and ASR endpoints for Go API server (#17036) 2026-07-17 17:22:57 +08:00
Wang Qi
6a1224ba04 Fix table parse: combined column (#17039) 2026-07-17 16:58:54 +08:00
Haruko386
344477f3f0 fix: loop component usage issue (#17028)
### Summary

As title

<img width="3718" height="2029" alt="image"
src="https://github.com/user-attachments/assets/227bcd8b-e5b8-465e-983c-c0c0650a4ea5"
/>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-17 16:40:42 +08:00
Lynn
b6ee6c3116 Fix: sample_rate in siliconflow tts model call (#17043) 2026-07-17 16:29:57 +08:00
Haruko386
ddd7fc02ee feat: support yahoo_finance search (#17022)
### Summary

As title

<img width="3116" height="1949" alt="image"
src="https://github.com/user-attachments/assets/13692cb2-06d6-470b-b13e-182773c8225a"
/>
2026-07-17 16:05:19 +08:00
Hz_
e55bc969f9 fix(go-agent): filter SSE done sentinel from model stream (#17034)
## Summary

- Filter the `[DONE]` transport sentinel from Eino model streams
- Add regression coverage for stream messages and callbacks

## Testing

- `bash build.sh --test ./internal/entity/models`
- `bash build.sh --test ./internal/agent/component`
- `bash build.sh --test -run
'Test(AgentChatCompletions_Stream|RunAgent_Stream)' ./internal/handler`
2026-07-17 15:55:00 +08:00
Hz_
1b77e3ebcd fix(go-agent): preserve canvas system state across turns (#17010)
## Summary

- Preserve request-scoped system variables such as files and user IDs
during Canvas execution.
- Persist conversation history, turn counts, and tool memory in the
session DSL across turns.
- Parse agent uploads into `sys.files` and align system variable
rendering with Python.

## Testing

- `bash build.sh --test ./internal/agent/...`
- `bash build.sh --test ./internal/service/...`

<img width="1896" height="1232" alt="image"
src="https://github.com/user-attachments/assets/b420cd97-53c3-470f-a3e1-d39cea26a213"
/>
2026-07-17 15:53:58 +08:00
Lynn
7336c27814 Fix: set Builtin models as default model (#17029) 2026-07-17 15:53:45 +08:00
Wang Qi
bee524892d Doc: fix doc (#17033) 2026-07-17 15:08:09 +08:00
qinling0210
995e405e8c Support pipeline DSL modification through dataset configuration (backend) (#16991)
…end)

### Summary

Support pipeline DSL modification through dataset configuration
(backend)

Key modification: knowledgebase.parser_config

---------

Co-authored-by: yzc <yuzhichang@gmail.com>
2026-07-17 14:40:09 +08:00
buua436
b32d5fd86b fix: render readable wiki artifact links (#17011) 2026-07-17 14:28:20 +08:00
chanx
c5cf9b473d fix(model-provider): replace per-card auto-save with batch Save-all (#17025) 2026-07-17 14:26:49 +08:00
Wang Qi
6b3a350a57 Fix cv model siliconflow and zhipu cannot describe video, capture 3 images from video and sent to llm (#852) (#17007) 2026-07-17 14:25:22 +08:00
Jin Hai
cf71c7193a Go: update server config (#17027)
### Summary

```
RAGFlow(admin)> list services;
+--------+--------------+----+---------------------+------+---------------+-----------+
| enable | host         | id | name                | port | service_type  | status    |
+--------+--------------+----+---------------------+------+---------------+-----------+
|        | localhost    | 0  | redis               | 6379 | cache         | alive     |
|        | localhost    | 1  | minio               | 9000 | file_store    | alive     |
|        | localhost    | 2  | elasticsearch       | 1200 | retrieval     | alive     |
|        | localhost    | 3  | mysql               | 3306 | meta_data     | alive     |
| false  | localhost    | 4  | jaeger              | 4318 | tracing       | unknown   |
|        | localhost    | 5  | clickhouse          | 9900 | olap          | unknown   |
|        | localhost    | 6  | nats                | 4222 | message_queue | CONNECTED |
|        | 192.168.1.68 | 7  | ragflow-server-9384 | 9384 | api_server    | alive     |
+--------+--------------+----+---------------------+------+---------------+-----------+

```

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-17 13:54:19 +08:00
buua436
27d091b5b6 fix: make await response wait for user input (#16995)
### What problem does this PR solve?

Await Response incorrectly consumed the initial `sys.query` as its
input, so the first user interaction was skipped.

This change makes Await Response wait for actual user input while
preserving the existing initial-query behavior for the Begin node.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
2026-07-17 13:12:42 +08:00
euvre
d0ac79dc96 fix: ASR/VLM/TTS models not selectable in default model settings (#17024) 2026-07-17 13:05:22 +08:00
balibabu
677960716e Feat: Enable the wiki's Markdown editor to navigate to a new Markdown file when a link is clicked. (#17019) 2026-07-17 11:22:18 +08:00
Zhichang Yu
f69ed74670 fix lefthook (#17023) dev-20260717 2026-07-17 11:18:10 +08:00
Jin Hai
7c698f8e4b Python: remove unused index (#17008)
### Summary

Remove below indexes.
```
idx_tenant_langfuse_secret_key
idx_tenant_langfuse_public_key
idx_tenant_langfuse_host
```

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-16 23:00:44 +08:00
balibabu
548f296ead Feat: Visualize session graph data using ArtifactForceGraph. (#16977)
### Summary

Feat: Visualize session graph data using ArtifactForceGraph.
2026-07-16 20:54:58 +08:00
euvre
c599dc6c52 fix: remove dangling MetaFields reference and skip affected Go backend tests (#16983) 2026-07-16 20:20:29 +08:00
Kevin Hu
d5d04ad639 Feat: compilation result navigation in agentic search (#17002)
### Summary

Compilation result navigation in agentic search.
2026-07-16 20:19:32 +08:00
buua436
bd485dbdfe fix: scope compilation template names by group (#16998) dev-20260716-2 2026-07-16 19:37:18 +08:00
Jin Hai
f8474a67f5 Go: tracing framework (#17004)
### Summary

Tracing framework

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-16 19:35:43 +08:00
Lynn
f8cba62108 Fix: sort instance by create_time desc (#16999) 2026-07-16 19:29:21 +08:00
Lynn
f9d7f3d2b4 Fix: add default models for some ocr providers (#16982) 2026-07-16 19:18:48 +08:00
maybehokori
f3a2fb7a10 fix: update somark.tech to somark.cn/somark.ai with purchase URLs (#16892)
## Summary

Update all `somark.tech` references to `somark.cn` (default for China) /
`somark.ai` (for overseas including Taiwan, China; Hong Kong, China;
Macau, China). Users fill in `base_url` manually — default is
`somark.cn`.

### Changes

| File | Change |
|------|--------|
| `constants.py` | Default → `somark.cn` |
| `somark_parser.py` | SAAS_BASE_URL + fallback → `somark.cn` |
| `ocr_model.py` | Default → `somark.cn` |
| `pdf_parser_common.go` | Go default → `somark.cn` |
| `llm.ts` | API key URL → `somark.cn` |
| `en.ts` | Base URL descriptions + purchase URLs |
| `zh.ts` | Base URL descriptions + purchase URLs |

### Purchase URLs
- China: `https://somark.cn/workbench/purchase`
- Overseas: `https://somark.ai/studio/purchase`

---------

Co-authored-by: justinychuang <huangyicheng@soulcode.cn>
Co-authored-by: Jin Hai <haijin.chn@gmail.com>
2026-07-16 19:18:05 +08:00
Haruko386
101155bdc7 fix: support message content (#16980)
### Summary

As Title
<img width="3241" height="1934" alt="image"
src="https://github.com/user-attachments/assets/cb22031c-f200-462a-b871-b4a739e7a66a"
/>
2026-07-16 19:08:36 +08:00
Haruko386
5307ecd520 Go: add tools for moonshot, baidu and minimax (#17000)
### Summary

As title
related to #16990
2026-07-16 19:03:59 +08:00
Jin Hai
c7a623ff81 Go: introduce clickhouse (#16996)
### Summary

Introduce Clickhouse for data statistics.

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-16 18:36:56 +08:00
maoyifeng
caa76fb68e Fix: CI tags cancel running workflow (#17001)
### Summary

1.  Change the CI trigger conditions.  synchronize and  labeled ci
2.  Fix ci: tags canceled running workflow
2026-07-16 17:58:20 +08:00
euvre
feba9e1158 fix: custom empty_response not shown in streaming chat (Go mode) (#16989) 2026-07-16 17:02:40 +08:00
Hz_
9003584e90 fix(go-agent): add input form of ListOperationsComponent and VariableAggregatorComponent (#16987)
## Summary
- Add `GetInputForm()` for `ListOperationsComponent` to expose `Query`
input field in debug UI
- Add `GetInputForm()` for `VariableAggregatorComponent` to expose
`Variables` input field in debug UI

## Test
- Verify input form fields render correctly for both components in the
debug UI
2026-07-16 16:58:38 +08:00
Wang Qi
d8a6cacd0a Fix link file to dataset check the duplicate name (#846) (#16975) 2026-07-16 16:03:27 +08:00