Skip to content

Fix: disable Ollama thinking for vision figure descriptions - #17031

Closed
iwasaki1112 wants to merge 1102 commits into
infiniflow:mainfrom
iwasaki1112:fix/ollama-vision-thinking-mode
Closed

iwasaki1112 wants to merge 1102 commits into
infiniflow:mainfrom
iwasaki1112:fix/ollama-vision-thinking-mode

Conversation

@iwasaki1112

Copy link
Copy Markdown
Contributor

Summary

  • OllamaCV.describe() / describe_with_prompt() call the Ollama Python client's generate() without think=False. Ollama only honors think as a top-level kwarg (not inside options), so Qwen3-family vision models emit a full reasoning trace before the actual figure description.
  • Added think=False to both calls.
  • The think parameter on generate() needs ollama-python>=0.5.1; bumped the pinned lower bound from >=0.5.0 accordingly.

Test plan

  • Verified on a live deployment (Ollama + qwen3.5:9b as the vision model): before the fix, a single figure description took ~6 minutes and ~2800 tokens (dominated by an unsuppressed thinking trace).
  • After the fix, the same figure-description call consistently took 10-60s.
  • Confirmed across a full AI-OCR parsing run over an 86-page PDF with 250+ figures — no errors, all figures processed at the faster pace.

cike8899 and others added 30 commits July 6, 2026 14:48
### Summary

Merge HTTP response functions into common/response.go

---------

Signed-off-by: Jin Hai <[email protected]>
### Summary

Remove redundant functions.
## Summary

Debugging YahooFinance component in agent canvas returns "unknown
component" and "no input_form".
YahooFinance was only registered as an eino tool, not as a runtime
component. The component factory only searches the runtime registry.
- `universe_a_wrappers.go`: add `yahooFinanceComponent` wrapper
delegating to `agenttool.YahooFinanceTool` with `GetInputForm()`
- `fixture_stubs.go`: register `"YahooFinance"` component

## TEST
`go build` and `go test ./internal/agent/component/...` all pass.
…nfiniflow#16675)

## Summary
- Add Go dynamic input form support for ExeSQL and Browser components.
- Align their input form metadata with the Python implementation.
- Add regression tests for `/components/:component_id/input-form`.
…ow#16661)

### Summary

Keep `data` as the uploaded document array when dataset document upload
partially succeeds.

