Skip to content

feat: Add Google as an option for genai#8358

Merged
erichare merged 2 commits into
mainfrom
feat-google-generative
Jun 3, 2025
Merged

feat: Add Google as an option for genai#8358
erichare merged 2 commits into
mainfrom
feat-google-generative

Conversation

@erichare
Copy link
Copy Markdown
Collaborator

@erichare erichare commented Jun 3, 2025

This pull request adds Google as an option to the Language Model component.

Summary by CodeRabbit

  • New Features
    • Added support for Google as a language model provider, allowing users to select and configure Google models alongside existing providers.
  • Improvements
    • Enhanced provider selection options and configuration settings to accommodate the new Google provider.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2025

Walkthrough

Support for the "Google" language model provider has been added to the language model component. This includes updating provider selection, model instantiation, configuration handling, and error checking to accommodate Google alongside existing providers.

Changes

File(s) Change Summary
src/backend/base/langflow/components/models/language_model.py Added support for "Google" as a language model provider, including imports, instantiation, and config updates.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LanguageModelComponent
    participant ChatGoogleGenerativeAI

    User->>LanguageModelComponent: Selects "Google" as provider and configures model
    LanguageModelComponent->>LanguageModelComponent: Validates API key and settings
    LanguageModelComponent->>ChatGoogleGenerativeAI: Instantiates with config
    ChatGoogleGenerativeAI-->>LanguageModelComponent: Returns model instance
    LanguageModelComponent-->>User: Provides configured model
Loading

📜 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 c4ca2bb and ad40217.

📒 Files selected for processing (1)
  • src/backend/base/langflow/components/models/language_model.py (4 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
src/backend/base/langflow/components/models/language_model.py

[error] 4-4: Unable to import 'langchain_google_genai'

(E0401)


[error] 5-5: Unable to import 'langchain_openai'

(E0401)

🔇 Additional comments (4)
src/backend/base/langflow/components/models/language_model.py (4)

29-29: LGTM! Google provider properly added to UI configuration.

The addition of "Google" to the provider options and metadata follows the established pattern and maintains consistency with existing providers.

Also applies to: 33-33


127-130:

Details

✅ Verification successful

LGTM! Configuration updates properly handle Google provider.

The update_build_config method correctly handles the Google provider by setting the appropriate model options, default value, and API key display name, maintaining consistency with the existing provider patterns.

Let's verify that the GOOGLE_GENERATIVE_AI_MODELS constant is properly defined:


🏁 Script executed:

#!/bin/bash
# Description: Verify the GOOGLE_GENERATIVE_AI_MODELS constant exists and contains valid model names
# Expected: The constant should be defined and contain a list of Google model names

# Find and examine the Google constants file
fd "google_generative_ai_constants.py" --exec cat {}

# Search for any references to this constant
rg "GOOGLE_GENERATIVE_AI_MODELS" -A 3 -B 1

Length of output: 7304


✔️ Google provider configuration verified

  • Confirmed that GOOGLE_GENERATIVE_AI_MODELS is defined in google_generative_ai_constants.py and correctly derives its values from GOOGLE_GENERATIVE_AI_MODELS_DETAILED.
  • Usage in src/backend/base/langflow/components/models/language_model.py matches the pattern established for other providers.

LGTM!


4-4:

Details

✅ Verification successful

LGTM! Verify the import dependencies are available.

The imports for Google GenAI components look correct and follow the established pattern.

However, let's verify that the required dependencies are properly installed:

Also applies to: 8-8


🏁 Script executed:

#!/bin/bash
# Description: Check if the required Google GenAI dependencies are available
# Expected: The langchain-google-genai package should be present in requirements

# Check for Google GenAI related packages in requirements files
fd -e txt -e in -e lock | xargs grep -l "langchain.*google" 2>/dev/null || echo "No Google GenAI dependencies found in requirements files"

# Check if the constants file exists
fd "google_generative_ai_constants.py" --type f

# Check for any existing Google-related imports in the codebase
rg "langchain_google_genai" -A 2

Length of output: 2840


Dependency verification passed for Google GenAI imports.
uv.lock confirms langchain_google_genai v2.0.6 is installed and src/backend/base/langflow/base/models/google_generative_ai_constants.py exists. All imports align with existing modules—no further action needed.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 4-4: Unable to import 'langchain_google_genai'

(E0401)


104-113:

Details

❓ Verification inconclusive

LGTM! Google provider implementation follows established patterns.

The Google provider implementation is well-structured and consistent with existing OpenAI and Anthropic implementations. The error handling for missing API keys is properly implemented.

Let's verify that the parameter names are correct for the ChatGoogleGenerativeAI class:


🏁 Script executed:

#!/bin/bash
# Description: Verify the correct parameter names for ChatGoogleGenerativeAI
# Expected: The constructor should accept model, temperature, streaming, and google_api_key parameters

# Search for ChatGoogleGenerativeAI class definition or usage examples
rg "ChatGoogleGenerativeAI" -A 10 -B 2

# Look for any existing usage patterns in the codebase
ast-grep --pattern 'ChatGoogleGenerativeAI($$$)'

Length of output: 11334


Verify ChatGoogleGenerativeAI constructor parameters
Before approving, please confirm that the external ChatGoogleGenerativeAI class actually accepts a streaming argument—our local wrapper in google_generative_ai.py never passes streaming, so there’s no evidence in the codebase that it’s supported.

• src/backend/base/langflow/components/models/language_model.py (lines 104–113)

  • Ensure the constructor signature matches: model, temperature, streaming, and google_api_key.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 3, 2025
@dosubot dosubot Bot added the enhancement New feature or request label Jun 3, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jun 3, 2025
Copy link
Copy Markdown
Contributor

@Yukiyukiyeah Yukiyukiyeah left a comment

Choose a reason for hiding this comment

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

LGTM!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 3, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jun 3, 2025
@erichare erichare enabled auto-merge June 3, 2025 21:59
@erichare erichare added this pull request to the merge queue Jun 3, 2025
Merged via the queue into main with commit 4d11123 Jun 3, 2025
81 of 85 checks passed
@erichare erichare deleted the feat-google-generative branch June 3, 2025 22:21
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants