fix: OSS Python SDK hygiene batch, 9 small bug fixes (#6770)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from typing import Optional, Literal
|
||||
from typing import Literal, Optional
|
||||
|
||||
from mem0.embeddings.base import EmbeddingBase
|
||||
from mem0.configs.embeddings.base import BaseEmbedderConfig
|
||||
from mem0.embeddings.base import EmbeddingBase
|
||||
|
||||
try:
|
||||
from fastembed import TextEmbedding
|
||||
@@ -29,4 +29,4 @@ class FastEmbedEmbedding(EmbeddingBase):
|
||||
"""
|
||||
text = text.replace("\n", " ")
|
||||
embeddings = list(self.dense_model.embed(text))
|
||||
return embeddings[0]
|
||||
return embeddings[0].tolist()
|
||||
|
||||
@@ -17,7 +17,7 @@ class HuggingFaceEmbedding(EmbeddingBase):
|
||||
super().__init__(config)
|
||||
|
||||
if self.config.huggingface_base_url:
|
||||
self.client = OpenAI(base_url=self.config.huggingface_base_url)
|
||||
self.client = OpenAI(base_url=self.config.huggingface_base_url, api_key=self.config.api_key)
|
||||
self.config.model = self.config.model or "tei"
|
||||
else:
|
||||
self.config.model = self.config.model or "multi-qa-MiniLM-L6-cos-v1"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Literal, Optional
|
||||
|
||||
from mem0.configs.embeddings.base import BaseEmbedderConfig
|
||||
@@ -8,17 +6,7 @@ from mem0.embeddings.base import EmbeddingBase
|
||||
try:
|
||||
from ollama import Client
|
||||
except ImportError:
|
||||
user_input = input("The 'ollama' library is required. Install it now? [y/N]: ")
|
||||
if user_input.lower() == "y":
|
||||
try:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", "ollama"])
|
||||
from ollama import Client
|
||||
except subprocess.CalledProcessError:
|
||||
print("Failed to install 'ollama'. Please install it manually using 'pip install ollama'.")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("The required 'ollama' library is not installed.")
|
||||
sys.exit(1)
|
||||
raise ImportError("The 'ollama' library is required. Please install it using 'pip install ollama'.")
|
||||
|
||||
|
||||
class OllamaEmbedding(EmbeddingBase):
|
||||
|
||||
Reference in New Issue
Block a user