feat: Add model_utils and model_constants intorducing PROVIDER_NAMES and MODEL_INFO variables for dynamic updation of model data (#4341)
feat: Add model_utils and model_constants - Enhanced the initialization logic in model_constants to handle delayed imports and circular dependencies. - Improved type hinting for better code clarity and maintainability. Details: - `get_model_info`: Retrieves comprehensive information about all available models, which is used to populate the `MODEL_INFO` dictionary. - `MODEL_INFO`: A dictionary where each key is a model identifier, and the value is a dictionary containing details about the model, such as its `display_name` and configuration options. - `PROVIDER_NAMES`: A list derived from `MODEL_INFO` that holds the names of model providers, providing a quick reference to all available model providers.
This commit is contained in:
parent
10a63ff07e
commit
98ee051ca6
6 changed files with 138 additions and 4 deletions
0
src/backend/tests/unit/base/models/__init__.py
Normal file
0
src/backend/tests/unit/base/models/__init__.py
Normal file
25
src/backend/tests/unit/base/models/test_model_constants.py
Normal file
25
src/backend/tests/unit/base/models/test_model_constants.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from src.backend.base.langflow.base.models.model_constants import ModelConstants
|
||||
|
||||
|
||||
def test_provider_names():
|
||||
# Initialize the ModelConstants
|
||||
ModelConstants.initialize()
|
||||
|
||||
# Expected provider names
|
||||
expected_provider_names = [
|
||||
"AIML",
|
||||
"Amazon Bedrock",
|
||||
"Anthropic",
|
||||
"Azure OpenAI",
|
||||
"Ollama",
|
||||
"Vertex AI",
|
||||
"Cohere",
|
||||
"Google Generative AI",
|
||||
"HuggingFace",
|
||||
"OpenAI",
|
||||
"Perplexity",
|
||||
"Qianfan",
|
||||
]
|
||||
|
||||
# Assert that the provider names match the expected list
|
||||
assert expected_provider_names == ModelConstants.PROVIDER_NAMES
|
||||
Loading…
Add table
Add a link
Reference in a new issue