Skip to content

refactor: Organize model lists to support metadata#8268

Merged
mfortman11 merged 10 commits into
mainfrom
lfoss-1221
May 30, 2025
Merged

refactor: Organize model lists to support metadata#8268
mfortman11 merged 10 commits into
mainfrom
lfoss-1221

Conversation

@mfortman11
Copy link
Copy Markdown
Collaborator

@mfortman11 mfortman11 commented May 29, 2025

creates a model metadata class to use to enhance the model selectors and replaces existing provider model lists accordingly

Additionally adds the new claude 4 models

Summary by CodeRabbit

  • New Features

    • Centralized and standardized model metadata across Anthropic, AWS, Google Generative AI, Groq, and OpenAI providers for consistent model selection and feature flagging.
    • Added new Anthropic model options: "claude-opus-4-20250514" and "claude-sonnet-4-20250514" to relevant components and starter projects.
  • Bug Fixes

    • Removed deprecated Anthropic model "claude-3-haiku-20240307" from model dropdowns.
  • Refactor

    • Consolidated model lists into metadata-driven structures for improved maintainability and consistency.
    • Reformatted JSON configuration files for better readability.
    • Updated default values and input visibility in some starter project components for clarity.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels May 29, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed enhancement New feature or request labels May 29, 2025
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels May 29, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels May 29, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 29, 2025

CodSpeed Performance Report

Merging #8268 will degrade performances by 24.63%

Comparing lfoss-1221 (ed6784f) with main (10d0e13)

Summary

⚡ 1 improvements
❌ 2 regressions
✅ 16 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_build_flow_invalid_job_id 8.6 ms 11.4 ms -24.63%
test_build_flow_start_with_inputs 218.8 ms 252.9 ms -13.5%
test_cancel_build_with_cancelled_error 420.7 ms 267.9 ms +57.03%

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels May 29, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2025

"""

Walkthrough

This update centralizes and standardizes model metadata across several backend modules by introducing detailed dictionaries that map model names or IDs to structured metadata objects. All model lists are now dynamically generated from these dictionaries, eliminating redundancy and improving maintainability. Starter project JSONs are updated to reflect new Anthropic model options and minor formatting changes.

Changes

File(s) Change Summary
src/backend/base/langflow/base/models/model_metadata.py Introduced ModelMetadata TypedDict and create_model_metadata helper function for consistent model metadata representation.
.../base/models/anthropic_constants.py
.../base/models/aws_constants.py
.../base/models/google_generative_ai_constants.py
.../base/models/groq_constants.py
.../base/models/openai_constants.py
Refactored model lists to detailed dictionaries mapping model names/IDs to metadata objects; all model lists are now dynamically generated by filtering these dictionaries based on metadata flags. Redundant static lists removed.
src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
.../Portfolio Website Code Generator.json
.../Research Translation Loop.json
Updated Anthropic model dropdown options: added "claude-opus-4-20250514" and "claude-sonnet-4-20250514", removed "claude-3-haiku-20240307". Reformatted arrays in Portfolio Website Code Generator for readability. Adjusted some default values and visibility in Parser and AnthropicModel nodes. No logic or control flow changes.

Sequence Diagram(s)

sequenceDiagram
    participant Code as Backend Code
    participant ModelDict as Model Metadata Dictionary
    participant Consumer as Model List Consumer

    Code->>ModelDict: Define model metadata via create_model_metadata()
    Consumer->>ModelDict: Query/filter for model lists (e.g., supported, deprecated)
    ModelDict-->>Consumer: Return dynamically generated model lists
Loading

Poem

🐇
Models now wear metadata coats,
With icons, flags, and tidy notes!
No more lists that grow askew—
Just one truth, clear and new.
Dropdowns updated, arrays aligned,
The codebase hops ahead—refined!
🥕
"""


📜 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 1d8ea0c and ed6784f.

📒 Files selected for processing (4)
  • src/backend/base/langflow/base/models/anthropic_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/aws_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/groq_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/openai_constants.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/backend/base/langflow/base/models/aws_constants.py
  • src/backend/base/langflow/base/models/groq_constants.py
  • src/backend/base/langflow/base/models/openai_constants.py
  • src/backend/base/langflow/base/models/anthropic_constants.py
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Lint Backend / Run Mypy (3.11)
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / Test CLI - Python 3.10
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
  • GitHub Check: Optimize new Python code in this PR
  • GitHub Check: Run benchmarks (3.12)
  • GitHub Check: Ruff Style Check (3.13)
  • GitHub Check: Update Starter Projects
  • GitHub Check: Run Ruff Check and Format
✨ 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.

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels May 29, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (1)

