Skip to content

Add Ollama - #45

Merged
hbmartin merged 1 commit into
mainfrom
ollama
Oct 1, 2025
Merged

Add Ollama#45
hbmartin merged 1 commit into
mainfrom
ollama

Conversation

@hbmartin

@hbmartin hbmartin commented Oct 1, 2025

Copy link
Copy Markdown
Owner

PR Type

Enhancement


Description

  • Add Ollama provider for local AI models

  • Include Ollama icon component with SVG path

  • Support model discovery via /api/tags endpoint

  • Add peer dependency for ollama-ai-provider-v2


Diagram Walkthrough

flowchart LR
  A["OllamaIcon"] --> B["OllamaProvider"]
  B --> C["Model Discovery"]
  B --> D["Client Instance"]
  C --> E["Local Models"]
  D --> F["AI SDK Integration"]
Loading

File Walkthrough

Relevant files
Enhancement
index.ts
Add Ollama icon component                                                               

src/lib/icons/index.ts

  • Add OllamaIcon component with SVG path definition
  • Export new icon for use in provider metadata
+13/-0   
OllamaProvider.ts
Implement Ollama provider with model discovery                     

src/lib/providers/OllamaProvider.ts

  • Create complete Ollama provider implementation
  • Add model discovery via API endpoint fetching
  • Include type guards for API response validation
  • Support dynamic import of ollama-ai-provider-v2 package
+189/-0 
Dependencies
package.json
Add Ollama provider dependency configuration                         

package.json

  • Add ollama-ai-provider-v2 as optional peer dependency
  • Include package in peerDependenciesMeta as optional
  • Add to devDependencies for development
+5/-0     
pnpm-lock.yaml
Update lockfile for Ollama dependencies                                   

pnpm-lock.yaml

  • Lock ollama-ai-provider-v2@1.4.1 with zod peer dependency
  • Update package resolution and snapshots
+15/-0   


Important

Add Ollama provider with new icon and functionality to fetch models and create instances using Ollama API.

  • Dependencies:
    • Add ollama-ai-provider-v2 to package.json as a peer and dev dependency.
  • Icons:
    • Add OllamaIcon to index.ts for representing the Ollama provider.
  • Providers:
    • Create OllamaProvider class in OllamaProvider.ts.
    • Implements fetchModels() to retrieve model list from Ollama API.
    • Implements createInstance() to create a language model instance using Ollama API.

This description was created by Ellipsis for d067e25. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Added Ollama provider to connect with local Ollama models.
    • Supports fetching and listing available local models via configurable base URL.
    • Introduced an Ollama icon for improved visual identification.
  • Chores

    • Added optional Ollama AI provider dependency and updated dependency metadata to support the new provider without impacting existing setups.

@sourcery-ai

sourcery-ai Bot commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR integrates a new Ollama AI provider by introducing its SVG icon, updating dependencies to include ‘ollama-ai-provider-v2’, and adding a fully featured OllamaProvider class that handles configuration, model discovery, and dynamic client instantiation.

Sequence diagram for OllamaProvider model discovery and instantiation

sequenceDiagram
  participant User
  participant OllamaProvider
  participant OllamaServer as "Ollama local server"
  participant OllamaClient as "ollama-ai-provider-v2 client"

  User->>OllamaProvider: Request model list
  OllamaProvider->>OllamaServer: GET /api/tags
  OllamaServer-->>OllamaProvider: Return model list
  OllamaProvider-->>User: Return available models

  User->>OllamaProvider: Request model instance
  OllamaProvider->>OllamaClient: createOllama(clientOptions)
  OllamaClient-->>OllamaProvider: LanguageModelV2 instance
  OllamaProvider-->>User: Return model instance
Loading

Entity relationship diagram for Ollama model data structures

erDiagram
  OLLAMAMODELLISTRESPONSE ||--|{ OLLAMAMODEL : models
  OLLAMAMODEL }|--|| OLLAMAMODELDETAILS : details

  OLLAMAMODELLISTRESPONSE {
    models OllamaModel[]
  }
  OLLAMAMODEL {
    name string
    modified_at string
    size number
    digest string
    details OllamaModelDetails
  }
  OLLAMAMODELDETAILS {
    format string
    family string
    families string[]
    parameter_size string
    quantization_level string
  }
Loading

File-Level Changes

Change Details Files
Added OllamaIcon component
  • Export a new IconComponent named OllamaIcon
  • Define SVG element and path for the Ollama logo
src/lib/icons/index.ts
Updated package.json to depend on ollama-ai-provider-v2
  • Add ‘ollama-ai-provider-v2’ to dependencies
  • Include it under optionalDependencies
  • Add it to devDependencies for local testing
package.json
Implemented OllamaProvider class
  • Define model interfaces and runtime type guards for Ollama responses
  • Set up provider metadata and configuration (base URL field)
  • Implement fetchModels with URL validation, fetch logic, payload checking, and mapping to ModelConfig
  • Implement createInstance using dynamic import, option normalization, and client instantiation
src/lib/providers/OllamaProvider.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 1, 2025

Copy link
Copy Markdown

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

Adds Ollama provider support: new dependency configuration for ollama-ai-provider-v2, a new Ollama icon export, and a new OllamaProvider implementing model discovery via Ollama HTTP API and dynamic runtime instantiation via optional dependency import.

Changes

Cohort / File(s) Summary
Dependency config
package.json
Adds ollama-ai-provider-v2 to dependencies, peerDependencies (optional via peerDependenciesMeta), and devDependencies; retains existing optional flags.
Icons
src/lib/icons/index.ts
Exports new OllamaIcon React SVG component; no changes to existing exports.
Provider: Ollama
src/lib/providers/OllamaProvider.ts
Introduces OllamaProvider with configuration defaults, model list fetching/validation from Ollama API, dynamic import-based instance creation, and internal type guards/utilities.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as UI/Caller
  participant Prov as OllamaProvider
  participant API as Ollama HTTP API
  participant Mod as ollama-ai-provider-v2 (dynamic)

  User->>Prov: fetchModels(options)
  Prov->>Prov: validate config (baseURL, path)
  Prov->>API: GET {baseURL}/{fetchModelListPath}
  API-->>Prov: JSON { models: [...] }
  Prov->>Prov: validate/shape models
  Prov-->>User: ModelConfig[]

  rect rgba(230,245,255,0.5)
  note over User,Prov: Create runtime model instance
  User->>Prov: createInstance({ modelId, options })
  Prov->>Prov: assert config defaults
  Prov->>Mod: import() ollama-ai-provider-v2
  alt module available
    Prov-->>User: LanguageModelV2 instance
  else missing module
    Prov-->>User: throw error (dependency required)
  end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Add LMStudio #43 — Adds another provider and icon with similar patterns (fetchModels, provider metadata, dynamic creation), aligning with this Ollama integration.
  • Add moonshot and bedrock providers #15 — Introduces a new AI provider and updates icons and package.json, mirroring the structure of this provider addition.

Suggested labels

Review effort 3/5

Poem

I twitch my whiskers, tap-tap—new trails to try,
An Ollama hum from localhost nearby.
Icons shine, configs align,
Models parade in a tidy line.
With a hop and a link I gleefully say:
“Fetch, instantiate—now we can play!” 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Add Ollama" is concise and directly reflects the main change of the pull request, which is to introduce Ollama support via a new provider, dependency, and icon without including extraneous details.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ollama

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 significantly expands the application's AI capabilities by integrating Ollama. This allows users to leverage local AI models, providing greater flexibility and privacy for their AI-powered workflows. The changes include adding the necessary provider logic, updating dependencies, and introducing a new icon to support this integration.

Highlights

  • Ollama Integration: This pull request introduces full support for Ollama, enabling the application to connect and interact with local AI models hosted via the Ollama platform.
  • New Ollama Provider: A dedicated OllamaProvider class has been added, encapsulating the logic for discovering available Ollama models and creating instances for AI interactions.
  • Dependency Management: The ollama-ai-provider-v2 package has been added as a new dependency, along with updates to the pnpm-lock.yaml to manage its installation.
  • Ollama Icon: A new SVG icon for Ollama has been included, which will be used to visually represent the Ollama provider within the application's UI.
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

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedollama-ai-provider-v2@​1.4.18610010095100

View full report

@qodo-code-review

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
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

@qodo-code-review

Copy link
Copy Markdown

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: Check AI SDK Compatibility

Failed stage: Build with AI SDK providers [❌]

Failed test name: ""

Failure summary:

