Skip to content

refactor: migrate llm providers to ai.common.LLMBase - #719

Merged
dsapandora merged 2 commits into
developfrom
feat/ai-common-llmbase-migration
Apr 29, 2026
Merged

dsapandora merged 2 commits into
developfrom
feat/ai-common-llmbase-migration

Conversation

@dsapandora

@dsapandora dsapandora commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Migrates LLMBase from nodes/llm_base/ into packages/ai/src/ai/common/llm_base.py as the single canonical base for all LLM providers. Removes the tight coupling where each module depended on a local llm_base.py, standardizing the interface (completion, token counting) on top of ChatBase (connection, retries, error handling).

Type

Testing

  • Tests added or updated
  • Tested locally
  • ./builder test passes

Checklist

  • Commit messages follow conventional commits
  • No secrets or credentials included
  • Wiki updated (if applicable)
  • Breaking changes documented (if applicable)

Linked Issue

Fixes #
close #720

Summary by CodeRabbit

Release Notes

  • Refactor

    • Updated base implementation across all LLM provider integrations (Anthropic, OpenAI, Bedrock, Gemini, Mistral, Ollama, Deepseek, IBM Watson, Perplexity, Qwen, Vertex, xAI, and vision-enabled models) to use a unified foundation class.
  • Documentation

    • Refreshed architecture documentation to reflect standardized LLM provider implementation structure.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR consolidates LLM provider node implementations by introducing a shared LLMBase base class in the central ai.common module and migrating 17+ LLM provider nodes from the local IInstanceGenericLLM to the new canonical base, including removing the old implementation and updating documentation.

Changes

Cohort / File(s) Summary
Documentation
docs/README-nodes.md
Reformatted Markdown tables for consistent alignment; updated "Internal" section to document llm_base as a compatibility wrapper to canonical ai.common.llm_base.LLMBase.
New LLMBase Class
packages/ai/src/ai/common/llm_base.py
Introduced shared LLMBase base class with methods for chat delegation (_question, writeQuestions), token metrics (getContextLength, getOutputLength, getTokenCounter, getTotalTokens, getOutputTokens, getTokens), and ask entrypoint.
Removed Old Base Class
nodes/src/nodes/llm_base/IInstance.py, nodes/src/nodes/llm_base/__init__.py
Deleted IInstanceGenericLLM implementation and removed its export from module __all__.
LLM Provider Migration
nodes/src/nodes/accessibility_describe/IInstance.py, nodes/src/nodes/llm_anthropic/IInstance.py, nodes/src/nodes/llm_bedrock/IInstance.py, nodes/src/nodes/llm_deepseek/IInstance.py, nodes/src/nodes/llm_gemini/IInstance.py, nodes/src/nodes/llm_gmi_cloud/IInstance.py, nodes/src/nodes/llm_ibm_watson/IInstance.py, nodes/src/nodes/llm_mistral/IInstance.py, nodes/src/nodes/llm_ollama/IInstance.py, nodes/src/nodes/llm_openai/IInstance.py, nodes/src/nodes/llm_openai_api/IInstance.py, nodes/src/nodes/llm_perplexity/IInstance.py, nodes/src/nodes/llm_qwen/IInstance.py, nodes/src/nodes/llm_vertex/IInstance.py, nodes/src/nodes/llm_vision_mistral/IInstance.py, nodes/src/nodes/llm_vision_ollama/IInstance.py, nodes/src/nodes/llm_xai/IInstance.py
Updated all LLM provider IInstance classes to inherit from ai.common.llm_base.LLMBase instead of nodes.llm_base.IInstanceGenericLLM; imports adjusted accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • LLM refactor #720: Directly implements the LLM base class refactor by introducing ai.common.LLMBase and migrating all provider IInstance classes from IInstanceGenericLLM to the new canonical base.

Possibly related PRs

Suggested reviewers

  • jmaionchi
  • stepmikhaylov
  • Rod-Christensen

Poem

🐰 The base classes hop to common ground,
Where LLMBase can now be found,
Seventeen providers unified at last,
Old IInstanceGenericLLM fades fast,
From nodes to ai, the refactor's complete—
A tidy hop makes architecture sweet! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: migrate llm providers to ai.common.LLMBase' accurately describes the main change: migrating multiple LLM provider implementations to use a new canonical base class from ai.common.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ai-common-llmbase-migration

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.

@github-actions github-actions Bot added docs Documentation module:nodes Python pipeline nodes module:ai AI/ML modules labels Apr 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No description provided.

@dsapandora
dsapandora marked this pull request as ready for review April 29, 2026 11:39

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ai/src/ai/common/llm_base.py`:
- Around line 29-31: getTokenCounter currently returns the getTokens method
object instead of calling it; update getTokenCounter (decorated with
`@invoke_function`) to call self.IGlobal._chat.getTokens(...) with parentheses and
pass the correct value from the _param argument (e.g., _param.value or the
appropriate field) so the function returns the token count rather than the
method reference.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 46440d14-98b8-4890-a8df-7853605d1f6f

📥 Commits

Reviewing files that changed from the base of the PR and between 4846445 and 2e055c4.

📒 Files selected for processing (21)
  • docs/README-nodes.md
  • nodes/src/nodes/accessibility_describe/IInstance.py
  • nodes/src/nodes/llm_anthropic/IInstance.py
  • nodes/src/nodes/llm_base/IInstance.py
  • nodes/src/nodes/llm_base/__init__.py
  • nodes/src/nodes/llm_bedrock/IInstance.py
  • nodes/src/nodes/llm_deepseek/IInstance.py
  • nodes/src/nodes/llm_gemini/IInstance.py
  • nodes/src/nodes/llm_gmi_cloud/IInstance.py
  • nodes/src/nodes/llm_ibm_watson/IInstance.py
  • nodes/src/nodes/llm_mistral/IInstance.py
  • nodes/src/nodes/llm_ollama/IInstance.py
  • nodes/src/nodes/llm_openai/IInstance.py
  • nodes/src/nodes/llm_openai_api/IInstance.py
  • nodes/src/nodes/llm_perplexity/IInstance.py
  • nodes/src/nodes/llm_qwen/IInstance.py
  • nodes/src/nodes/llm_vertex/IInstance.py
  • nodes/src/nodes/llm_vision_mistral/IInstance.py
  • nodes/src/nodes/llm_vision_ollama/IInstance.py
  • nodes/src/nodes/llm_xai/IInstance.py
  • packages/ai/src/ai/common/llm_base.py
💤 Files with no reviewable changes (2)
  • nodes/src/nodes/llm_base/init.py
  • nodes/src/nodes/llm_base/IInstance.py

Comment thread packages/ai/src/ai/common/llm_base.py Resolved
@dsapandora
dsapandora merged commit b84a03a into develop Apr 29, 2026
30 checks passed
@dsapandora
dsapandora deleted the feat/ai-common-llmbase-migration branch April 29, 2026 12:44
@dsapandora
dsapandora restored the feat/ai-common-llmbase-migration branch April 30, 2026 20:09
@coderabbitai coderabbitai Bot mentioned this pull request May 7, 2026
4 tasks
@coderabbitai coderabbitai Bot mentioned this pull request May 15, 2026
7 tasks
@stepmikhaylov
stepmikhaylov deleted the feat/ai-common-llmbase-migration branch September 22, 2026 20:47
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation module:ai AI/ML modules module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LLM refactor

3 participants