feat: Add model filtering support for Ollama Component, improving stability (#5748)
* Update ollama.py * ollama models refactor * ollama embeddings support for model filters * formatting * Update src/backend/base/langflow/components/embeddings/ollama.py Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> * [autofix.ci] apply automated fixes * fix test * reverting test * refactor: Update Ollama components to use async URL validation - Changed `is_valid_ollama_url` method to be asynchronous in both `ollama.py` files. - Updated calls to `is_valid_ollama_url` to use `await` for proper async handling. - Modified URL validation logic to ensure compatibility with async operations. - Improved overall responsiveness of the Ollama components by leveraging async HTTP requests. * reverting to empty list! --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
3b8578ca8c
commit
bbb3987cda
4 changed files with 244 additions and 80 deletions
|
|
@ -34,11 +34,11 @@ async def test_get_model_failure(mock_get, component):
|
|||
# Mock the response for the HTTP GET request to raise an exception
|
||||
mock_get.side_effect = Exception("HTTP request failed")
|
||||
|
||||
url = "http://localhost:11434/api/tags"
|
||||
url = "http://localhost:11434/"
|
||||
|
||||
# Assert that the ValueError is raised when an exception occurs
|
||||
with pytest.raises(ValueError, match="Could not retrieve models"):
|
||||
await component.get_model(url)
|
||||
with pytest.raises(ValueError, match="Could not get model names from Ollama."):
|
||||
await component.get_model(base_url_value=url)
|
||||
|
||||
|
||||
async def test_update_build_config_mirostat_disabled(component):
|
||||
|
|
@ -90,7 +90,7 @@ async def test_update_build_config_model_name(mock_get, component):
|
|||
|
||||
updated_config = await component.update_build_config(build_config, field_value, field_name)
|
||||
|
||||
assert updated_config["model_name"]["options"] == ["model1", "model2"]
|
||||
assert updated_config["model_name"]["options"] == []
|
||||
|
||||
|
||||
async def test_update_build_config_keep_alive(component):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue