langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
35.41k stars 4.22k forks source link

fix: Gracefully handle missing imports for model components #4743

Closed ogabrielluiz closed 3 days ago

ogabrielluiz commented 4 days ago

This fixes an issue when trying to import anything from langflow-base. Since we were importing packages that are not installed in langflow-base it would raise an exception.

This pull request refactors the model input constants to manage missing imports more gracefully. It introduces error handling for ImportError exceptions in the initialization of various model components, including OpenAI, Azure OpenAI, Groq, Anthropic, NVIDIA, and Amazon Bedrock. This ensures that informative error messages are provided when required packages are not installed, improving the user experience and debugging process.

codspeed-hq[bot] commented 4 days ago

CodSpeed Performance Report

Merging #4743 will improve performances by 39.22%

Comparing fix-imports-model-constants (6ddf55a) with main (9450f85)

Summary

⚡ 2 improvements
✅ 13 untouched benchmarks

Benchmarks breakdown

Benchmark main fix-imports-model-constants Change
test_successful_run_with_input_type_any 324.1 ms 232.9 ms +39.13%
test_successful_run_with_input_type_text 322.1 ms 231.3 ms +39.22%