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:
Edwin Jose 2024-11-01 11:32:43 -04:00 • committed by GitHub
commit 98ee051ca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 138 additions and 4 deletions

View 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