Skip to content

Ollama followups - #46

Merged
hbmartin merged 1 commit into
mainfrom
ollama-followup
Oct 3, 2025
Merged

Ollama followups#46
hbmartin merged 1 commit into
mainfrom
ollama-followup

Conversation

@hbmartin

@hbmartin hbmartin commented Oct 3, 2025

Copy link
Copy Markdown
Owner

Summary by Sourcery

Refactor OllamaProvider to use a centralized default URL, enhance configuration validation and typing, register the provider, and update dependencies and ESLint setup

Enhancements:

  • Centralize Ollama API default URL into a constant and apply it throughout the provider
  • Refine OllamaProvider configuration and clientOptions typing using TypeScript’s satisfies operator
  • Improve getSdkLanguageModel to handle missing configurations more robustly
  • Update Ollama provider description to mention Llama and register it in the provider registry

Build:

  • Bump various devDependencies including AI SDKs, testing libraries, type definitions, React, ESLint plugins, Tailwind CSS, and Vite

Chores:

  • Clean up ESLint configuration by replacing deprecated reactHooks extends with the react-hooks plugin

Summary by CodeRabbit

  • New Features
    • Added Ollama as a selectable AI provider with sensible default connection settings.
  • Improvements
    • More robust provider initialization and config validation; defaults applied when no config is supplied.
    • Updated provider descriptions for clearer model guidance.
  • Bug Fixes
    • Ensured consistent fallback to a default base URL when none is provided.
  • Chores
    • Upgraded dependencies (React 19.2.0, Vite 7.1.9, Tailwind 3.4.18, testing libraries, AI SDKs).
    • Updated linting setup, including React Hooks plugin upgrade and configuration adjustments.

@sourcery-ai

sourcery-ai Bot commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR refactors OllamaProvider to centralize default base URLs and strengthen configuration handling, updates provider metadata, bumps various devDependencies, fixes an SDK utility's config validation, adjusts ESLint react-hooks settings, and registers OllamaProvider in the providers registry.

Class diagram for updated OllamaProvider configuration handling

classDiagram
  class OllamaProvider {
    +metadata: ProviderMetadata
    +configuration: ConfigAPI<OllamaProviderSettings>
    +fetchModels(params, options)
    +createInstance(params: ProviderInstanceParams): Promise<LanguageModelV2>
  }
  OllamaProvider --> OllamaProviderSettings
  OllamaProviderSettings : baseURL
  OllamaProviderSettings : compatibility
  OllamaProviderSettings : ...other options
  OllamaProvider ..> ConfigAPI : uses
  OllamaProvider ..> ProviderMetadata : uses
  OllamaProvider ..> LanguageModelV2 : creates

  class ConfigAPI {
    +assertValidConfigAndRemoveEmptyKeys(config)
    +validateConfig(config)
  }

  class ProviderMetadata {
    +id
    +name
    +description
    +icon
    +documentationUrl
    +fetchModelListPath
  }
Loading

Class diagram for getSdkLanguageModel utility function update

classDiagram
  class getSdkLanguageModel {
    +storage: StorageAdapter
    +returns: Promise<LanguageModelV2>
  }
  getSdkLanguageModel --> StorageAdapter
  getSdkLanguageModel --> LanguageModelV2
  getSdkLanguageModel ..> OllamaProvider : instantiates
  getSdkLanguageModel ..> ConfigAPI : uses validateConfig

  class StorageAdapter {
    +getProviderConfiguration(providerId)
  }

  class OllamaProvider {
    +configuration: ConfigAPI<OllamaProviderSettings>
    +createInstance(params)
  }
Loading

File-Level Changes

Change Details Files
Centralize default base URL
  • Define DEFAULT_BASE_URL constant
  • Replace hard-coded URLs in configuration and fetch/create methods
  • Apply trim and existence checks when falling back to default
src/lib/providers/OllamaProvider.ts
Update provider metadata description
  • Revise description to mention Llama models instead of gpt-oss
src/lib/providers/OllamaProvider.ts
Improve clientOptions construction and validation
  • Spread options into a typed clientOptions with satisfies check
  • Enforce trimmed baseURL and valid compatibility values
  • Assert configuration before creating the Ollama client
src/lib/providers/OllamaProvider.ts
Bump devDependencies versions
  • Upgrade ai-SDKs (amazon-bedrock, anthropic, etc.)
  • Update testing and type packages (jest-dom, @types/react/-dom)
  • Refresh tooling deps (react, eslint-plugins, tailwindcss, vite)
package.json
Enhance provider config validation in SDK utility
  • Instantiate provider to check default config validity
  • Validate empty configuration explicitly
  • Use empty object fallback for options when config is undefined
src/lib/utils/index.ts
Adjust ESLint configuration for react-hooks
  • Remove deprecated 'recommended-latest' React Hooks preset
  • Add react-hooks plugin under rules section
eslint.config.ts
Register OllamaProvider in provider registry
  • Add OllamaProvider to allProviders map
src/lib/providers/index.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 3, 2025

Copy link
Copy Markdown

Walkthrough

Removes react-hooks recommended-latest from ESLint extends and explicitly registers the react-hooks plugin. Bumps multiple dependencies. Adds and registers an Ollama provider with a DEFAULT_BASE_URL and revised option handling. Updates provider instantiation and config validation flow to validate defaults when config is absent.

Changes

Cohort / File(s) Summary
Lint config
eslint.config.ts
Removed reactHooks.configs['recommended-latest'] from extends; added named react-hooks plugin entry.
Dependencies
package.json
Bumped devDependencies: React/React DOM, types, ESLint plugins, Tailwind, Vite, AI SDK packages.
Providers: Ollama + registry
src/lib/providers/OllamaProvider.ts, src/lib/providers/index.ts
Introduced DEFAULT_BASE_URL; refactored baseURL fallback and options handling; updated description text; registered OllamaProvider under ollama.
Utils: provider creation/validation flow
src/lib/utils/index.ts
Instantiate provider before validation; if no config, validate provider defaults and pass {} as options; unchanged public API.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Utils as Utils.getProviderInstance
  participant Registry as Providers.index
  participant Provider as OllamaProvider
  participant Config as configuration.validateConfig

  Caller->>Utils: request provider instance (id, config?)
  Utils->>Registry: resolve provider by id
  Registry-->>Utils: OllamaProvider
  Utils->>Provider: createInstance(options = config ?? {})
  Note over Provider: Build clientOptions<br/>baseURL = options.baseURL || DEFAULT_BASE_URL
  alt config provided
    Utils->>Config: validateConfig(config)
    Config-->>Utils: result
    alt ok
      Utils-->>Caller: instance
    else not ok
      Utils-->>Caller: throw validation error
    end
  else no config
    Utils->>Config: validateConfig({})
    Config-->>Utils: result
    alt ok
      Utils-->>Caller: instance (defaults)
    else not ok
      Utils-->>Caller: throw validation error
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Add Storybook #3: Also modifies eslint.config.ts around Storybook and plugin/extends setup.
  • Add Ollama #45: Touches OllamaProvider and its baseURL/config handling similar to this provider integration.
  • Add LMStudio #43: Updates provider registration and configuration validation paths overlapping utils and provider index changes.

Suggested labels

Review effort 3/5

Poem

A whisk of ears, a hop, a twirl—
I nibbled configs, gave hooks a whirl.
New Ollama paths, defaults in tow,
If configs are empty, I still go.
Dependencies groomed, neat as a nest—
Thump-thump! This bunny ships the best. 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title “Ollama followups” vaguely indicates work related to Ollama but does not clearly summarize the primary changes such as adding the OllamaProvider, updating default baseURL handling, and adjusting ESLint configurations; as a result it lacks sufficient specificity for a teammate to understand the main purpose at a glance. Consider revising the title to succinctly describe the core update—for example, “Add OllamaProvider and update default baseURL handling”—so that it clearly reflects the main changes introduced in this pull request.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ollama-followup

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61d70be and e38fa05.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • eslint.config.ts (1 hunks)
  • package.json (4 hunks)
  • src/lib/providers/OllamaProvider.ts (5 hunks)
  • src/lib/providers/index.ts (2 hunks)
  • src/lib/utils/index.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/lib/utils/index.ts (2)
src/lib/index.ts (1)
  • getProviderConfiguration (45-45)
src/lib/storage/repository.ts (1)
  • getProviderConfiguration (120-125)
src/lib/providers/index.ts (2)
src/lib/types/index.ts (1)
  • createProviderId (275-275)
src/lib/providers/OllamaProvider.ts (1)
  • OllamaProvider (96-194)
⏰ 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). (1)
  • GitHub Check: Sourcery review
🔇 Additional comments (17)
eslint.config.ts (1)

46-46: LGTM! Explicit plugin registration aligns with flat config best practices.

The explicit registration of the react-hooks plugin under a named key is the correct approach for ESLint flat config. This change, combined with the manual rule definitions at lines 211-212, gives you full control over which React Hooks rules are enabled.

package.json (9)

142-143: Verify compatibility of patch bumps.

The dependency bumps for @ai-sdk/amazon-bedrock and @ai-sdk/anthropic appear to be routine patch updates.


160-160: Verify compatibility of patch bump.

The dependency bump for @testing-library/jest-dom appears to be a routine patch update.


164-165: Verify compatibility of minor bumps.

The dependency bumps for @types/react and @types/react-dom appear to be routine minor updates aligned with the React 19.2.0 upgrade.


168-168: Verify compatibility of patch bump.

The dependency bump for ai appears to be a routine patch update.


178-178: Verify compatibility of patch bump.

The dependency bump for eslint-plugin-react-refresh appears to be a routine patch update.


190-191: Verify compatibility of minor bumps.

The dependency bumps for react and react-dom appear to be routine minor updates.


194-194: Verify compatibility of patch bump.

The dependency bump for tailwindcss appears to be a routine patch update.


198-198: Verify compatibility of patch bump.

The dependency bump for vite appears to be a routine patch update.


177-177: Install ‘jiti’ to load your TypeScript ESLint config

  • ESLint error: missing jiti when loading eslint.config.ts.
  • Add it to devDependencies (npm install --save-dev jiti) or adjust your ESLint loader, then rerun
    npx eslint src/lib/providers/OllamaProvider.ts to verify eslint-plugin-react-hooks@6.1.0 compatibility.
src/lib/providers/index.ts (1)

12-12: LGTM! Ollama provider registration follows the established pattern.

The import and registration of OllamaProvider is consistent with how other providers are registered in the codebase.

Also applies to: 40-40

src/lib/utils/index.ts (1)

18-24: LGTM! Enhanced validation flow supports providers with sensible defaults.

The refactored flow creates the provider instance earlier and validates default configuration when no stored config exists. This allows providers with valid defaults (like Ollama's DEFAULT_BASE_URL) to function without requiring explicit configuration storage. Passing an empty object {} instead of undefined aligns with provider implementations that expect an options object.

src/lib/providers/OllamaProvider.ts (5)

9-9: LGTM! Centralized default configuration.

Introducing the DEFAULT_BASE_URL constant eliminates duplication and provides a single source of truth for Ollama's default endpoint.


100-100: LGTM! Accurate model examples.

The updated description correctly references Llama models, replacing the generic "gpt-oss" reference.


110-110: LGTM! Consistent use of DEFAULT_BASE_URL.

The configuration field now uses the centralized constant for the default value.


122-126: LGTM! Consistent fallback logic.

The fetchModels method correctly falls back to DEFAULT_BASE_URL when no valid base URL is provided in options.


175-189: LGTM! Improved type safety and consistency.

The refactored createInstance method:

  • Uses consistent bracket notation for property access (options['baseURL'], options['compatibility'])
  • Correctly falls back to DEFAULT_BASE_URL when no valid base URL is provided
  • Employs the satisfies operator for type-safe option construction without type assertions
  • Validates the final clientOptions object, ensuring defaults are properly applied

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hbmartin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on maintaining the project's health and compatibility by updating a wide array of dependencies to their latest versions. It also includes targeted improvements to the ESLint setup for React hooks and enhances the robustness and clarity of the Ollama AI provider's configuration and instantiation process. These changes collectively ensure the project remains up-to-date with current best practices and library versions, while also making the Ollama integration more reliable.

Highlights

  • Dependency Updates: Numerous development dependencies have been updated to their latest versions, including various AI SDK packages, testing libraries like @testing-library/jest-dom, React and React DOM, ESLint plugins, Vite, and Tailwind CSS. The pnpm-lock.yaml file reflects these extensive changes.
  • ESLint Configuration Refinement: The ESLint configuration has been adjusted to explicitly manage react-hooks as a plugin, removing its direct extension from the recommended configuration, which streamlines the linting setup for React projects.
  • Ollama Provider Enhancements: The Ollama AI provider has been improved with a defined default base URL, an updated description, and more robust handling of configuration options, ensuring better stability and clarity when creating new Ollama instances.
  • Provider Integration: The OllamaProvider is now correctly imported and registered within the allProviders map, making it fully available for use across the application.
  • SDK Language Model Retrieval: The getSdkLanguageModel utility function has been made more resilient by ensuring that an empty configuration object is passed to createInstance if no specific configuration is found, and by validating the default configuration.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@socket-security

Copy link
Copy Markdown

@qodo-code-review

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Configuration injection

Description: The code accesses options['baseURL'] and options['compatibility'] using bracket notation
without prior narrowing of key types, which could allow unexpected keys to pass into
clientOptions; ensure only whitelisted config keys are used to prevent configuration
injection impacting external requests.
OllamaProvider.ts [175-188]

Referred Code
const baseURL =
  'baseURL' in options && options['baseURL'].trim().length > 0
    ? options['baseURL'].trim()
    : DEFAULT_BASE_URL;
const compatibility =
  options['compatibility'] === 'compatible' || options['compatibility'] === 'strict'
    ? options['compatibility']
    : 'strict';

const clientOptions = {
  ...options,
  baseURL,
  compatibility,
} satisfies OllamaProviderSettings;
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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

Important

Looks good to me! 👍

Reviewed everything up to e38fa05 in 1 minute and 16 seconds. Click for details.
  • Reviewed 209 lines of code in 5 files
  • Skipped 1 files when reviewing.
  • Skipped posting 7 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. eslint.config.ts:31
  • Draft comment:
    Removed react-hooks recommended-latest config from extends. Ensure its removal doesn’t miss any necessary hook rules.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to ensure that the removal of a configuration doesn't miss any necessary rules. This falls under the category of asking the author to double-check or ensure something, which is against the rules.
2. eslint.config.ts:43
  • Draft comment:
    Plugins now explicitly include 'react-hooks'. Confirm this configuration meets your project’s hook linting needs.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to confirm if the configuration meets their needs, which violates the rule against asking for confirmation or ensuring behavior is intended. It does not provide a specific suggestion or point out a potential issue.
3. package.json:142
  • Draft comment:
    Dependency versions have been bumped. Verify that these updates (especially for react, eslint-plugin-react-hooks, and ai) remain compatible with your project.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is asking the PR author to verify compatibility of dependency updates, which is against the rules. It does not provide a specific suggestion or point out a specific issue with the code.
4. src/lib/providers/OllamaProvider.ts:97
  • Draft comment:
    Updated description text from 'gpt-oss' to 'Llama'. Confirm this model list accurately reflects what’s supported.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to confirm if the model list accurately reflects what’s supported. This falls under asking the author to confirm their intention or to ensure the behavior is intended, which is against the rules.
5. src/lib/providers/OllamaProvider.ts:124
  • Draft comment:
    Good refactoring using DEFAULT_BASE_URL constant in fetchModels. Ensure that both fetchModels and createInstance use this constant consistently.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
6. src/lib/providers/OllamaProvider.ts:175
  • Draft comment:
    When extracting baseURL and compatibility in createInstance, defaulting compatibility to 'strict' is used. Verify that this fallback value is the intended behavior.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to verify if the fallback value is intended, which violates the rule against asking for confirmation of intention. It does not provide a specific suggestion or point out a clear issue with the code.
7. src/lib/utils/index.ts:21
  • Draft comment:
    The additional check using configuration.validateConfig({}) for missing config is a good safeguard. Ensure that providers expecting optional configuration are correctly validated.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 30% <= threshold 50% The comment is informative and suggests ensuring that providers expecting optional configuration are correctly validated. However, it doesn't ask for a specific action or provide a specific suggestion. It seems to be more of a reminder than a direct request for change.

Workflow ID: wflow_z17ktBkthMzhEXvj

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add type check before trimming

Add a typeof check to ensure options['baseURL'] is a string before calling
.trim() to prevent potential runtime errors.

src/lib/providers/OllamaProvider.ts [175-178]

 const baseURL =
-  'baseURL' in options && options['baseURL'].trim().length > 0
+  typeof options['baseURL'] === 'string' && options['baseURL'].trim().length > 0
     ? options['baseURL'].trim()
     : DEFAULT_BASE_URL;
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential runtime error if options['baseURL'] is not a string and provides a valid fix, improving code robustness.

Medium
  • More

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces some great improvements, especially the refactoring of the Ollama provider and the enhanced error handling for provider configurations. The dependency updates are also a welcome change.

I've added a comment with a suggestion to further simplify and improve the consistency of the configuration handling logic in OllamaProvider.ts. This also points out a related bug in fetchModels that you might want to address.

Overall, these changes make the code more robust and easier to maintain. Nice work!

Comment on lines +175 to +189
const baseURL =
'baseURL' in options && options['baseURL'].trim().length > 0
? options['baseURL'].trim()
: DEFAULT_BASE_URL;
const compatibility =
options.compatibility === 'compatible' || options.compatibility === 'strict'
? options.compatibility
options['compatibility'] === 'compatible' || options['compatibility'] === 'strict'
? options['compatibility']
: 'strict';

const clientOptions: OllamaProviderSettings = {
const clientOptions = {
...options,
baseURL,
compatibility,
};
this.configuration.assertValidConfigAndRemoveEmptyKeys(options);
} satisfies OllamaProviderSettings;
this.configuration.assertValidConfigAndRemoveEmptyKeys(clientOptions);

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.

medium

This refactoring improves the configuration handling. For even better readability and consistency, you could simplify the baseURL and compatibility logic. Using optional chaining for baseURL and dot notation for compatibility would make the code more concise and align it with other parts of the codebase.

Also, I noticed that the baseUrl in fetchModels is not trimmed before being used, which could lead to errors. You might want to apply a similar fix there.

Here's a suggested simplification for this block:

    const baseURL = options.baseURL?.trim() || DEFAULT_BASE_URL;
    const compatibility =
      options.compatibility === 'compatible' || options.compatibility === 'strict'
        ? options.compatibility
        : 'strict';

    const clientOptions = {
      ...options,
      baseURL,
      compatibility,
    } satisfies OllamaProviderSettings;
    this.configuration.assertValidConfigAndRemoveEmptyKeys(clientOptions);

@hbmartin
hbmartin merged commit c55f3d8 into main Oct 3, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant