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 mem0.configs.embeddings.base import BaseEmbedderConfig
|
||||
@@ -6,9 +8,17 @@ from mem0.embeddings.base import EmbeddingBase
|
||||
try:
|
||||
from ollama import Client
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Ollama requires extra dependencies. Install with `pip install ollama`"
|
||||
) from None
|
||||
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)
|
||||
|
||||
|
||||
class OllamaEmbedding(EmbeddingBase):
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import httpx
|
||||
from typing import Optional, List, Union
|
||||
import threading
|
||||
@@ -5,9 +7,17 @@ import threading
|
||||
try:
|
||||
import litellm
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"litellm requires extra dependencies. Install with `pip install litellm`"
|
||||
) from None
|
||||
user_input = input("The 'litellm' library is required. Install it now? [y/N]: ")
|
||||
if user_input.lower() == 'y':
|
||||
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 import Memory, MemoryClient
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import logging
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
@@ -7,9 +9,18 @@ try:
|
||||
import chromadb
|
||||
from chromadb.config import Settings
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Chromadb requires extra dependencies. Install with `pip install chromadb`"
|
||||
) from None
|
||||
user_input = input("The 'chromadb' library is required. Install it now? [y/N]: ")
|
||||
if user_input.lower() == 'y':
|
||||
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
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import json
|
||||
from typing import Optional, List
|
||||
from pydantic import BaseModel
|
||||
@@ -6,9 +8,18 @@ try:
|
||||
import psycopg2
|
||||
from psycopg2.extras import execute_values
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"PGVector requires extra dependencies. Install with `pip install psycopg2`"
|
||||
) from None
|
||||
user_input = input("The 'psycopg2' library is required. Install it now? [y/N]: ")
|
||||
if user_input.lower() == 'y':
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user