-
Notifications
You must be signed in to change notification settings - Fork 19.8k
feat(model-profiles): distribute data across packages #34024
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
ccurme
wants to merge
28
commits into
master
Choose a base branch
from
cc/model_profiles_distributed
base: master
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.
+5,299
−15,605
Open
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
11b1b20
add profile module to langchain-core
ccurme 0ce2d59
add tomli to core deps
ccurme 771d1e6
turn langchain-model-profiles into cli tool for refreshing data
ccurme 2f96ba6
add data to anthropic
ccurme d6f9ef9
move loading to provider packages
ccurme 4c60b4c
move to attribute in core
ccurme 829eed4
support on anthropic
ccurme 55c0a4d
allow setting profile fields without mutation
ccurme 09b0e9a
nit
ccurme 97a6015
Merge branch 'master' into cc/model_profiles_distributed
ccurme 42a39d1
cr
ccurme ed461f4
move data loader tests
ccurme fc4666c
restructure augmentations toml
ccurme 14f6770
update langchain-model-profiles tests
ccurme b5bee8d
update langchain-model-profiles readme
ccurme 3f14327
fixes
ccurme 55f00a7
implement _get_default_model_profile
ccurme 3012d7b
update openai
ccurme a0beff2
update langchain_v1
ccurme 4c5aa25
override for azure
ccurme 18cc6c4
deepseek
ccurme 2bb9315
fireworks
ccurme c4514ea
groq
ccurme 9622375
huggingface
ccurme e3c2631
mistral
ccurme d05641b
perplexity
ccurme a86c3f2
xai
ccurme 4fd9c77
resolve todo
ccurme 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
11 changes: 11 additions & 0 deletions
11
libs/core/langchain_core/language_models/profile/__init__.py
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| """Model profile types and data loading utilities.""" | ||
|
|
||
| from langchain_core.language_models.profile.model_profile import ( | ||
| ModelProfile, | ||
| ModelProfileRegistry, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "ModelProfile", | ||
| "ModelProfileRegistry", | ||
| ] |
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
45 changes: 45 additions & 0 deletions
45
libs/core/langchain_core/language_models/profile/_loader_utils.py
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """Utilities for loading model profiles from provider packages.""" | ||
|
|
||
| from functools import lru_cache | ||
| from pathlib import Path | ||
|
|
||
| from langchain_core.language_models.profile._data_loader import _DataLoader | ||
| from langchain_core.language_models.profile.model_profile import ( | ||
| ModelProfileRegistry, | ||
| map_raw_data_to_profile, | ||
| ) | ||
|
|
||
|
|
||
| def load_profiles_from_data_dir( | ||
| data_dir: Path, provider_id: str | ||
| ) -> ModelProfileRegistry | None: | ||
| """Load model profiles from a provider's data directory. | ||
|
|
||
| Args: | ||
| data_dir: Path to the provider's data directory. | ||
| provider_id: The provider identifier (e.g., 'anthropic', 'openai'). | ||
|
|
||
| Returns: | ||
| ModelProfile with model capabilities, or None if not found. | ||
| """ | ||
| loader = _get_loader(data_dir) | ||
| data = loader.get_profile_data(provider_id) | ||
| if not data: | ||
| return None | ||
| return { | ||
| model_name: map_raw_data_to_profile(raw_profile) | ||
| for model_name, raw_profile in data.items() | ||
| } | ||
|
|
||
|
|
||
| @lru_cache(maxsize=32) | ||
| def _get_loader(data_dir: Path) -> _DataLoader: | ||
| """Get a cached loader for a data directory. | ||
|
|
||
| Args: | ||
| data_dir: Path to the data directory. | ||
|
|
||
| Returns: | ||
| DataLoader instance. | ||
| """ | ||
| return _DataLoader(data_dir) |
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
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.