840-841: Mirror model options in second node
The second AnthropicModel node was updated with the same new options. Ensure both lists are identical and driven by the centralized metadata.

Also applies to: 846-846

🧹 Nitpick comments (3)
src/backend/base/langflow/base/models/model_metadata.py (1)

4-15: Consider making required fields explicit in the TypedDict definition.

The ModelMetadata class uses total=False making all fields optional, but the helper function clearly treats provider, name, and icon as required fields. This inconsistency could lead to confusion about the actual requirements.

Consider using a more explicit approach:

-class ModelMetadata(TypedDict, total=False):
+class ModelMetadata(TypedDict):
     """Simple model metadata structure."""
 
     provider: str  # Provider name (e.g., "anthropic", "groq", "openai")
     name: str  # Model name/ID
     icon: str  # Icon name for UI
+
+class ModelMetadataOptional(TypedDict, total=False):
+    """Optional model metadata fields."""
     tool_calling: bool  # Whether model supports tool calling (defaults to False)
     reasoning: bool  # Reasoning models (defaults to False)
     search: bool  # Search models (defaults to False)
     preview: bool  # Whether model is in preview/beta (defaults to False)
     not_supported: bool  # Whether model is not supported or deprecated (defaults to False)
     deprecated: bool  # Whether model is deprecated (defaults to False)
+
+class CompleteModelMetadata(ModelMetadata, ModelMetadataOptional):
+    """Complete model metadata with required and optional fields."""
+    pass

Then update the return type of create_model_metadata to use CompleteModelMetadata.

src/backend/base/langflow/base/models/aws_constants.py (1)

4-122: Reduce boilerplate by generating metadata entries dynamically
The AWS_MODELS_DETAILED dictionary repeats provider="Amazon Bedrock", icon="Amazon", and tool_calling=True for every entry. Consider DRYing this up with a small helper and a comprehension. For example:

# at top of file
_COMMON = dict(provider="Amazon Bedrock", icon="Amazon", tool_calling=True)
_CATEGORIES = {
    # Amazon Titan Models
    "amazon.titan-text-express-v1",
    "amazon.titan-text-lite-v1",
    "amazon.titan-text-premier-v1:0",
    # Anthropic Models
    "anthropic.claude-v2",
    "anthropic.claude-v2:1",
    # …and so on for each category
}

AWS_MODELS_DETAILED = {
    name: create_model_metadata(name=name, **_COMMON)
    for name in _CATEGORIES
}

This approach reduces duplication, centralizes common parameters, and makes adding/removing models easier.

src/backend/base/langflow/base/models/groq_constants.py (1)

126-132: Review the complex TOOL_CALLING_UNSUPPORTED_GROQ_MODELS filtering.

The filtering logic for tool calling unsupported models is correct but complex. It excludes not_supported and deprecated models while finding models without tool_calling support.

Consider adding a comment to clarify this logic:

 TOOL_CALLING_UNSUPPORTED_GROQ_MODELS = [
+    # Models that don't support tool calling, excluding deprecated and unsupported models
     model_name
     for model_name, metadata in GROQ_MODELS_DETAILED.items()
     if not metadata.get("tool_calling", False)
     and not metadata.get("not_supported", False)
     and not metadata.get("deprecated", False)
 ]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7e186a and 186b873.

