Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ollama code to get model.model property instead of model.name #2188

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion embedchain/embedchain/embedder/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, config: Optional[OllamaEmbedderConfig] = None):

client = Client(host=config.base_url)
local_models = client.list()["models"]
if not any(model.get("name") == self.config.model for model in local_models):
if not any(model.get("model") == self.config.model for model in local_models):
logger.info(f"Pulling {self.config.model} from Ollama!")
client.pull(self.config.model)
embeddings = OllamaEmbeddings(model=self.config.model, base_url=config.base_url)
Expand Down
2 changes: 1 addition & 1 deletion embedchain/embedchain/llm/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, config: Optional[BaseLlmConfig] = None):

client = Client(host=config.base_url)
local_models = client.list()["models"]
if not any(model.get("name") == self.config.model for model in local_models):
if not any(model.get("model") == self.config.model for model in local_models):
logger.info(f"Pulling {self.config.model} from Ollama!")
client.pull(self.config.model)

Expand Down
2 changes: 1 addition & 1 deletion mem0/embeddings/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _ensure_model_exists(self):
Ensure the specified model exists locally. If not, pull it from Ollama.
"""
local_models = self.client.list()["models"]
if not any(model.get("name") == self.config.model for model in local_models):
if not any(model.get("model") == self.config.model for model in local_models):
self.client.pull(self.config.model)

def embed(self, text):
Expand Down
2 changes: 1 addition & 1 deletion mem0/llms/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _ensure_model_exists(self):
Ensure the specified model exists locally. If not, pull it from Ollama.
"""
local_models = self.client.list()["models"]
if not any(model.get("name") == self.config.model for model in local_models):
if not any(model.get("model") == self.config.model for model in local_models):
self.client.pull(self.config.model)

def _parse_response(self, response, tools):
Expand Down
2 changes: 1 addition & 1 deletion tests/embeddings/test_ollama_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def mock_ollama_client():
with patch("mem0.embeddings.ollama.Client") as mock_ollama:
mock_client = Mock()
mock_client.list.return_value = {"models": [{"name": "nomic-embed-text"}]}
mock_client.list.return_value = {"models": [{"model": "nomic-embed-text"}]}
mock_ollama.return_value = mock_client
yield mock_client

Expand Down
Loading