This matches the Python API behavior and allows parse-on-creation to run
for successfully uploaded files when other files in the same folder are
unsupported.
Ports remaining Go parser wiring and PDF backends, adds tenant-aware VLM
dispatch, aligns post-processing with Python, and adds end-to-end
pipeline coverage with a generated six-page PDF.
…omitted (infiniflow#15484)

## Summary

Closes infiniflow#15483.

Default workflow/session agent completions to non-streaming when
`stream` is omitted.

## Changes

- `api/apps/restful_apis/agent_api.py`: `req.get("stream", False)` on
workflow paths.

## Test plan

- [ ] POST workflow completion without `stream`; assert JSON response.
## Summary
Upgrade crawl4ai from 0.8.9 to 0.9.0 to fix GHSA-r253-r9jw-qg44.

## Vulnerability
| Field | Value |
|-------|-------|
| **ID** | GHSA-r253-r9jw-qg44 |
| **Severity** | CRITICAL |
| **Scanner** | trivy |
| **Rule** | `GHSA-r253-r9jw-qg44` |
| **File** | `uv.lock` |
| **Assessment** | Likely exploitable |

**Description**: Crawl4AI: Unauthenticated RCE via Chromium
launch-argument injection in browser_config.extra_args

## Evidence

**Scanner confirmation**: trivy rule `GHSA-r253-r9jw-qg44` flagged this
pattern.

**Production code**: This file is in the production codebase, not
test-only code.

## Threat Model Context

This is a web service - vulnerabilities in request handlers are directly
exploitable by remote attackers.

## Changes
- `pyproject.toml`
- `uv.lock`

## Verification
- [x] Build passes
- [x] Scanner re-scan confirms fix
- [x] LLM code review passed

---
*This change addresses a pattern flagged by static analysis. The code
path handles user-influenced input and the fix reduces the attack
surface against both manual and automated exploitation.*

---
*Automated security fix by [OrbisAI Security](https://orbisappsec.com)*

Co-authored-by: Ling Qin <[email protected]>
### Motivation

This PR evolves the harness from a pure execution runtime into an
**observable, replayable agent evaluation platform**. The current
`harness/graph` checkpoint mechanism is insufficient for true
event-sourced introspection—we need append-only event logs capturing
every tool call, state transition, memory write, and approval decision,
enabling deterministic replay, fork/diff, postmortem analysis, and
time-travel debugging.

### Key Design Goals

1. **Event-Sourced Execution Model**  
Replace coarse checkpoints with granular, append-only event logs. Every
operation becomes a durable event: tool invocation, state mutation,
memory update, human approval. This unlocks deterministic replay,
branching execution histories, and regression datasets derived directly
from production failures.

2. **First-Class Replay & Evaluation Loop**  
Replay is not an afterthought—it is a core primitive. A single live run
seeds an offline corpus that supports: repeated playback, model
substitution, tool result mocking, and strategy comparison. The harness
graduates from "executor" to "continuous evaluation platform" where
failed production traces convert directly into offline regression
suites.

3. **Operational Observability**  
   Beyond raw traces, expose metrics that prove stability over time:
   - Tool success / failure rates
   - Approval latency distributions
   - Retry frequencies
   - Checkpoint restore reliability
   - Memory retrieval quality
   - Cost per completed task
   - Fork replay pass rates

The underlying thesis: the bottleneck for most agent systems is not
execution capability, but the inability to **demonstrate continuous,
measurable improvement**.


### Type of change

- [x] New Feature (non-breaking change which adds functionality)
…flow#14140)

## Summary
- Add language-aware Snowball stemmer to `RagTokenizer` supporting 16
languages (Dutch, German, French, Spanish, etc.)
- Thread the KB `language` parameter through the full tokenization
pipeline (14 parser modules + task executor)
- Add Dutch to the frontend language lists and cross-language form

## Problem
RAGFlow uses the English Porter stemmer + WordNet lemmatizer for **all**
BM25 tokenization, regardless of the knowledge base language setting.
This produces incorrect stems for non-English text. For example:

| Dutch word | Dutch stemmer | English Porter |
|---|---|---|
| documenten | document | documenten (unchanged!) |
| gebruikers | gebruiker | gebruik (over-stemmed) |
| instellingen | instell | instellingen (unchanged!) |

This degrades BM25 recall for any non-English knowledge base.

## Solution
NLTK already ships Snowball stemmers for 16 languages. This PR:

1. **`rag/nlp/rag_tokenizer.py`**: Overrides `tokenize()` with
`set_language()` and `_normalize_token()` that selects the correct NLTK
Snowball stemmer. Falls back to Porter for unmapped languages (Chinese,
Japanese, Korean, etc. — these use character-based tokenization anyway).
2. **`rag/nlp/__init__.py`** + **14 `rag/app/*.py` parsers** +
**`rag/svr/task_executor.py`**: Threads the `language` parameter through
`tokenize()`, `tokenize_chunks()`, `tokenize_table()`, and all callers.
3. **Frontend**: Adds Dutch (`Nederlands`) to `LanguageList`,
`LanguageMap`, `LanguageAbbreviationMap`, `LanguageTranslationMap`,
cross-language form field, and `en.ts` locale.

## Backward Compatibility
- Default language is `"English"`, preserving existing behavior for all
current users
- Languages without a Snowball stemmer mapping fall back to Porter (no
change)
- No new dependencies — NLTK Snowball is already bundled
…#16682)

## Summary

Fixes a page crash when opening the BGPT node configuration in the
canvas.

## Root Cause

BGPT was using the tool-form watcher call pattern in a normal canvas
component form.

Tool forms use:

useWatchFormChange(form)

Canvas component forms use:

useWatchFormChange(node?.id, form)

Tool is not equal to component. The BGPT canvas component imported the
component-level hook but called it like a tool-form hook, so the form
argument became undefined and React Hook Form tried to read control from
a null context.

## Change

Updated the BGPT canvas form to pass the node id and form instance
correctly.

## Validation

Ran ESLint for the changed file:
npx eslint src/pages/agent/form/bgpt-form/index.tsx

<img width="1369" height="1184" alt="image"
src="https://github.com/user-attachments/assets/a40c5202-7394-4f26-9da2-08329dcc7fbf"
/>
### Summary

There is a [new function](https://pkg.go.dev/[email protected]#Contains)
added in the go1.21 standard library, which can make the code more
concise and easy to read.

Signed-off-by: weifanglab <[email protected]>
## Summary
Adds the missing input form metadata for the Go BGPT canvas component.

## Root Cause

The standalone BGPT component was registered in Go, but it did not
implement GetInputForm(). During component trial run, the backend asks
the component for its input_form. Since BGPT had none, the API returned:

component has no input_form: BGPT:<node_id>

Python BGPT already exposes the query input form, so the Go component
needed the same contract.

## Change

Added GetInputForm() to the Go BGPT component with a single query line
input.
Added test coverage to ensure BGPT exposes the input form.

## Validation

Backend:
bash build.sh --test -run TestBGPT ./internal/agent/component

<img width="1369" height="1184" alt="image"
src="https://github.com/user-attachments/assets/f99e4a81-2359-42e5-80bb-dcc4e6a63fea"
/>

<img width="1736" height="1152" alt="image"
src="https://github.com/user-attachments/assets/c11240a5-2c42-4d08-88e3-c6dfbf49eedb"
/>
### Summary

The Go backend never seeded the `canvas_template` table, so the "Create
agent from template" page was blank when the frontend proxies to the Go
API (`API_PROXY_SCHEME=go`). This PR adds `SeedCanvasTemplates()` in
`internal/dao`, invoked from `InitDB()` after migrations, which loads
`agent/templates/*.json` and mirrors Python's `add_graph_templates()`
behavior.

Changes:
- Add `internal/dao/canvas_template_seed.go` to parse and upsert
built-in templates.
- Call `SeedCanvasTemplates()` in `InitDB()`.
- Add `CanvasTypes` (`JSONSlice`) to `entity.CanvasTemplate` so the
frontend can filter/group by category.
- Skip seeding gracefully when the templates directory is absent.

This fixes the blank template catalogue in Go mode.
### Summary

Add object as a begin-node parameter type with JSON editor UI, webhook
schema support, and backend parsing in UserFillUp.

Co-authored-by: Cursor <[email protected]>
Follow on this PR: infiniflow#15484 it break the Agent chat
euvre and others added 17 commits July 16, 2026 17:02
### Summary

1.  Change the CI trigger conditions.  synchronize and  labeled ci
2.  Fix ci: tags canceled running workflow
### Summary

Introduce Clickhouse for data statistics.

Signed-off-by: Jin Hai <[email protected]>
…finiflow#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 <[email protected]>
Co-authored-by: Jin Hai <[email protected]>
### Summary

Tracing framework

---------

Signed-off-by: Jin Hai <[email protected]>
### Summary

Compilation result navigation in agentic search.
…low#16977)

### Summary

Feat: Visualize session graph data using ArtifactForceGraph.
### Summary

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

---------

Signed-off-by: Jin Hai <[email protected]>
OllamaCV.describe()/describe_with_prompt() call the Ollama Python
client's generate() without think=False. Ollama only honors think as
a top-level kwarg (not inside options), so Qwen3-family vision models
emit a full reasoning trace before the actual description. On an
RTX 3070 with qwen3.5:9b this took ~6 minutes and ~2800 tokens per
figure; disabling it drops that to 10-60s.

The generate() think parameter needs ollama-python>=0.5.1; bump the
pinned lower bound accordingly.

Verified on a live deployment: figure descriptions during AI-OCR
parsing dropped from ~6 min/figure to ~10-60s/figure after this
change, confirmed across a full run over an 86-page PDF with 250+
figures.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Ollama dependency minimum version is raised to 0.5.1, and both Ollama CV image-generation calls now pass think=False to suppress reasoning traces from Qwen3-family models.

Changes

Ollama CV generation

Layer / File(s) Summary
Ollama version and thinking control
pyproject.toml, rag/llm/cv_model.py
The minimum Ollama version is raised to 0.5.1, and both CV generation methods pass top-level think=False.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wangq8, lynn-inf

Poem

I’m a rabbit with prompts in my hat,
No thinking trace—imagine that!
Ollama hops to version five-one,
Clear CV answers now are spun.
Two image paths bloom bright and neat.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: disabling Ollama thinking for vision figure descriptions.
Description check ✅ Passed The description includes the required Summary section with context and adds a useful Test plan.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
rag/llm/cv_model.py (1)

778-789: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for both vision generation methods.

Mock self.client.generate and assert that both describe() and describe_with_prompt() pass think=False as a top-level keyword, while preserving response extraction. As per coding guidelines, “Preserve valid behavior with focused tests.”

Also applies to: 795-806

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rag/llm/cv_model.py` around lines 778 - 789, Add focused regression tests for
the vision generation methods describe and describe_with_prompt, mocking
self.client.generate and asserting each call passes think=False as a top-level
keyword. Keep the existing response extraction assertions so the tests verify
both the new argument and preserved output behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@rag/llm/cv_model.py`:
- Around line 778-789: Add focused regression tests for the vision generation
methods describe and describe_with_prompt, mocking self.client.generate and
asserting each call passes think=False as a top-level keyword. Keep the existing
response extraction assertions so the tests verify both the new argument and
preserved output behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb29e814-3e91-4b51-bf3c-02111e9d97b3

📥 Commits

Reviewing files that changed from the base of the PR and between 27d091b and 5fa065e.

📒 Files selected for processing (2)
  • pyproject.toml
  • rag/llm/cv_model.py

@JinHai-CN
JinHai-CN requested a review from 6ba3i August 27, 2026 12:18

@6ba3i 6ba3i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python fix looks good to me. think=False is applied at the right level and the dependency bump makes sense.

The one thing I think we still need is Go parity. Current main now has the same parser-side vision path in Go, but Ollama only serializes Thinking when it is true, so Thinking: false is effectively the same as leaving it unset. That means Qwen3/Qwen3.5 can still think by default there.

I’d update the Go Ollama driver to serialize any non-nil Thinking value, and have the vision invoker explicitly pass Thinking: false. The same should apply to streaming.

Also worth regenerating uv.lock after the minimum Ollama version bump.

Other than that, LGTM

@6ba3i

6ba3i commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Hello @iwasaki1112 could you please take a look at my comment fix the missing go implementation ?

@6ba3i

6ba3i commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

overlaps on #19529

@6ba3i 6ba3i closed this Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. 🌈 python Pull requests that update Python code size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.