Skip to content

fix: add support in Agent to fix ollama - #10499

Merged
edwinjosechittilappilly merged 5 commits into
mainfrom
fix-ollama-agents
Nov 6, 2025
Merged

fix: add support in Agent to fix ollama#10499
edwinjosechittilappilly merged 5 commits into
mainfrom
fix-ollama-agents

Conversation

@edwinjosechittilappilly

@edwinjosechittilappilly edwinjosechittilappilly commented Nov 4, 2025

Copy link
Copy Markdown
Collaborator

This pull request introduces enhancements to the ChatOllamaComponent in ollama.py, focusing on enabling structured output and improving input configuration flexibility. The most significant changes are the addition of a new input for structured output, updates to the model-building logic to respect this setting, and dynamic UI adjustments based on user selections.

Structured Output Feature:

  • Added a new boolean input enable_structured_output to the component, allowing users to toggle structured output functionality in the model configuration.
  • Updated the build_model method to conditionally parse and include the format field only if structured output is enabled, preventing errors when the feature is off. [1] [2]

Input and UI Configuration:

  • Set the model_name input as required, ensuring users must specify a model for the component to function.
  • Modified the visibility of the format input to be hidden by default, with its visibility now controlled dynamically based on the structured output setting.
  • Implemented logic in update_build_config to show or hide the format input in the UI depending on the value of enable_structured_output, improving user experience and reducing confusion.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added structured output toggle to enable/disable format configuration
    • Format input is now hidden by default and conditionally displayed when structured output is enabled
    • Model Name field is now required for valid configuration

@coderabbitai

coderabbitai Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The Ollama component was modified to make model name required, introduce an enable_structured_output boolean input to conditionally control structured output formatting, hide the format input by default, and update build logic to compute and include format parameters only when structured output is enabled.

Changes

Cohort / File(s) Summary
Ollama component structured output feature
src/lfx/src/lfx/components/ollama/ollama.py
Added required flag to model_name, introduced enable_structured_output boolean input with conditional visibility toggle for format field, modified build_model to compute output_format only when structured output is enabled, and added update_build_config handling for enable_structured_output field to toggle format visibility

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The changes involve straightforward conditional logic and UI configuration adjustments
  • Model name required flag is a simple property update
  • Format visibility toggle based on enable_structured_output is a standard pattern
  • The build_model modifications use basic if/else conditions without complex interactions

Suggested labels

bug, lgtm

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning, 3 inconclusive)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error The PR adds new features (enable_structured_output, required model_name, dynamic format visibility) but test files show no coverage for these changes. Add unit tests for enable_structured_output toggle, model_name requirement validation, format field visibility, and build_model output_format logic to ensure new functionality is properly tested.
Test File Naming And Structure ⚠️ Warning PR adds enable_structured_output feature to Ollama component but lacks test coverage for this new functionality and related UI/build logic changes. Add unit and integration tests covering enable_structured_output input field, build_model format parameter logic, update_build_config format field visibility toggling, and edge cases.
Title check ❓ Inconclusive The PR title 'fix: add support in Agent to fix ollama' is vague and doesn't clearly convey the main changes, which involve adding structured output support and improving UI configuration in ChatOllamaComponent. Consider revising the title to be more specific about the main change, such as 'fix: add structured output support to ChatOllamaComponent' or 'fix: improve Ollama model configuration with toggleable structured output'.
Test Quality And Coverage ❓ Inconclusive Repository appears empty or inaccessible; cannot locate ollama.py file, test files, or testing infrastructure despite comprehensive search attempts. Ensure repository is properly cloned with all files accessible, then verify test coverage for enable_structured_output, build_model changes, and update_build_config logic.
Excessive Mock Usage Warning ❓ Inconclusive No test files found in PR to assess mock usage patterns. Create and review test files for the modified ChatOllamaComponent to assess mock usage appropriateness.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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 and usage tips.

@edwinjosechittilappilly

Copy link
Copy Markdown
Collaborator Author

@coderabbitai please check any potential issue

@github-actions github-actions Bot added the bug Something isn't working label Nov 4, 2025
@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
14.67% (3955/26947) 7.45% (1533/20552) 9% (532/5906)

Unit Test Results

Tests Skipped Failures Errors Time
1588 0 💤 0 ❌ 0 🔥 19.139s ⏱️

@codecov

codecov Bot commented Nov 4, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 31.43%. Comparing base (b74e9ee) to head (e6910d2).
⚠️ Report is 3 commits behind head on main.

❌ Your project status has failed because the head coverage (39.36%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10499      +/-   ##
==========================================
+ Coverage   31.41%   31.43%   +0.02%     
==========================================
  Files        1325     1325              
  Lines       59987    59987              
  Branches     8980     8980              
==========================================
+ Hits        18843    18856      +13     
+ Misses      40237    40224      -13     
  Partials      907      907              
Flag Coverage Δ
backend 51.01% <ø> (+0.08%) ⬆️
frontend 13.57% <ø> (ø)
lfx 39.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 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.

@coderabbitai

coderabbitai Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Oops, something went wrong! Please try again later. 🐰 💔

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 4, 2025

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

This PR adds an enable_structured_output feature to the Ollama component that allows users to control whether structured output formatting should be enabled. When disabled, the format field is hidden and its value is not passed to the model.

Key changes:

  • Added a new enable_structured_output boolean input field
  • Made the model_name field required
  • Hidden the format field by default
  • Modified the logic to conditionally parse and use the format field based on the toggle
  • Added dynamic UI behavior to show/hide the format field when the toggle changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"model": self.model_name,
"mirostat": mirostat_value,
"format": output_format,
"format": output_format or None,

Copilot AI Nov 4, 2025

Copy link

Choose a reason for hiding this comment

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

The expression output_format or None is redundant. If output_format is already None (when enable_structured_output is False), this expression returns None. If it's a truthy value, it returns that value. However, if output_format is an empty dict {} or empty string '', it would incorrectly convert it to None. Consider using output_format directly instead of output_format or None.

Suggested change
"format": output_format or None,
"format": output_format,

Copilot uses AI. Check for mistakes.
Comment on lines +333 to +336
if field_value:
build_config["format"]["show"] = True
else:
build_config["format"]["show"] = False

Copilot AI Nov 4, 2025

Copy link

Choose a reason for hiding this comment

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

The if-else block can be simplified to a single line: build_config[\"format\"][\"show\"] = field_value. This makes the code more concise while maintaining the same functionality.

Suggested change
if field_value:
build_config["format"]["show"] = True
else:
build_config["format"]["show"] = False
build_config["format"]["show"] = field_value

Copilot uses AI. Check for mistakes.

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/lfx/src/lfx/components/ollama/ollama.py (1)

277-277: LGTM! Logic correctly handles format parameter.

The format parameter is correctly set to output_format or None, ensuring it's filtered out (line 302) when structured output is disabled. The or None is slightly redundant since _parse_format_field already handles falsy values, but it serves as defensive programming.

Optional: The or None could be simplified to just output_format since line 267 already handles the None case, but keeping it doesn't hurt:

-            "format": output_format or None,
+            "format": output_format,
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 732ec1e and e89c738.

📒 Files selected for processing (1)
  • src/lfx/src/lfx/components/ollama/ollama.py (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/lfx/src/lfx/components/ollama/ollama.py (1)
src/lfx/src/lfx/inputs/inputs.py (1)
  • BoolInput (414-426)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Frontend Unit Tests / Frontend Jest Unit Tests
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Lint Backend / Run Mypy (3.11)
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
  • GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Test Starter Templates
  • GitHub Check: CodeQL analysis (python)
  • GitHub Check: Update Component Index
🔇 Additional comments (5)
src/lfx/src/lfx/components/ollama/ollama.py (5)

104-104: LGTM! Good defensive change.

Making model_name required ensures users must select a model before building, preventing potential runtime errors.


129-129: LGTM! Improves UX.

Hiding the format input by default aligns well with the new opt-in structured output feature and reduces UI clutter.


220-227: LGTM! Well-structured feature addition.

The enable_structured_output input is properly configured with appropriate defaults and real-time refresh capability. The opt-in approach (default False) is a safe choice.


332-337: LGTM! Dynamic visibility logic is correct.

The logic properly toggles the format field's visibility based on the enable_structured_output value. The early return is fine since field handlers are mutually exclusive.


267-270: LGTM! Correct conditional logic.

Format parsing is correctly gated by enable_structured_output, and the error handling provides a clear message if parsing fails.

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

LGTM

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
Comment thread src/lfx/src/lfx/components/ollama/ollama.py Outdated
@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Nov 5, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
@HzaRashid

Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly @lucaseduoli i fixed the tests and added some new ones to test the behavior/relationship of the format and enable_structured_output fields. I'd appreciate your review, thanks!

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Nov 5, 2025
@edwinjosechittilappilly
edwinjosechittilappilly added this pull request to the merge queue Nov 6, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Nov 6, 2025
* improve ollama format field behaviour in agent component and update ollama tests

* chore: update component index

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: Hamza Rashid <hzarashid@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@edwinjosechittilappilly
edwinjosechittilappilly removed this pull request from the merge queue due to a manual request Nov 6, 2025
@edwinjosechittilappilly
edwinjosechittilappilly added this pull request to the merge queue Nov 6, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 6, 2025
@edwinjosechittilappilly
edwinjosechittilappilly added this pull request to the merge queue Nov 6, 2025
Merged via the queue into main with commit 5e8a558 Nov 6, 2025
81 of 83 checks passed
@edwinjosechittilappilly
edwinjosechittilappilly deleted the fix-ollama-agents branch November 6, 2025 17:40
korenLazar pushed a commit to kiran-kate/langflow that referenced this pull request Nov 13, 2025
* improve ollama format field behaviour in agent component and update ollama tests

* chore: update component index

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: Hamza Rashid <hzarashid@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants