Commit Graph

784 Commits

Author SHA1 Message Date
euvre
86530931fe fix(agent): set exp_user_id and name on session creation so exploration shows session titles (#17327) 2026-07-24 11:36:20 +08:00
Haruko386
74218bdd6a fix: search chunk cannot get result (#17328) 2026-07-24 11:01:30 +08:00
euvre
80d61ac8e2 fix(agent): return tavily tool errors as result instead of crashing the ReAct agent (#17274) 2026-07-24 10:57:18 +08:00
Hz_
e66d617f4f fix(go-model): default Jina rerank top_n to document count (#17242)
## Summary

- Default Jina rerank `top_n` to the document count
- Add coverage for default and explicitly configured `top_n` values

## Testing

- `bash build.sh --test -c -o /tmp/ragflow-models.test
./internal/entity/models`
- `git diff --check`
2026-07-24 10:53:09 +08:00
Hz_
339bba8793 refactor(go-models): share chat response handling (#17289)
## Summary

- Add provider-specific DeepSeek chat response handling aligned with its
documented schema.
- Share Zhipu and DeepSeek usage accounting and chat response helpers.

## Testing

- `go test -c -o /tmp/ragflow-models.test ./internal/entity/models`

#17284
2026-07-24 10:51:37 +08:00
euvre
40388c4a71 fix(models): surface MiniMax rate-limit and API errors instead of generic messages (#17292) 2026-07-24 09:54:08 +08:00
euvre
99bea630b0 fix: agent session round count not incremented in Go mode (#17295) 2026-07-24 09:53:58 +08:00
Jack
902d05b22b feat: parser component param check and family mapping fixes (#17312)
## Summary

Adds construction-time parameter validation to the ingestion
`ParserComponent` (mirroring the applicable subset of Python
`ParserParam.check()`), fixes a family-mapping mismatch that silently
skipped `output_format` validation and setup configuration for
image/audio files, and aligns the no-CGO parser stubs with the CGO
variants by threading `context.Context` through `ParseWithResult`.
2026-07-23 22:06:22 +08:00
Jin Hai
61201e437d Go: fix context (#17277)
### Summary

Continue to add context

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-23 21:48:54 +08:00
qinling0210
a84d2ae3d2 fix(infinity): avoid hangs with pooled connections and bounded timeouts (#17287)
### Summary

**Issue**
When calling Infinity under concurrent load, one shared connection was
reused across concurrent operations, it just hangs.
 

**Solution**
Avoid hangs with pooled connections and bounded timeouts
2026-07-23 20:37:38 +08:00
euvre
4dfa5b145b fix: chat attachments not used in Go mode (#17259) 2026-07-23 20:24:13 +08:00
Jack
d12fd3b79d feat: parser pages range and parse type validation for dataset/document (#17293)
## Summary

Adds page-range parsing support to the Go-native pipeline path and
introduces strict `parse_type` validation for both dataset and document
update endpoints.

## What changed

### Pages range parsing
- **`internal/utility/pdf_pages.go`** — `NormalizePDFPages`: normalizes
raw page ranges (list of `[from,to]` 1-indexed inclusive ranges) into
sorted, merged, deduplicated `[][]int`. Invalid ranges are dropped.
- **`internal/ingestion/pipeline/pdf_pages.go`** —
`NormalizeParserConfigPages`: walks any parser_config map and normalizes
`"pages"` values under every component → filetype setup, so the
persisted config always carries clean, merged ranges.
- **`internal/deepdoc/parser/pdf/parser.go`** — integrates
`resolvePagesToProcess` to filter parsed PDF pages by the configured
ranges.
- Pipeline integration (parser pages):
`internal/parser/parser/pdf_parser_common.go`, `chunk_process.go`, plus
associated e2e and unit tests.

### Parse type validation (shared logic)
- **`internal/service/parser_mode.go`** (new) — `ValidateParseTypeMode`:
shared function that validates `parse_type` (1=BuiltIn/parser_id,
2=Pipeline/pipeline_id) and ensures the corresponding field is present.
Used by both dataset and document update endpoints.
- **`internal/service/dataset/crud.go`** / `update.go` — replaces inline
`isPipelineMode`/`isBuiltinMode` computation with the shared
`service.ValidateParseTypeMode`.
- **`internal/service/document/document_dataset_update.go`** — adds
strict `parse_type` validation in `validateDatasetDocumentUpdate`,
simplifies the reparse logic to a two-way switch (isBuiltin/isPipeline)
now that parse_type is always valid.
- **`internal/service/document/document.go`** — adds `ParseType` field
to `UpdateDatasetDocumentRequest`.
- **`internal/service/document/document_dataset_update.go`** —
`updateDocumentParserConfig` fallback path when DSL loading fails.
- **`internal/service/parser_mode_test.go`** (new) — test coverage for
nil, invalid, and missing-field scenarios.

### Frontend
- **`web/src/interfaces/request/document.ts`** — adds `parseType` to
`IChangeParserRequestBody`.
- **`web/src/hooks/use-document-request.ts`** —
`useSetDocumentPipelineParser` sends `parse_type` in the PATCH payload.
- **`web/src/pages/dataset/dataset/use-change-document-parser.ts`** —
Go/Python branching for the document parser config dialog.
-
**`web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`**
— `buildSubmitData` returns `parseType` (bugfix: was dropped from the
return value).

### Test changes
- **Removed**: 2 tests that verified the old "mutually exclusive" error
(replaced by `ValidateParseTypeMode` coverage).
- **Modified**: 6 tests across document and dataset packages to include
`ParseType` in request structs.
- **Added**: new e2e tests for pages parsing (`pages_e2e_test.go`,
`pdf_parser_pages_e2e_test.go`) and unit tests for `NormalizePDFPages`,
`NormalizeParserConfigPages`, `resolvePagesToProcess`.

## Backward compatibility
- The `parse_type` field is **required** when `parser_id` or
`pipeline_id` is sent. This changes the contract for both dataset and
document PATCH endpoints, but aligns the Go backend with the existing
frontend behavior (the frontend already sends `parse_type`). Callers
that omit `parse_type` when updating parser/pipeline selections will
receive a clear error message.
- Existing callers that only update fields like `name`, `enabled`, or
`meta_fields` are unaffected.
- Test updates ensure all known call sites are compliant.
2026-07-23 19:57:27 +08:00
euvre
fce2a94fe0 fix(go): resolve custom tenant model in LLM agent canvas component (#17187) 2026-07-23 19:37:13 +08:00
Lynn
c3e03f5c06 Fix: update base_url and model list for provider tencent Hunyuan (#17304) 2026-07-23 19:24:54 +08:00
Haruko386
5d8dfa610c fix: unable to get prologue in agent bot (#17299)
### Summary

As title
2026-07-23 19:13:45 +08:00
Haruko386
efe6bca5b3 refactor: the request body build (#17286)
### Summary

As title
2026-07-23 19:12:58 +08:00
Lynn
4a2564c7da Feat: OpenAI-API-Compatible (#17276) 2026-07-23 13:39:57 +08:00
Jin Hai
5478f955ab Go: add context to DAO (#17269)
### Summary

DAO layer doesn't use context, this PR is to fix it.

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-23 12:15:58 +08:00
euvre
7b29fc10ca fix(agent): wire memory persistence in Message component (Go runtime) (#17256) 2026-07-23 11:37:59 +08:00
euvre
b095a5511a fix: make qwen3-vl-plus usable as chat/vision model in Go mode (#17254) 2026-07-23 11:14:08 +08:00
euvre
a5aa9489f2 fix(chunker): glue delimiter to preceding segment instead of emitting it as a standalone chunk (#17168) 2026-07-23 10:13:46 +08:00
euvre
3733da2773 fix: count distinct chunk IDs so doc.chunk_num matches actual indexed chunks (#17182) 2026-07-23 09:58:43 +08:00
euvre
db1559f71b fix: prevent thinking content from leaking into visible answer in shared chat (Go mode) (#17225) 2026-07-23 09:58:24 +08:00
Jin Hai
d19a036cda Go: add context to lots of interface (#17253)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-22 22:30:57 +08:00
Hz_
2487d4b8f7 feat(go-models): expand providers (SiliconFlow, Qiniu, Huawei Cloud, Jina) tool call support (#17241)
## Summary

- Add tool call support for SiliconFlow, Qiniu, Huawei Cloud, and Jina
while consolidating shared OpenAI-compatible helpers used by Aliyun
- Handle streaming tool call deltas and advertise tool support for
eligible provider models
- Add cross-provider tool call tests and enable Qiniu connection
verification through the models endpoint

#16990
2026-07-22 21:27:58 +08:00
Haruko386
29292e9622 fix: can get duplicate agent-name when update agent (#17232)
### Summary

As title
2026-07-22 21:27:25 +08:00
Haruko386
1d165c7315 fix: unable to get owner in chat and search (#17244)
### Summary

As title
2026-07-22 21:27:08 +08:00
Haruko386
48b63ab6b0 fix: cannot not show embed ID in listMemories (#17211)
### Summary

As title
2026-07-22 21:26:44 +08:00
euvre
11c08fe62e fix(go): resolve tenant model IDs in memory create/update without hard failure (#17176) 2026-07-22 19:34:41 +08:00
euvre
f4a61efbb4 fix: keep memory card position stable after rename or config update (#17234) 2026-07-22 19:22:29 +08:00
Jack
8669c469d5 fix(ingestion): align laws DSL with Python — heading fallback, colon-title, short-line filter, remove_toc, and image extension mapping (#17200)
## Summary

This PR aligns the Go ingestion pipeline's **Laws** DSL template with
the Python implementation by fixing heading-detection gaps, adds
image-extension support, refactors the **Extractor** component's LLM
resolution, hardens heading detection for CJK text, and makes the
Extractor accept the Python DSL prompt key names
(`sys_prompt`/`prompts`) alongside the Go names.

## Changes

### 1. Picture file-type detection (`internal/utility/file.go`)

Adds explicit mapping for common image extensions (png, jpg, jpeg, gif,
bmp, tiff, tif, webp, svg, ico, avif, heic, apng) → `FileTypeVISUAL`,
with regression tests.

### 2. Laws DSL heading-detection alignment
(`internal/ingestion/component/chunker/`)

Four fixes to `resolveTitleLevels`:

| Fix | What changed | Why |
|-----|-------------|-----|
| **DOCX `ck_type` fallback** | `ckType` field on `lineRecord`,
propagated from `ChunkDoc.CKType` in `recordsFromStructured`. When
`ck_type=="heading"`, assign `fallbackLevel`. | office_oxide extracts
DOCX heading metadata, but the info was lost before reaching the heading
detector. Word headings whose text doesn't match any regex (e.g.
"Introduction") were treated as body. |
| **`make_colon_as_title` promotion** | `isColonTitle()`: promotes lines
ending with `:`/`:` that have sentence-ending punctuation before the
colon and ≥32 runes between them. | Mirrors Python's
`make_colon_as_title` in `rag/nlp/__init__.py`. Triple guard prevents
false positives. |
| **Short/numeric line filter** | Lines with ≤1 rune or purely numeric
are pinned to body level. | Mirrors Python `tree_merge`'s filter of
`sections` where `len(...) <= 1` or `re.match(r"[0-9]+$", ...)`. |
| **PDF `remove_toc`** | `"remove_toc": true` added to the PDF parser
setup in `ingestion_pipeline_laws.json`. | The Go PDF parser already
supports TOC removal; the Book template already enables it. |

### 3. Extractor llm_id resolution
(`internal/ingestion/component/extractor.go`)

Refactored to handle both **bare tenant_model UUIDs** and **composite
model@provider** strings via the shared `resolveModelConfig`
(`dispatch_model.go`):

- **`resolveExtractorChatConfig`** — UUID path calls
`resolveModelConfigByID` directly (one DB hit); composite path goes
through `resolveModelConfig`. Added `isBareTenantModelID` pre-check for
clear errors when a UUID doesn't exist.
- **`resolveExtractorChatTarget`** — propagates resolution errors
instead of silently returning empty driver.
- **`Chat()`** — removed `driver = "dummy"` fallback. Missing driver is
now an explicit error.
- **Removed dead code**: `splitExtractorLLID`,
`findExtractorSoleActiveInstance`.

### 4. `InjectExtractorLLMID` — fallback when no user config
(`internal/common/parser_config.go`)

Injects the tenant's global default LLM into extractor components **only
when their `llm_id` is empty**. Preserves user-selected UUID or
model@provider values.

Priority: user-configured llm_id > tenant global default > error (no
silent dummy fallback).

### 5. `ResponseHeaderTimeout` increase
(`internal/entity/models/base_model.go`)

`ResponseHeaderTimeout` 60s → 120s in `NewDriverHTTPClient`. Reasoning
models with large extraction prompts can take longer than 60s to produce
the first response token.

### 6. CJK rune-aware heading detection
(`internal/ingestion/component/chunker/title.go`)

Two byte-vs-rune bugs that only manifest on CJK text:

| Fix | What changed | Why |
|-----|-------------|-----|
| **`isColonTitle` byte offset** | `body[lastPunct+1:]` →
`body[lastPunct+runeLen:]` via `utf8.DecodeRuneInString` |
`strings.LastIndexAny` returns a byte index; `+1` skips only 1 byte,
corrupting multi-byte CJK punctuation (e.g. `。` = 3 bytes) and inflating
the rune count past the 32-rune threshold → false-positive heading
promotion. |
| **Short-line filter byte count** | `len(text) <= 1` →
`utf8.RuneCountInString(text) <= 1` | Go `len` is UTF-8 bytes; a single
CJK char (3 bytes) passed the filter, but Python's `len` returns 1 →
mismatch. |

### 7. `extractor_tag.go` — log error when llm fails

When `resolveExtractorChatTarget` returned an error, `runAutoTags` will
log error.

### 8. Python DSL prompt-key compatibility
(`internal/ingestion/component/extractor.go`)

The Resume DSL template uses Python-side key names (`sys_prompt`,
`prompts`). `NewExtractorComponent` now accepts them as fallbacks
alongside the Go names:

- `system_prompt` (Go) ← `sys_prompt` (Python) as fallback
- `prompt` (Go string) ← `prompts` (Python array `[{"role","content"}]`,
takes `[0].content`) as fallback

Mirrors the alias pattern already in `internal/agent/component/llm.go`.
`resolveInputs` accepts per-call `sys_prompt` override too.

## Remaining gaps vs Python

| Gap | Scope | Impact |
|-----|-------|--------|
| **TOC removal for TXT/MD/HTML** | Python's `remove_contents_table`
works on all text formats; Go's `remove_toc` is PDF-only. | Low —
plain-text documents rarely contain structured TOCs. |
| **Regex pattern details** | Minor differences in quantifiers, missing
H5/H6 markdown patterns, missing 4-level numbering pattern. | Low — Go's
variants are stricter; DOCX headings are covered by `ck_type` fallback.
|

## Testing

- `TestHierarchyTitleChunker_CKTypeHeadingFallback` — DOCX `ck_type`
heading promotion
- `TestHierarchyTitleChunker_ColonTitlePromotion` /
`_ColonTitleShortLine_Negative` — colon-title promotion + guard
- `TestIsColonTitle_CJKEdgeCase` / `TestIsColonTitle_ASCII_NoRegression`
— CJK byte-offset fix + ASCII regression
- `TestHierarchyTitleChunker_ColonTitlePromotion_CJK_EdgeCase` — CJK
colon edge case through full pipeline
- `TestHierarchyTitleChunker_ShortSingleCJKLineFilter` — single CJK char
filtered to body
- `TestHierarchyTitleChunker_ShortNumericLineFilter` — purely numeric
lines filtered
- `TestGetFileType_ImageExtensions` / `_ExistingFormats_NoRegression` —
image extension mapping
- `TestInjectExtractorLLMID_SkipWhenUUID` / `_SkipWhenComposite` /
`_InjectWhenEmpty` — llm_id injection guard
- `TestIsBareTenantModelID` — UUID detection
- `TestResolveExtractorChatTarget_AtSplitFallback` / `_NoDriver` — @
split fallback without DB
- `TestNewExtractorComponent_SysPromptAlias` / `_PromptsArray` /
`_PromptsArray_PromptWins` / `_SystemPromptWinsOverSysPrompt` — Python
key compatibility
- `TestBuildDOCXJSONSections_List` / `_TextBox` / `_MixedWithList` —
DOCX list/text_box parsing
- Full ingestion test suite passes (chunker, pipeline, task, service,
component packages)
2026-07-22 19:14:32 +08:00
Lynn
32ddf59ac6 Fix: go restful api tests (#17247) 2026-07-22 19:06:08 +08:00
Haruko386
db18766027 fix: unable use agent as a tool in agent component (#17228)
### Summary

As title

<img width="3774" height="2128" alt="image"
src="https://github.com/user-attachments/assets/b1ce69b0-2298-4c0c-92de-8d840938e4f0"
/>
2026-07-22 19:04:55 +08:00
Hz_
45ca5f9a3d fix(go-agent): route graph step errors through exception outputs (#17167)
## Summary

- Route ReAct graph step-limit errors through the Agent `_ERROR` output.
- Align the Go Agent default max rounds with Python by using five
rounds.
- Preserve cancellation, timeout, and configuration errors as real
failures.

## Testing

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

<img width="2050" height="1409" alt="image"
src="https://github.com/user-attachments/assets/108e2d27-e115-4595-91a2-21f90c2531ae"
/>
2026-07-22 19:00:53 +08:00
euvre
e0ae22e83b fix(agent): prevent double reply when Agent node is followed by Message node (#17233) 2026-07-22 14:59:29 +08:00
euvre
bab7302265 fix(go): nil pointer dereference in ZhipuAI Embed method (#17219) 2026-07-22 13:59:06 +08:00
euvre
8408f9a4e2 Go: only unlink file-manager files when deleting documents from a knowledge base (#17175) 2026-07-22 12:14:22 +08:00
euvre
4697ee29aa fix: avoid duplicate document names when linking files to datasets (#17181) 2026-07-22 12:12:23 +08:00
euvre
fe3e87361d fix(agent): restrict permission field edits to canvas owner only (#17185) 2026-07-22 12:09:22 +08:00
euvre
03e583f9bc fix: add create_date field to APIKeyResponse for token list display (#17186) 2026-07-22 12:08:16 +08:00
Hz_
b175ed582f fix(go-agent): support Tavily tool names (#17163)
## Summary

- Register `TavilySearch` and `TavilyExtract` Canvas component names in
the Go Agent tool registry.
- Add regression coverage for building both tools by their Python
component names.

## Testing

- `bash build.sh --test ./internal/agent/tool/...`
- `bash build.sh --test ./internal/agent/component/...`
2026-07-22 10:38:26 +08:00
Haruko386
b9de586043 fix: add accessible check for datasets (#17116)
### Summary

As title:

Some operations on datasets have been fixed as they previously lacked
authentication, preventing team members from proper or correct usage.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-21 19:20:56 +08:00
Haruko386
d57edee9c3 Go: add funASR provider (#17171)
### Summary

As title

verif ied from CLI

```
RAGFlow(api/default)>  asr with 'paraformer@test@funasr' audio './internal/test.wav' param '{"language": "en"}'
+----------------------------------------------------------------------------------------------------------------------+
| text                                                                                                                 |
+----------------------------------------------------------------------------------------------------------------------+
| The examination and testimony of the experts enabled the commission to conclude that five shots may have been fired. |
+----------------------------------------------------------------------------------------------------------------------+
```
---

<img width="2876" height="1377" alt="image"
src="https://github.com/user-attachments/assets/4cee62c6-1c71-43ce-b398-4d9fbff33c3c"
/>

```bash
INFO:     127.0.0.1:51910 - "POST /v1/audio/transcriptions HTTP/1.1" 200 OK██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  2.19it/s]
INFO:     127.0.0.1:60934 - "GET /v1/models HTTP/1.1" 200 OK%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  2.10it/s]
```

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-07-21 19:20:34 +08:00
Lynn
340d30eb12 Fix: verify model api (#17183) 2026-07-21 19:09:46 +08:00
euvre
3f9d9529b3 fix(file2document): batch link should add to existing KBs, not replace them (#17172) 2026-07-21 19:05:02 +08:00
Lynn
3f5b765a5f Fix(go): check model availability (#17156) 2026-07-21 19:02:14 +08:00
Jin Hai
a5488d035a Go: refactor to avoid conflicts (#17191)
### Summary

1. merge registery test into ingestion
2. move license code to EE version

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-21 18:47:02 +08:00
qinling0210
edeb47cd54 Implement Tagger in Extractor component in GO (#17128)
### Summary

Implement Tagger in Extractor component in GO
2026-07-21 17:52:06 +08:00
qinling0210
0189ca3700 Port PR14140 and PR16881 to GO (#17102)
### Summary

Port
https://github.com/infiniflow/ragflow/pull/14140/
https://github.com/infiniflow/ragflow/pull/16881
2026-07-21 17:46:23 +08:00
Haruko386
08ed962aed fix: Refactor ListConnectors to validate userID and simplify logic (#17152)
### Summary

Trim whitespace from userID and check for empty value. Use userID
directly for listing connectors instead of tenant ID.
2026-07-21 16:47:28 +08:00