⛔ Files ignored due to path filters (1)
  • src/frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • src/backend/base/langflow/base/models/anthropic_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/aws_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/google_generative_ai_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/groq_constants.py (1 hunks)
  • src/backend/base/langflow/base/models/model_metadata.py (1 hunks)
  • src/backend/base/langflow/base/models/openai_constants.py (1 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json (1 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (64 hunks)
  • src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (1 hunks)
🔇 Additional comments (23)
src/backend/base/langflow/base/models/model_metadata.py (1)

18-41: LGTM! Well-designed helper function.

The create_model_metadata function provides a clean API with explicit defaults and proper keyword-only arguments for optional parameters. This ensures consistent model metadata creation across the codebase.

src/backend/base/langflow/initial_setup/starter_projects/Research Translation Loop.json (1)

544-550:

Details

✅ Verification successful

Verify the validity of the new Claude 4 model identifiers.

The newly added model names claude-opus-4-20250514 and claude-sonnet-4-20250514 contain future dates (May 14, 2025) and reference Claude 4 models that may not be officially available yet.

Please verify these model identifiers are valid and available:

Additionally, please search for the latest information about Claude 4 availability:


🏁 Script executed:

#!/bin/bash
# Description: Check if the new Claude 4 models are valid by querying Anthropic's API
# Expected: Confirmation of model availability or error messages

# Check if the models are available in Anthropic's model list
curl -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
     -H "Content-Type: application/json" \
     https://api.anthropic.com/v1/models 2>/dev/null | \
     jq '.data[]? | select(.id | contains("claude-opus-4-20250514") or contains("claude-sonnet-4-20250514")) | .id' || \
     echo "Models not found or API call failed"

# Also search for any Claude 4 models
curl -H "Authorization: Bearer $ANTHROPIC_API_KEY" \
     -H "Content-Type: application/json" \
     https://api.anthropic.com/v1/models 2>/dev/null | \
     jq '.data[]? | select(.id | contains("claude") and contains("4")) | .id' || \
     echo "No Claude 4 models found"

Length of output: 401


🌐 Web query:

What are the latest available Claude 4 models from Anthropic as of 2025? Are claude-opus-4-20250514 and claude-sonnet-4-20250514 officially available?

💡 Result:

Based on the latest information available, as of May 29, 2025, Anthropic has officially released two new Claude 4 models: Claude Opus 4 and Claude Sonnet 4. These models were announced on May 21, 2025, at Anthropic's first developer conference called "Code with Claude"[5][7].

Claude 4 Models

Claude Opus 4 is Anthropic's most powerful model to date, described as pushing the frontier in coding, agentic search, and creative writing[2]. Anthropic claims it's the world's best coding model, excelling at sustained performance on complex, long-running tasks and agent workflows[1][3].

Claude Sonnet 4 is designed as an upgrade to Claude Sonnet 3.7, delivering superior coding and reasoning capabilities while responding more precisely to instructions[1]. It's positioned as a midsize model for high-volume use cases, offering a balance of quality, cost-effectiveness, and responsiveness[3].

Model Availability

Yes, both claude-opus-4-20250514 and claude-sonnet-4-20250514 are officially available. These specific model IDs were confirmed in a live blog of the Claude 4 launch event[7].

The models are available through multiple platforms:

  • Anthropic's own API
  • Amazon Bedrock (released May 22, 2025)
  • Google Cloud's Vertex AI[1][3][6]

For Amazon Bedrock specifically, the model IDs are:

  • anthropic.claude-opus-4-20250514-v1:0 for Opus 4
  • anthropic.claude-sonnet-4-20250514-v1:0 for Sonnet 4[9]

Access and Pricing

Claude Opus 4 is available for Pro, Max, Team, and Enterprise Claude users[2]. Pricing starts at $15 per million input tokens and $75 per million output tokens[1][2].

Claude Sonnet 4 is available to both paying customers and users of the free chatbot applications[8]. It's priced at $3 per million input tokens and $15 per million output tokens[1].

Both models feature a 200K context window for input, with Opus 4 supporting up to 32K output tokens[1][6].

Citations:


Verified Claude 4 model identifiers

I’ve confirmed that both claude-opus-4-20250514 and claude-sonnet-4-20250514 are official Claude 4 releases (announced May 21, 2025) and are available via Anthropic’s API, Amazon Bedrock, and Google Cloud Vertex AI. No further changes are required.

src/backend/base/langflow/base/models/google_generative_ai_constants.py (3)

1-2: Import of create_model_metadata is correct
The relative import from .model_metadata aligns with the new metadata-driven approach and the helper is available in the same directory.


4-54: Centralized metadata dictionary is well-structured
The GOOGLE_GENERATIVE_AI_MODELS_DETAILED mapping consistently applies the provider, icon, and tool_calling fields, with preview=True flagged appropriately for preview models. This single source of truth eliminates redundancy and keeps the model list in sync.


56-56: Backwards-compatible model list regenerated from metadata keys
Using list(GOOGLE_GENERATIVE_AI_MODELS_DETAILED.keys()) preserves insertion order and ensures existing consumers of GOOGLE_GENERATIVE_AI_MODELS remain functional.

src/backend/base/langflow/base/models/aws_constants.py (2)

1-2: Import of create_model_metadata added correctly
This import enables the construction of rich metadata entries for AWS models and is placed at the top of the file as expected.


124-125: Backwards-compatible AWS model ID list regenerated
Assigning AWS_MODEL_IDs = list(AWS_MODELS_DETAILED.keys()) maintains the legacy constant for existing code paths while leveraging the new metadata mapping.

src/backend/base/langflow/initial_setup/starter_projects/Portfolio Website Code Generator.json (6)

12-204: Stylistic: Multi-line array expansions
The various output_types and inputTypes arrays in the edge definitions were reformatted from single-line to multi-line. These are purely formatting changes to improve readability and match other starter project JSONs.


502-503: Update Anthropic model options
You’ve added the new models claude-opus-4-20250514 and claude-sonnet-4-20250514. Please verify that this list is kept in sync with the ANTHROPIC_MODELS array in langflow/base/models/anthropic_constants.py to avoid drift.

Also applies to: 508-508


830-830: Increase default max_tokens to 8192
The token cap was raised from 4096 to 8192. Confirm that downstream components can handle the larger default and that performance remains acceptable.


2235-2235: Hide pattern input by default
For the Parser when in Stringify mode, pattern.show is now false. Double-check that your update_build_config logic correctly toggles this field’s visibility based on the selected mode.


2393-2395: Default Parser mode changed to Stringify
The mode dropdown now defaults to Stringify instead of Parser. Please ensure this aligns with other starter templates and doesn’t break existing flows expecting the old default.

Also applies to: 2404-2404


2486-2489: Formatted tags as multi-line
The tags array was expanded for readability; its contents ("chatbots", "coding") remain unchanged. No functional impact.

src/backend/base/langflow/base/models/anthropic_constants.py (3)

50-60: Excellent metadata-driven approach for list generation.

The dynamic generation of categorized lists from the metadata dictionary is well-implemented and maintains backward compatibility while eliminating redundancy.


1-1:

Details

✅ Verification successful

Verify the model_metadata module dependency.

The import statement references a relative import from .model_metadata. Ensure this module exists and exports the create_model_metadata function.


🏁 Script executed:

#!/bin/bash
# Description: Verify the model_metadata module exists and contains the required function
# Expected: Find the module file and the create_model_metadata function

# Check if model_metadata.py exists in the same directory
fd -t f "model_metadata.py" src/backend/base/langflow/base/models/

# Search for the create_model_metadata function definition
ast-grep --pattern 'def create_model_metadata($$$) {
  $$$
}'

Length of output: 186


🏁 Script executed:

#!/bin/bash
# Check for the create_model_metadata function definition using grep and ripgrep
grep -R "def create_model_metadata" -n src/backend/base/langflow/base/models/model_metadata.py
rg -n "def create_model_metadata" src/backend/base/langflow/base/models/model_metadata.py

Length of output: 248


Import validation – create_model_metadata is present

Verified that src/backend/base/langflow/base/models/model_metadata.py defines create_model_metadata (line 18). No changes required.


5-10:

Details

✅ Verification successful

Verify the new Claude 4 model names and availability.

The new Claude 4 models (claude-opus-4-20250514 and claude-sonnet-4-20250514) represent significant additions. Please verify these model names are accurate and officially supported by Anthropic.


🌐 Web query:

What are the latest Claude 4 model names and release dates from Anthropic? Are claude-opus-4-20250514 and claude-sonnet-4-20250514 valid model identifiers?

💡 Result:

Claude 4 Model Names and Release Dates

Anthropic's latest generation of AI models, Claude 4, consists of two main variants:

  • Claude Opus 4
  • Claude Sonnet 4

These models were officially announced and released on May 21–22, 2025[1][3][4][9]. The announcement was made at Anthropic's "Code with Claude" event, with both models immediately becoming available to users on the Anthropic API, Amazon Bedrock, and Google Cloud's Vertex AI[8][9].

Key Details

  • Claude Opus 4 is described as Anthropic’s most capable and powerful model, excelling at complex reasoning, advanced coding, and agentic tasks[1][4][8][10].
  • Claude Sonnet 4 is positioned for balanced performance—faster and more efficient than Opus 4, yet a clear improvement over previous Sonnet models (like 3.7) in both reasoning and coding capabilities[1][10].

Validity of Model Identifiers

The following model identifiers are explicitly documented as valid for the Claude 4 series:

  • claude-opus-4-20250514
  • claude-sonnet-4-20250514

Anthropic’s official migration guide for their API instructs users to shift to these exact model names when accessing Claude 4 models[7]. The identifier format aligns with their versioning convention (model-family-version-date), confirming they are legitimate and currently supported model names[7].

Summary Table

Model Name Release Date Valid Identifier Description
Claude Opus 4 May 21–22, 2025 claude-opus-4-20250514 Most powerful, deep reasoning, advanced coding, complex tasks
Claude Sonnet 4 May 21–22, 2025 claude-sonnet-4-20250514 Balanced performance, faster response, improved coding/reasoning

Conclusion

  • The latest Claude 4 models are Claude Opus 4 and Claude Sonnet 4, both released in May 2025[1][3][9].
  • The model identifiers claude-opus-4-20250514 and claude-sonnet-4-20250514 are valid and officially recommended for use with the Anthropic API[7].

Citations:


Confirmed: Claude 4 model identifiers are correct and supported

Both claude-opus-4-20250514 and claude-sonnet-4-20250514 are the official Claude 4 model names released by Anthropic in May 2025, matching their documented versioning scheme and immediately available via the Anthropic API.

No changes are needed.

src/backend/base/langflow/base/models/openai_constants.py (3)

3-4: Good documentation and structure.

The comment "Unified model metadata - single source of truth" clearly communicates the intent of this refactoring.


66-70: Verify reasoning models filtering logic.

The reasoning models list excludes not_supported models, which is correct. However, ensure the reasoning flag is properly set for o1 models.


58-64:

Details

✅ Verification successful

Review the complex filtering logic for OPENAI_MODEL_NAMES.

The filtering logic excludes reasoning, search, and not_supported models. This is more complex than other providers and should be verified for correctness.


🏁 Script executed:

#!/bin/bash
# Description: Verify the filtering logic produces expected results
# Expected: Check that regular models are correctly identified

# Search for usage of OPENAI_MODEL_NAMES in the codebase to understand expected behavior
rg -A 3 -B 3 "OPENAI_MODEL_NAMES"

Length of output: 67934


🏁 Script executed:

#!/bin/bash
# Inspect model categories in openai_constants.py
python3 - <<'EOF'
import importlib.util
import sys
# Load the module from its file path
spec = importlib.util.spec_from_file_location(
    "openai_constants", 
    "src/backend/base/langflow/base/models/openai_constants.py"
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)

# Gather categories
regular = mod.OPENAI_MODEL_NAMES
reasoning = getattr(mod, "OPENAI_REASONING_MODEL_NAMES", [])
search = [m for m, v in mod.OPENAI_MODELS_DETAILED.items() if v.get("search", False)]
not_supported = [m for m, v in mod.OPENAI_MODELS_DETAILED.items() if v.get("not_supported", False)]

# Print results
print("TOTAL DETAILED MODELS:", len(mod.OPENAI_MODELS_DETAILED))
print("REGULAR (no reasoning, no search, supported):", regular)
print("REASONING MODELS:", reasoning)
print("SEARCH MODELS:", search)
print("NOT SUPPORTED MODELS:", not_supported)
EOF

Length of output: 466


🏁 Script executed:

#!/bin/bash
# Load openai_constants via package import to handle relative imports
python3 - <<'EOF'
import sys
# Add project path so 'langflow' package can be imported
sys.path.insert(0, "src/backend/base")
from langflow.base.models.openai_constants import OPENAI_MODEL_NAMES, OPENAI_REASONING_MODEL_NAMES, OPENAI_MODELS_DETAILED

# Build search and not_supported lists
search_models = [m for m, v in OPENAI_MODELS_DETAILED.items() if v.get("search", False)]
not_supported_models = [m for m, v in OPENAI_MODELS_DETAILED.items() if v.get("not_supported", False)]

print("Total detailed models:", len(OPENAI_MODELS_DETAILED))
print("Regular models (OPENAI_MODEL_NAMES):", OPENAI_MODEL_NAMES)
print("Reasoning models (OPENAI_REASONING_MODEL_NAMES):", OPENAI_REASONING_MODEL_NAMES)
print("Search models:", search_models)
print("Not supported models:", not_supported_models)
EOF

Length of output: 434


🏁 Script executed:

#!/bin/bash
# Parse OPENAI_MODELS_DETAILED via AST to categorize models without external imports
python3 - <<'EOF'
import ast, sys
from pprint import pprint

file_path = "src/backend/base/langflow/base/models/openai_constants.py"
try:
    source = open(file_path).read()
except FileNotFoundError:
    print(f"{file_path} not found")
    sys.exit(1)

tree = ast.parse(source)
detailed_node = None
for node in tree.body:
    if isinstance(node, ast.Assign):
        for target in node.targets:
            if isinstance(target, ast.Name) and target.id == "OPENAI_MODELS_DETAILED":
                detailed_node = node.value
                break
        if detailed_node:
            break

if detailed_node is None:
    print("OPENAI_MODELS_DETAILED assignment not found")
    sys.exit(1)

models = ast.literal_eval(detailed_node)
regular, reasoning, search, not_supported = [], [], [], []
for model, meta in models.items():
    if meta.get("reasoning", False):
        reasoning.append(model)
    elif meta.get("search", False):
        search.append(model)
    elif meta.get("not_supported", False):
        not_supported.append(model)
    else:
        regular.append(model)

print("Total detailed models:", len(models))
print("Regular models:", sorted(regular))
print("Reasoning models:", sorted(reasoning))
print("Search models:", sorted(search))
print("Not supported models:", sorted(not_supported))
EOF

Length of output: 923


🏁 Script executed:

#!/bin/bash
# Display create_model_metadata implementation and OPENAI_MODELS_DETAILED definition
echo "=== model_metadata.py ==="
sed -n '1,200p' src/backend/base/langflow/base/models/model_metadata.py
echo
echo "=== openai_constants.py ==="
sed -n '1,200p' src/backend/base/langflow/base/models/openai_constants.py

Length of output: 5574


Filtering logic for OPENAI_MODEL_NAMES is correct
The list comprehension in openai_constants.py accurately excludes any models flagged with reasoning, search, or not_supported, leaving only the core “regular” models (including preview ones) in OPENAI_MODEL_NAMES. No changes are needed.

src/backend/base/langflow/base/models/groq_constants.py (4)

3-5: Excellent documentation approach.

The comment structure clearly explains the purpose of the unified metadata approach.


6-23: Well-organized production models section.

The inline comments indicating model providers (Google, Meta) and the consistent metadata structure enhance readability and maintainability.


106-112: Verify the production models filtering logic.

The filtering correctly excludes preview, deprecated, and not_supported models. This logic looks sound for identifying stable production models.


134-138: Good backward compatibility approach.

The combined list and reverse compatibility alias ensure existing code continues to work while providing the new categorized access patterns.

Comment on lines +1559 to +1560
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
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.

💡 Verification agent

🧩 Analysis chain

Verify and align new model options with backend definitions and default value.

Make sure the newly added keys ("claude-opus-4-20250514" and "claude-sonnet-4-20250514") exist in ANTHROPIC_MODELS/ANTHROPIC_MODELS_DETAILED in anthropic_constants.py and that the deprecated "claude-3-haiku-20240307" is fully removed. Also, the starter project’s default "value" ("claude-3-5-sonnet-20241022") must appear in the "options" list—currently it does not.

To verify definitions and default alignment:

If the default index is -1, update it to one of the allowed options (e.g., "claude-opus-4-20250514"):

--- a/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
+++ b/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
@@ -1574,7 +1574,7 @@
                 "type": "str",
-                "value": "claude-3-5-sonnet-20241022"
+                "value": "claude-opus-4-20250514"
             },

🏁 Script executed:

#!/bin/bash
set -e
# Check that the new models are defined and the deprecated one is gone
rg -n 'claude-opus-4-20250514|claude-sonnet-4-20250514|claude-3-haiku-20240307' src/backend/base/langflow/base/models/anthropic_constants.py

# Ensure default value is in the options list (-1 means missing)
jq '.data.nodes[] 
  | select(.type=="AnthropicModel") 
  | .data.node.template.model_name as $mn 
  | ($mn.options | index($mn.value)) // -1' -Mr src/backend/base/langflow/initial_setup/starter_projects/"Custom Component Maker.json"

Length of output: 874


🏁 Script executed:

#!/bin/bash
set -e
# Check occurrences of the default model in the JSON
rg -C2 '"claude-3-5-sonnet-20241022"' src/backend/base/langflow/initial_setup/starter_projects/"Custom Component Maker.json"

# Verify if the default value appears in the options array (prints index or -1)
jq '.data.nodes[]
  | select(.type=="AnthropicModel")
  | .data.node.template.options
  | index("claude-3-5-sonnet-20241022") // -1' -Mr src/backend/base/langflow/initial_setup/starter_projects/"Custom Component Maker.json"

Length of output: 533


Action Required: Sync Anthropic model definitions and starter‐project defaults

