Skip to content

fix(sdk): temperature default should be a float, not a 1-tuple - #18656

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
simpleqt:fix-sdk-memory-temperature-tuple
Aug 24, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
simpleqt:fix-sdk-memory-temperature-tuple

Conversation

@simpleqt

Copy link
Copy Markdown
Contributor

Summary

Memory.__init__ in the Python SDK sets

self.temperature = (0.5,)

The parentheses + trailing comma make this a one-element tuple, not a float. It is a trailing-comma typo:

  • The server-side model stores temperature as a FloatField(default=0.5) (api/db/db_models.py), and memory_api_service.update_memory validates it with float(...).
  • Every other scalar default in the SDK modules is a plain scalar (e.g. self.progress = 0.0 in document.py).

The tuple default is normally masked because the API response includes temperature and Base._update_from_dict overwrites the attribute, but whenever a response omits the field, memory.temperature leaks the tuple (e.g. str(memory)/to_json() renders "temperature": [0.5], and float comparisons/json payloads get a list instead of a number). Fix is the scalar 0.5, matching the server default.

self.temperature = (0.5,) is a trailing-comma typo. The server-side
Memory model stores temperature as a FloatField (default 0.5) and
memory_api_service validates it as float, so the SDK attribute should
default to the scalar 0.5 like every other scalar default in the SDK.
Copilot AI lite review requested due to automatic review settings August 23, 2026 05:27
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Aug 23, 2026

Copilot AI 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.

Pull request overview

Fixes a Python SDK default value bug where Memory.temperature was accidentally initialized as a 1-tuple (0.5,) due to a trailing comma, ensuring the SDK default matches the server-side FloatField(default=0.5) behavior and avoids leaking list/tuple-shaped values into JSON serialization.

Changes:

  • Replace the tuple default self.temperature = (0.5,) with the intended scalar float self.temperature = 0.5.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c35d575-50ad-4cdb-b73c-fd9a95b11831

📥 Commits

Reviewing files that changed from the base of the PR and between 9ea83b7 and 1ac7d17.

📒 Files selected for processing (1)
  • sdk/python/ragflow_sdk/modules/memory.py

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The Memory constructor now sets temperature to the numeric float 0.5 instead of the single-element tuple (0.5,).

Changes

Memory temperature initialization

Layer / File(s) Summary
Correct the temperature default
sdk/python/ragflow_sdk/modules/memory.py
Memory.__init__ now assigns 0.5 as the default temperature value.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 1ac7d

This change corrects the SDK temperature default from a one-element tuple to the intended numeric value, preventing malformed serialized values when the field is omitted. No actionable merge-blocking risk remains.

Poem

A rabbit checked the memory nest,
And found a tuple in its test.
Now 0.5 sits clean and bright,
A float behaving just right.
Hop, hop—defaults take flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the SDK fix and the incorrect tuple default.
Description check ✅ Passed The description includes the required Summary section and clearly explains the defect, impact, and fix.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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.

@JinHai-CN
JinHai-CN requested a review from wangq8 August 24, 2026 03:54

@wangq8 wangq8 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.

Confirmed. The server-side model stores temperature as FloatField(default=0.5) (api/db/db_models.py:1825), and this is the only trailing-comma tuple default in the SDK modules, so (0.5,) is clearly an unintentional typo rather than a deliberate 1-tuple. Changing it to 0.5 matches the server default and removes the latent bug where memory.temperature could leak a list in to_json() / JSON payloads when the field is omitted from a response.

LGTM. Thanks for the fix!

@wangq8
wangq8 requested a review from Lynn-Inf August 24, 2026 11:16
@wangq8 wangq8 added the ci Continue Integration label Aug 24, 2026
@wangq8

wangq8 commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

LGTM

@Lynn-Inf Lynn-Inf 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.

LGTM

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (9ea83b7) to head (1ac7d17).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18656   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit f5c359e into infiniflow:main Aug 24, 2026
11 checks passed
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. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants