langflow icon indicating copy to clipboard operation
langflow copied to clipboard

fix: improvement to ollama component to allow for dynamic filtering based on model capabilities

Open pedrocassalpacheco opened this issue 1 year ago • 4 comments

Refactored src/backend/base/langflow/components/models/ollama.py to avoid hardcoding model name patterns when filtering out embedding models.

The previous implementation relied on name-based heuristics to exclude embedding models from the list of available models. This approach has been replaced with a more robust solution that uses the Ollama REST API (/api/show) to dynamically inspect each model’s capabilities and exclude those with "embedding" listed.

This makes the logic more maintainable and resilient to future changes in model naming.

Single file/method changed

https://github.com/pedrocassalpacheco/langflow/blob/75bbced249b67b1b40d732182e7e507ec157a8cc/src/backend/base/langflow/components/models/ollama.py

pedrocassalpacheco avatar Apr 17 '25 19:04 pedrocassalpacheco

@ogabrielluiz or @italojohnny or @edwinjosechittilappilly - please review.

pedrocassalpacheco avatar Apr 17 '25 19:04 pedrocassalpacheco

@edwinjosechittilappilly - thanks for the review. I modified the filter, but moving constants to a global is not a good approach, as per my comments.

pedrocassalpacheco avatar Apr 22 '25 17:04 pedrocassalpacheco

Looks Good Please do not remove the package lock.json

edwinjosechittilappilly avatar Apr 23 '25 07:04 edwinjosechittilappilly

Changes to package lock reverted.

edwinjosechittilappilly avatar Apr 23 '25 07:04 edwinjosechittilappilly

@pedrocassalpacheco can you fix the tests in the PR?

edwinjosechittilappilly avatar Apr 29 '25 06:04 edwinjosechittilappilly

@pedrocassalpacheco I am waiting for the bug fixes to be merged. Also, since QA is in Progress, I suggest we keep this PR for the Next/follow-up release.

edwinjosechittilappilly avatar May 01 '25 17:05 edwinjosechittilappilly