The new keys are correctly defined in anthropic_constants.py, but:

  • The deprecated model claude-3-haiku-20240307 still appears in ANTHROPIC_MODELS[_DETAILED]—remove its entry if you intend full removal.
  • The starter project’s default value "claude-3-5-sonnet-20241022" isn’t listed under "options". Either add it to the list or choose one of the new options as the default.

Files to update:

  • src/backend/base/langflow/base/models/anthropic_constants.py
  • src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json

Example diffs:

--- a/src/backend/base/langflow/base/models/anthropic_constants.py
+++ b/src/backend/base/langflow/base/models/anthropic_constants.py
@@ -36,8 +36,6 @@
     "claude-opus-4-20250514": create_model_metadata(
         provider="Anthropic", name="claude-opus-4-20250514", icon="Anthropic", tool_calling=True
     ),
-    "claude-3-haiku-20240307": create_model_metadata(
-        provider="Anthropic", name="claude-3-haiku-20240307", icon="Anthropic", tool_calling=True, deprecated=True
-    ),
     "claude-sonnet-4-20250514": create_model_metadata(
         provider="Anthropic", name="claude-sonnet-4-20250514", icon="Anthropic", tool_calling=True
     ),
--- a/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
+++ b/src/backend/base/langflow/initial_setup/starter_projects/Custom Component Maker.json
@@ -1557,7 +1557,8 @@
                   "claude-opus-4-20250514",
                   "claude-sonnet-4-20250514",
+                  "claude-3-5-sonnet-20241022"
                 ],
                 "type": "str",
-                "value": "claude-3-5-sonnet-20241022"
+                "value": "claude-3-5-sonnet-20241022"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
"claude-opus-4-20250514",
"claude-sonnet-4-20250514",
+ "claude-3-5-sonnet-20241022"
],
"type": "str",
- "value": "claude-3-5-sonnet-20241022"
+ "value": "claude-3-5-sonnet-20241022"
🤖 Prompt for AI Agents
In src/backend/base/langflow/base/models/anthropic_constants.py and
src/backend/base/langflow/initial_setup/starter_projects/Custom Component
Maker.json around lines 1559-1560, remove the deprecated model
"claude-3-haiku-20240307" from ANTHROPIC_MODELS and ANTHROPIC_MODELS_DETAILED in
anthropic_constants.py. Then, in the JSON starter project file, ensure the
default value "claude-3-5-sonnet-20241022" is included in the "options" list or
update the default to one of the new valid options like
"claude-opus-4-20250514". This will align the model definitions and defaults
correctly.

Comment on lines 44 to 48
ANTHROPIC_MODELS = [
# all the models below support tool calling also
"claude-3-7-sonnet-latest",
"claude-3-5-sonnet-latest",
"claude-3-5-haiku-latest",
"claude-3-opus-latest",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
model_name
for model_name, metadata in ANTHROPIC_MODELS_DETAILED.items()
if not metadata.get("deprecated", False) and metadata.get("tool_calling", False)
]
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.

