feat: Automate installation of required libraries. (#1795)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from mem0.configs.embeddings.base import BaseEmbedderConfig
|
from mem0.configs.embeddings.base import BaseEmbedderConfig
|
||||||
@@ -6,9 +8,17 @@ from mem0.embeddings.base import EmbeddingBase
|
|||||||
try:
|
try:
|
||||||
from ollama import Client
|
from ollama import Client
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'ollama' library is required. Install it now? [y/N]: ")
|
||||||
"Ollama requires extra dependencies. Install with `pip install ollama`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
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)
|
||||||
|
|
||||||
|
|
||||||
class OllamaEmbedding(EmbeddingBase):
|
class OllamaEmbedding(EmbeddingBase):
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import httpx
|
import httpx
|
||||||
from typing import Optional, List, Union
|
from typing import Optional, List, Union
|
||||||
import threading
|
import threading
|
||||||
@@ -5,9 +7,17 @@ import threading
|
|||||||
try:
|
try:
|
||||||
import litellm
|
import litellm
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'litellm' library is required. Install it now? [y/N]: ")
|
||||||
"litellm requires extra dependencies. Install with `pip install litellm`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "litellm"])
|
||||||
|
import litellm
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'litellm'. Please install it manually using 'pip install litellm'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
raise ImportError("The required 'litellm' library is not installed.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from mem0.memory.telemetry import capture_client_event
|
from mem0.memory.telemetry import capture_client_event
|
||||||
from mem0 import Memory, MemoryClient
|
from mem0 import Memory, MemoryClient
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional, List, Dict
|
from typing import Optional, List, Dict
|
||||||
|
|
||||||
@@ -7,9 +9,18 @@ try:
|
|||||||
import chromadb
|
import chromadb
|
||||||
from chromadb.config import Settings
|
from chromadb.config import Settings
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'chromadb' library is required. Install it now? [y/N]: ")
|
||||||
"Chromadb requires extra dependencies. Install with `pip install chromadb`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "chromadb"])
|
||||||
|
import chromadb
|
||||||
|
from chromadb.config import Settings
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'chromadb'. Please install it manually using 'pip install chromadb'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("The required 'chromadb' library is not installed.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from mem0.vector_stores.base import VectorStoreBase
|
from mem0.vector_stores.base import VectorStoreBase
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
@@ -6,9 +8,18 @@ try:
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2.extras import execute_values
|
from psycopg2.extras import execute_values
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'psycopg2' library is required. Install it now? [y/N]: ")
|
||||||
"PGVector requires extra dependencies. Install with `pip install psycopg2`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "psycopg2"])
|
||||||
|
import psycopg2
|
||||||
|
from psycopg2.extras import execute_values
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'psycopg2'. Please install it manually using 'pip install psycopg2'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("The required 'psycopg2' library is not installed.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
from mem0.vector_stores.base import VectorStoreBase
|
from mem0.vector_stores.base import VectorStoreBase
|
||||||
|
|||||||
Reference in New Issue
Block a user