-
Notifications
You must be signed in to change notification settings - Fork 8.2k
feat: Get live provider and model data from model.dev #11007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deon-sanchez
wants to merge
47
commits into
main
Choose a base branch
from
lfoss-3056
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
841b365
backend updated
deon-sanchez 76e271b
Merge branch 'main' of https://github.com/langflow-ai/langflow into l…
deon-sanchez cd81575
[autofix.ci] apply automated fixes
autofix-ci[bot] 114591e
updated to use provider env variable
deon-sanchez cf8d0c9
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez 53f365d
[autofix.ci] apply automated fixes
autofix-ci[bot] 3c3fc1e
added doc url link
deon-sanchez 8a2f85f
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez f6666e1
added doc prop
deon-sanchez f32664a
Merge branch 'main' of https://github.com/langflow-ai/langflow into l…
deon-sanchez f845cd2
merge main
deon-sanchez cab466e
fixed disabled empty state
deon-sanchez 25e9aab
[autofix.ci] apply automated fixes
autofix-ci[bot] 7a75235
updated be components with new pattern
deon-sanchez 197113f
fixed conflicts
deon-sanchez bd7adeb
[autofix.ci] apply automated fixes
autofix-ci[bot] 2d43c6e
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] ba86269
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] 0dc9bd1
updated templates
deon-sanchez 8757085
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez 0f22c83
[autofix.ci] apply automated fixes
autofix-ci[bot] d17c9ed
filter based upon provider and models
deon-sanchez f32901c
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez 72f56a8
updated provider mapping and cache clearing logic
deon-sanchez 1b371ca
narrowed exception handling to OSError and ValueError
deon-sanchez c149b66
Merge branch 'main' of https://github.com/langflow-ai/langflow into l…
deon-sanchez 5093169
removed agentic flows creation and moved agentic initialization after…
deon-sanchez b63c348
[autofix.ci] apply automated fixes
autofix-ci[bot] f304bfe
fix: Update model provider filtering and embedding model detection
deon-sanchez ecb222d
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez 17de889
removed console.log
deon-sanchez 8402040
[autofix.ci] apply automated fixes
autofix-ci[bot] 6d23009
updated models showed
deon-sanchez 088d139
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez d1d1cc1
[autofix.ci] apply automated fixes
autofix-ci[bot] 130ec8d
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] ea13598
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] 32552eb
refactor: Simplify embedding model detection logic and add constant f…
deon-sanchez 9d2fe3b
Merge branch 'lfoss-3056' of https://github.com/langflow-ai/langflow …
deon-sanchez a7ada62
Merge branch 'main' into lfoss-3056
deon-sanchez 4f3918e
Merge branch 'main' of https://github.com/langflow-ai/langflow into l…
deon-sanchez fffa68d
merge templates
deon-sanchez b7323be
merge updated templates
deon-sanchez 25de840
Merge branch 'main' of https://github.com/langflow-ai/langflow into l…
deon-sanchez 23699ef
[autofix.ci] apply automated fixes
autofix-ci[bot] be513a2
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] 9f5561f
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,41 @@ | ||
| from .model import LCModelComponent | ||
| from .model_metadata import ModelCost, ModelLimits, ModelMetadata, ModelModalities, create_model_metadata | ||
| from .models_dev_client import ( | ||
| clear_cache as clear_live_models_cache, | ||
| ) | ||
| from .models_dev_client import ( | ||
| fetch_models_dev_data, | ||
| get_live_models_detailed, | ||
| get_models_by_provider, | ||
| get_provider_metadata_from_api, | ||
| search_models, | ||
| ) | ||
| from .unified_models import ( | ||
| get_model_provider_variable_mapping, | ||
| get_model_providers, | ||
| get_unified_models_detailed, | ||
| refresh_live_model_data, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| # Core components | ||
| "LCModelComponent", | ||
| # Unified models API | ||
| "get_model_provider_variable_mapping", | ||
| "get_model_providers", | ||
| "get_unified_models_detailed", | ||
| "refresh_live_model_data", | ||
| # Model metadata types | ||
| "ModelCost", | ||
| "ModelLimits", | ||
| "ModelMetadata", | ||
| "ModelModalities", | ||
| "create_model_metadata", | ||
| # Live models API (models.dev) | ||
| "clear_live_models_cache", | ||
| "fetch_models_dev_data", | ||
| "get_live_models_detailed", | ||
| "get_models_by_provider", | ||
| "get_provider_metadata_from_api", | ||
| "search_models", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,144 @@ | ||
| from typing import TypedDict | ||
|
|
||
|
|
||
| class ModelCost(TypedDict, total=False): | ||
| """Cost information per million tokens.""" | ||
|
|
||
| input: float # Cost per million input tokens | ||
| output: float # Cost per million output tokens | ||
| reasoning: float # Cost per million reasoning tokens (if applicable) | ||
| cache_read: float # Cost per million cached read tokens | ||
| cache_write: float # Cost per million cached write tokens | ||
| input_audio: float # Cost per million audio input tokens | ||
| output_audio: float # Cost per million audio output tokens | ||
|
|
||
|
|
||
| class ModelLimits(TypedDict, total=False): | ||
| """Token limits for the model.""" | ||
|
|
||
| context: int # Maximum context window size | ||
| output: int # Maximum output tokens | ||
|
|
||
|
|
||
| class ModelModalities(TypedDict, total=False): | ||
| """Input/output modalities supported by the model.""" | ||
|
|
||
| input: list[str] # Supported input types (e.g., ["text", "image", "audio"]) | ||
| output: list[str] # Supported output types (e.g., ["text", "image"]) | ||
|
|
||
|
|
||
| class ModelMetadata(TypedDict, total=False): | ||
| """Simple model metadata structure.""" | ||
| """Model metadata structure with extended fields from models.dev API.""" | ||
|
|
||
| provider: str # Provider name (e.g., "anthropic", "groq", "openai") | ||
| # Core identification | ||
| provider: str # Provider name (e.g., "Anthropic", "OpenAI") | ||
| provider_id: str # Provider ID from API (e.g., "anthropic", "openai") | ||
| name: str # Model name/ID | ||
| display_name: str # Human-readable model name | ||
| icon: str # Icon name for UI | ||
|
|
||
| # Capabilities | ||
| 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) | ||
| structured_output: bool # Whether model supports structured output | ||
| temperature: bool # Whether model supports temperature parameter | ||
| attachment: bool # Whether model supports file attachments | ||
|
|
||
| # Status flags | ||
| preview: bool # Whether model is in preview/beta (defaults to False) | ||
| not_supported: bool # Whether model is not supported or deprecated (defaults to False) | ||
| not_supported: bool # Whether model is not supported (defaults to False) | ||
| deprecated: bool # Whether model is deprecated (defaults to False) | ||
| default: bool # Whether model is a default/recommended option (defaults to False) | ||
| model_type: str # Type of model (defaults to "llm" or "embeddings") | ||
| open_weights: bool # Whether model has open weights | ||
|
|
||
| # Model classification | ||
| model_type: str # Type of model ("llm", "embeddings", "image", "audio", "video") | ||
|
|
||
| # Extended metadata from models.dev | ||
| cost: ModelCost # Pricing information | ||
| limits: ModelLimits # Token limits | ||
| modalities: ModelModalities # Supported input/output modalities | ||
| knowledge_cutoff: str # Knowledge cutoff date (e.g., "2024-04") | ||
| release_date: str # Model release date | ||
| last_updated: str # Last update date | ||
|
|
||
| # Provider metadata | ||
| api_base: str # Base API URL for the provider | ||
| env_vars: list[str] # Environment variables for API keys | ||
| documentation_url: str # Link to provider documentation | ||
|
|
||
|
|
||
| def create_model_metadata( | ||
| provider: str, | ||
| name: str, | ||
| icon: str, | ||
| *, | ||
| provider_id: str | None = None, | ||
| display_name: str | None = None, | ||
| tool_calling: bool = False, | ||
| reasoning: bool = False, | ||
| search: bool = False, | ||
| structured_output: bool = False, | ||
| temperature: bool = True, | ||
| attachment: bool = False, | ||
| preview: bool = False, | ||
| not_supported: bool = False, | ||
| deprecated: bool = False, | ||
| default: bool = False, | ||
| open_weights: bool = False, | ||
| model_type: str = "llm", | ||
| cost: ModelCost | None = None, | ||
| limits: ModelLimits | None = None, | ||
| modalities: ModelModalities | None = None, | ||
| knowledge_cutoff: str | None = None, | ||
| release_date: str | None = None, | ||
| last_updated: str | None = None, | ||
| api_base: str | None = None, | ||
| env_vars: list[str] | None = None, | ||
| documentation_url: str | None = None, | ||
| ) -> ModelMetadata: | ||
| """Helper function to create ModelMetadata with explicit defaults.""" | ||
| return ModelMetadata( | ||
| metadata = ModelMetadata( | ||
| provider=provider, | ||
| name=name, | ||
| icon=icon, | ||
| tool_calling=tool_calling, | ||
| reasoning=reasoning, | ||
| search=search, | ||
| structured_output=structured_output, | ||
| temperature=temperature, | ||
| attachment=attachment, | ||
| preview=preview, | ||
| not_supported=not_supported, | ||
| deprecated=deprecated, | ||
| default=default, | ||
| open_weights=open_weights, | ||
| model_type=model_type, | ||
| ) | ||
|
|
||
| # Add optional fields if provided | ||
| if provider_id is not None: | ||
| metadata["provider_id"] = provider_id | ||
| if display_name is not None: | ||
| metadata["display_name"] = display_name | ||
| if cost is not None: | ||
| metadata["cost"] = cost | ||
| if limits is not None: | ||
| metadata["limits"] = limits | ||
| if modalities is not None: | ||
| metadata["modalities"] = modalities | ||
| if knowledge_cutoff is not None: | ||
| metadata["knowledge_cutoff"] = knowledge_cutoff | ||
| if release_date is not None: | ||
| metadata["release_date"] = release_date | ||
| if last_updated is not None: | ||
| metadata["last_updated"] = last_updated | ||
| if api_base is not None: | ||
| metadata["api_base"] = api_base | ||
| if env_vars is not None: | ||
| metadata["env_vars"] = env_vars | ||
| if documentation_url is not None: | ||
| metadata["documentation_url"] = documentation_url | ||
|
|
||
| return metadata |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.