🛠️ Refactor suggestion

Review the ANTHROPIC_MODELS filtering logic.

The filtering logic excludes deprecated models and only includes tool_calling enabled models. This differs from the pattern in other files and may be overly restrictive.

Consider whether this filtering should match the pattern used in other provider files. The current logic:

if not metadata.get("deprecated", False) and metadata.get("tool_calling", False)

This excludes models that don't support tool calling, which might not be the intended behavior. Consider:

-    if not metadata.get("deprecated", False) and metadata.get("tool_calling", False)
+    if not metadata.get("deprecated", False)

Or create a separate list for tool_calling models if both are needed.

🤖 Prompt for AI Agents
In src/backend/base/langflow/base/models/anthropic_constants.py around lines 44
to 48, the current filtering logic for ANTHROPIC_MODELS excludes deprecated
models but only includes those with tool_calling enabled, which is more
restrictive than other provider files. To fix this, adjust the filtering to
exclude only deprecated models without requiring tool_calling to be True,
matching the pattern used elsewhere. If tool_calling-specific filtering is
needed, create a separate list for those models instead of combining both
conditions in ANTHROPIC_MODELS.

Comment on lines +50 to +56
"o3-mini": create_model_metadata(
provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True, not_supported=True
),
"o1-mini": create_model_metadata(
provider="OpenAI", name="o1-mini", icon="OpenAI", reasoning=True, not_supported=True
),
}
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.

💡 Verification agent

🧩 Analysis chain

Review the not_supported reasoning models.

The o3-mini and o1-mini models are marked as both reasoning and not_supported. Verify this is intentional and accurate according to OpenAI's current model availability.


🌐 Web query:

What is the current availability status of OpenAI's o1-mini, o3-mini, and o1 reasoning models? Are o1-mini and o3-mini currently supported in the OpenAI API?

💡 Result:

Current Availability and Support Status of OpenAI o1-mini, o3-mini, and o1 Reasoning Models

o3-mini

  • Availability:
    o3-mini is the latest small reasoning model from OpenAI and is available in the OpenAI API. It is positioned as a high-intelligence, low-latency alternative to o1-mini and is accessible via the Chat Completions API, Assistants API, and Batch API.[1][9]
  • Support in API:
    o3-mini is confirmed as currently supported in the OpenAI API, with key developer features such as streaming, function calling, and structured outputs.[9] It is also available to ChatGPT Plus, Team, and Pro users, and to API users on usage tiers 3–5 (with limitations for lower usage tiers based on rollout).[1][9]
    Additionally, developer messages are supported with o3-mini, unlike o1-mini.[7][9]
  • Context window and compatibility:
    o3-mini supports a 200,000-token context window, making it suitable for larger reasoning tasks.[9]
  • Deprecation:
    o3-mini is intended to replace o1-mini in many contexts, as it offers improved performance at the same cost and latency.[1][4][5]