The action failed during the TypeScript build step due to TS4111 errors in
src/lib/providers/OllamaProvider.ts. Properties accessed from an index signature must use bracket
notation:
- src/lib/providers/OllamaProvider.ts(174,29): TS4111: Property baseURL comes from an
index signature, so it must be accessed with ['baseURL'].
-
src/lib/providers/OllamaProvider.ts(174,62): TS4111: Property baseURL comes from an index signature,
so it must be accessed with ['baseURL'].
- src/lib/providers/OllamaProvider.ts(176,15): TS4111:
Property compatibility comes from an index signature, so it must be accessed with ['compatibility'].

- src/lib/providers/OllamaProvider.ts(176,57): TS4111: Property compatibility comes from an index
signature, so it must be accessed with ['compatibility'].
-
src/lib/providers/OllamaProvider.ts(177,19): TS4111: Property compatibility comes from an index
signature, so it must be accessed with ['compatibility'].
As a result, pnpm run build failed with
exit code 2, causing the workflow to fail. Note: an earlier step also showed
ERR_PNPM_OPTION_NOT_SUPPORTED for pnpm add --no-save, but that step was tolerant (|| true) and did
not cause the failure.

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

228:  ##[group]Run pnpm add --no-save @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google || true
229:  �[36;1mpnpm add --no-save @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google || true�[0m
230:  shell: /usr/bin/bash -e {0}
231:  env:
232:  PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
233:  ##[endgroup]
234:  ERR_PNPM_OPTION_NOT_SUPPORTED  The "add" command currently does not support the no-save option
235:  ##[group]Run pnpm run build
236:  �[36;1mpnpm run build�[0m
237:  shell: /usr/bin/bash -e {0}
238:  env:
239:  PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
240:  ##[endgroup]
241:  > ai-sdk-react-model-picker@0.4.0 build /home/runner/work/ai-sdk-react-model-picker/ai-sdk-react-model-picker
242:  > tsc -b && vite build
243:  ##[error]src/lib/providers/OllamaProvider.ts(174,29): error TS4111: Property 'baseURL' comes from an index signature, so it must be accessed with ['baseURL'].
244:  ##[error]src/lib/providers/OllamaProvider.ts(174,62): error TS4111: Property 'baseURL' comes from an index signature, so it must be accessed with ['baseURL'].
245:  ##[error]src/lib/providers/OllamaProvider.ts(176,15): error TS4111: Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].
246:  ##[error]src/lib/providers/OllamaProvider.ts(176,57): error TS4111: Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].
247:  ##[error]src/lib/providers/OllamaProvider.ts(177,19): error TS4111: Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].
248:  ELIFECYCLE  Command failed with exit code 2.
249:  ##[error]Process completed with exit code 2.
250:  Post job cleanup.

@openhands-ai

openhands-ai Bot commented Oct 1, 2025

Copy link
Copy Markdown

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • CI

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #45 at branch `ollama`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect model fetch URL construction

To correctly handle base URLs with subpaths, construct the request URL by
resolving the fetchModelListPath relative to the full baseUrl, not just its
origin.

src/lib/providers/OllamaProvider.ts [126-133]

 let requestUrl: URL;
 try {
-  const base = new URL(baseUrl);
-  requestUrl = new URL(this.metadata.fetchModelListPath, base.origin);
+  // Ensure baseUrl ends with a slash for correct relative URL resolution
+  const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
+  // Resolve path relative to the full base URL
+  requestUrl = new URL(this.metadata.fetchModelListPath.slice(1), base);
 } catch (error) {
   const reason = error instanceof Error ? error.message : String(error);
   throw new Error(`Invalid Ollama base URL: ${reason}`);
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion correctly identifies a functional bug where the URL construction for fetchModels fails for base URLs with subpaths (e.g., when behind a reverse proxy). The proposed fix is accurate and resolves a significant correctness issue.

Medium
General
Use configured default for base URL

Instead of hardcoding the default baseURL, retrieve it from the
this.configuration object to ensure a single source of truth and improve
maintainability.

src/lib/providers/OllamaProvider.ts [174]

-const baseURL = options.baseURL?.trim().length ? options.baseURL : 'http://localhost:11434/api';
+const baseURL =
+  options.baseURL?.trim().length
+    ? options.baseURL
+    : this.configuration.fields.find(f => f.name === 'baseURL')?.defaultValue ?? 'http://localhost:11434/api';
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that the default baseURL is hardcoded in two places. Centralizing the default by reading it from the configuration object improves maintainability and adheres to the DRY principle.

Low
  • More

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

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/lib/providers/OllamaProvider.ts:120-124` </location>
<code_context>
+
+    this.configuration.assertValidConfigAndRemoveEmptyKeys(options);
+
+    const baseUrl =
+      // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, sonarjs/different-types-comparison
+      options !== undefined && 'baseURL' in options && options.baseURL.trim().length > 0
+        ? options.baseURL
+        : 'http://localhost:11434/api';
+
+    let requestUrl: URL;
</code_context>

<issue_to_address>
**issue:** Base URL fallback logic may not handle URLs with paths correctly.

If baseURL includes a path, constructing the new URL using base.origin may omit the intended API path. Please ensure the full baseURL is used or validate the path to prevent incorrect endpoint formation.
</issue_to_address>

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.

Comment on lines +120 to +124
const baseUrl =
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, sonarjs/different-types-comparison
options !== undefined && 'baseURL' in options && options.baseURL.trim().length > 0
? options.baseURL
: 'http://localhost:11434/api';

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.

issue: Base URL fallback logic may not handle URLs with paths correctly.

If baseURL includes a path, constructing the new URL using base.origin may omit the intended API path. Please ensure the full baseURL is used or validate the path to prevent incorrect endpoint formation.

@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 adds support for the Ollama AI provider, including its dependency, icon, and the provider implementation. The core logic in OllamaProvider.ts is mostly well-structured. However, I've identified a critical bug in the construction of the model list fetch URL that would cause issues for users with reverse proxy setups. Additionally, I've provided several suggestions to improve code robustness, such as correctly handling whitespace in URLs and enhancing the clarity of type guards and configuration handling.

Comment thread src/lib/providers/OllamaProvider.ts
Comment thread src/lib/providers/OllamaProvider.ts
Comment thread src/lib/providers/OllamaProvider.ts
Comment thread src/lib/providers/OllamaProvider.ts
Comment thread src/lib/providers/OllamaProvider.ts

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

Caution

Changes requested ❌

Reviewed everything up to d067e25 in 2 minutes and 13 seconds. Click for details.
  • Reviewed 249 lines of code in 3 files
  • Skipped 1 files when reviewing.
  • Skipped posting 4 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. src/lib/providers/OllamaProvider.ts:157
  • Draft comment:
    The TODO about handling undefined params.options is redundant since options are defaulted with 'params.options ?? {}'. Consider removing the comment.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. src/lib/providers/OllamaProvider.ts:120
  • Draft comment:
    Consider simplifying baseURL extraction by using optional chaining (e.g. options?.baseURL?.trim()) for clarity.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. src/lib/providers/OllamaProvider.ts:184
  • Draft comment:
    Configuration validation is called in both fetchModels and createInstance. Consider consolidating this to avoid duplication if appropriate.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. src/lib/providers/OllamaProvider.ts:147
  • Draft comment:
    Typo in comment: "discoveredAt effects sorting" should likely read "discoveredAt affects sorting".
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% While the grammar correction is technically correct, TODO comments are temporary by nature and this is a very minor issue. The meaning is still clear despite the grammatical error. The rules state we should not make purely informative comments or obvious/unimportant ones. This seems to fall into that category. The grammar error could potentially cause confusion for non-native English speakers. Also, maintaining high code quality includes maintaining good documentation. While documentation quality is important, this is a temporary TODO comment that will likely be removed soon. The meaning is clear enough that it won't cause real confusion. This comment should be deleted as it's a minor grammatical correction that doesn't materially improve the code or prevent any issues.

Workflow ID: wflow_S172wACsvTpvwVfq

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

let requestUrl: URL;
try {
const base = new URL(baseUrl);
requestUrl = new URL(this.metadata.fetchModelListPath, base.origin);

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.

Using base.origin here discards any pathname in the provided baseURL. Consider using the full URL (e.g. base.href) if the path is meant to be preserved.

Suggested change
requestUrl = new URL(this.metadata.fetchModelListPath, base.origin);
requestUrl = new URL(this.metadata.fetchModelListPath, base.href);

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/lib/providers/OllamaProvider.ts (3)

98-98: Clarify "gpt-oss" in description.

The description mentions "gpt-oss" which may be unclear. Did you mean "llama" or another specific model? "gpt-oss" isn't a standard Ollama model name.

Consider revising to:

-    description: 'Use local AI models like gpt-oss, Qwen, Gemma, DeepSeek hosted on your computer.',
+    description: 'Use local AI models like Llama, Qwen, Gemma, DeepSeek hosted on your computer.',

147-147: Address TODO about discoveredAt sorting.

The TODO raises a valid concern about how discoveredAt affects model list ordering. Consider whether models should be sorted by name, modification date, or discovery time.

Would you like me to suggest an implementation for model sorting, or should this be deferred to a future issue?


157-157: Address TODO about undefined options handling.

The TODO questions whether params.options undefined case needs handling. Line 172 already handles this with params.options ?? {}, so the TODO can be removed.

Apply this diff:

-  // TODO: need to handle case where params.options is undefined?
   async createInstance(params: ProviderInstanceParams): Promise<LanguageModelV2> {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 051a170 and d067e25.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • package.json (3 hunks)
  • src/lib/icons/index.ts (1 hunks)
  • src/lib/providers/OllamaProvider.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/lib/icons/index.ts (1)
src/lib/types/index.ts (1)
  • IconComponent (76-76)
src/lib/providers/OllamaProvider.ts (2)
src/lib/types/index.ts (3)
  • isObject (111-113)
  • createProviderId (275-275)
  • createModelId (276-276)
src/lib/icons/index.ts (1)
  • OllamaIcon (5-16)
🪛 GitHub Actions: CI
src/lib/providers/OllamaProvider.ts

[error] 174-174: TypeScript TS4111: Property 'baseURL' comes from an index signature, so it must be accessed with ['baseURL'].

🪛 GitHub Check: Check AI SDK Compatibility
src/lib/providers/OllamaProvider.ts

[failure] 177-177:
Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].


[failure] 176-176:
Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].


[failure] 176-176:
Property 'compatibility' comes from an index signature, so it must be accessed with ['compatibility'].


[failure] 174-174:
Property 'baseURL' comes from an index signature, so it must be accessed with ['baseURL'].


[failure] 174-174:
Property 'baseURL' comes from an index signature, so it must be accessed with ['baseURL'].

🪛 GitHub Check: Lint, Type Check, and Test
src/lib/providers/OllamaProvider.ts

[failure] 174-174:
Unnecessary optional chain on a non-nullish value

⏰ 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 (7)
src/lib/icons/index.ts (1)

5-16: LGTM! Icon implementation follows established patterns.

The OllamaIcon is correctly implemented using the same structure as other provider icons, with proper typing and SVG rendering.

package.json (1)

186-186: Verify devDependency version exists.

The devDependency specifies version ^1.4.1, but this appears inconsistent with the package's release history. This needs verification to ensure the package can be installed during development.

This will be verified by the web search requested for line 98.

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

1-7: LGTM! Clean imports and type definitions.

The module structure with dynamic import type, proper typing from AI SDK, and configuration imports is well organized.


9-27: LGTM! Well-structured type definitions.

The OllamaModel and OllamaModelListResponse interfaces accurately model the Ollama API response structure with appropriate optional fields.


29-92: LGTM! Robust type guards with thorough validation.

The type guards properly validate all required and optional fields, including nested structures and array elements. This provides strong runtime type safety.


158-188: Dynamic import error handling aligns with other providers. No additional error handling is required at this layer; network or model validation should be handled by the Ollama client library or upstream code.


120-124: Fix: Use bracket notation for index signature property.

TypeScript requires bracket notation when accessing properties from index signatures. The baseURL property must be accessed with options['baseURL'].

Apply this diff:

     const baseUrl =
       // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, sonarjs/different-types-comparison
-      options !== undefined && 'baseURL' in options && options.baseURL.trim().length > 0
-        ? options.baseURL
+      options !== undefined && 'baseURL' in options && options['baseURL'].trim().length > 0
+        ? options['baseURL']
         : 'http://localhost:11434/api';

Likely an incorrect or invalid review comment.

Comment thread package.json
Comment thread src/lib/providers/OllamaProvider.ts
@hbmartin
hbmartin merged commit 61d70be into main Oct 1, 2025
4 of 6 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 3, 2025
@hbmartin
hbmartin deleted the ollama branch October 3, 2025 14:24
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