Skip to content

Conversation

@siddharthsambharia-portkey
Copy link
Contributor

Description

This PR adds thinking parameter support for Ollama provider

Motivation

--

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

Fixes And Closes #1414

@matter-code-review
Copy link
Contributor

Summary By MatterAI MatterAI logo

🔄 What Changed

Added a new think parameter to the OllamaChatCompleteConfig to control thinking behavior with a transformation function that maps the thinking parameter's type to a boolean value.

🔍 Impact of the Change

This change introduces a new configurable option for Ollama chat completions, allowing users to enable or disable thinking behavior based on the parameter's type. The transformation function ensures proper mapping of the parameter to a boolean value for API consumption.

📁 Total Files Changed

File ChangeLog
Ollama Chat Added think parameter with transformation logic to map thinking type to boolean

🧪 Test Added/Recommended

Recommended

  • Unit tests for the new think parameter transformation function
  • Integration tests to verify the parameter is correctly passed to the Ollama API

🔒Security Vulnerabilities

N/A

Copy link
Contributor

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

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

🧪 PR Review is completed: Review of Ollama thinking parameter addition - found type safety issue with Params interface

Comment on lines +77 to +85
think: {
param: 'thinking',
transform: (params: Params) => {
if (params.thinking?.type === 'disabled') {
return false;
}
return true;
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Type Safety

Issue: The transform function references params.thinking but there's no guarantee that the Params interface includes a thinking property. This could lead to TypeScript compilation errors or runtime issues if the Params type doesn't match the expected structure.

Fix: Ensure the Params interface includes a thinking property with the correct type definition, or add proper type guards to handle cases where thinking might not exist.

Impact: Prevents TypeScript compilation errors and ensures type safety at compile time

Suggested change
think: {
param: 'thinking',
transform: (params: Params) => {
if (params.thinking?.type === 'disabled') {
return false;
}
return true;
},
},
think: {
param: 'thinking',
transform: (params: Params) => {
if (params.thinking?.type === 'disabled') {
return false;
}
return true;
},
},

tools: {
param: 'tools',
},
think: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this would mean
think -> gets mapped to -> thinking
you probably are trying to do the opposite
you should do

  thinking: {
    param: 'think',
    transform: (params: Params) => {
      if (params.thinking?.type === 'disabled') {
        return false;
      }
      return true;
    },
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support thinking for Ollama Provider

2 participants