o1-mini

  • Availability:
    o1-mini is now deprecated and is being replaced by o3-mini as the cost-effective small reasoning model in the lineup.[3][9] It is no longer listed as a featured or current model in OpenAI’s model documentation, and recent platform docs explicitly label o1-mini as deprecated.[3][9]
  • Support in API:
    o1-mini is not currently supported as a production model in the OpenAI API for new users. Only select customers who had previous access (from limited preview releases) may still have regional access, but general access is closed for new deployments.[2][3][9]
  • Limitations:
    o1-mini does not support developer messages and has fewer features compared to o3-mini.[7][9]

o1 (Main Model, Not Mini)

  • Availability:
    The primary o1 reasoning model (not the "mini" variant) is still available as a general reasoning model in the OpenAI API and does not require a special access request for global deployments.[2][3]
  • Support in API:
    o1 is supported and can be accessed for reasoning tasks, but it is no longer the latest or most cost-effective option compared to o3 and o4-mini.[2][3][4]

Summary Table

Model OpenAI API Status Feature Support Notes
o3-mini Supported Full dev features, streaming, function calling Replaces o1-mini; high performance[1][9]
o1-mini Deprecated/Unsupported Limited, no dev messages Only legacy/regional exceptions[2][3][7][9]
o1 Supported Full features Not as advanced as o3/o4-mini[2][3][4]

Key Points

  • o3-mini is supported and available via OpenAI’s API.
  • o1-mini is deprecated and generally not available to new users or for standard deployments.
  • o1 (main) reasoning model remains supported, but is not the latest or most cost-effective choice.

If you are developing new applications or updating existing ones, you should use o3-mini for high-performance, cost-effective reasoning tasks in the OpenAI ecosystem.[1][9]

Citations:


Correct support status for o3-mini

The o3-mini model is currently supported in the OpenAI API and should no longer be marked as not_supported. Please update its metadata accordingly; the o1-mini entry remains deprecated.

• File: src/backend/base/langflow/base/models/openai_constants.py
• Change not_supported=Truenot_supported=False for "o3-mini"

Suggested diff:

-   "o3-mini": create_model_metadata(
-       provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True, not_supported=True
-   ),
+   "o3-mini": create_model_metadata(
+       provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True, not_supported=False
+   ),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"o3-mini": create_model_metadata(
provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True, not_supported=True
),
"o1-mini": create_model_metadata(
provider="OpenAI", name="o1-mini", icon="OpenAI", reasoning=True, not_supported=True
),
}
"o3-mini": create_model_metadata(
provider="OpenAI", name="o3-mini", icon="OpenAI", reasoning=True, not_supported=False
),
"o1-mini": create_model_metadata(
provider="OpenAI", name="o1-mini", icon="OpenAI", reasoning=True, not_supported=True
),
}
🤖 Prompt for AI Agents
In src/backend/base/langflow/base/models/openai_constants.py around lines 50 to
56, the o3-mini model is incorrectly marked as not_supported=True despite being
currently supported by the OpenAI API. Update the create_model_metadata call for
"o3-mini" to set not_supported=False to reflect its actual support status, while
leaving the o1-mini entry unchanged as deprecated.

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

This Looks good,
Have we considered the scenario where the models are dynamically loaded from the API what happens then?

preview: bool # Whether model is in preview/beta (defaults to False)
not_supported: bool # Whether model is not supported or deprecated (defaults to False)
deprecated: bool # Whether model is deprecated (defaults to False)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we add multimodal capabilities tag
Also, mime_type supported or file type supported?

Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly 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 May 30, 2025
Copy link
Copy Markdown
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

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

Can all these be just lists instead of dicts?

@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels May 30, 2025
@github-actions github-actions Bot added refactor Maintenance tasks and housekeeping and removed refactor Maintenance tasks and housekeeping labels May 30, 2025
@mfortman11 mfortman11 added this pull request to the merge queue May 30, 2025
Merged via the queue into main with commit 7ab4951 May 30, 2025
38 checks passed
@mfortman11 mfortman11 deleted the lfoss-1221 branch May 30, 2025 18:44
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
* add model metadata

* add new anthropic models

* templates

* [autofix.ci] apply automated fixes

* stylel fix

* whitespace

* move models to a list

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
smatiolids pushed a commit to smatiolids/langflow-dev that referenced this pull request Jul 4, 2025
* add model metadata

* add new anthropic models

* templates

* [autofix.ci] apply automated fixes

* stylel fix

* whitespace

* move models to a list

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor Maintenance tasks and housekeeping size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants