feat: Automate installation of required libraries. (#1795)

This commit is contained in:
Jaimin Godhani
2024-09-03 12:37:57 +05:30
committed by GitHub
parent 9804f078d0
commit d03ba0fc8a
4 changed files with 54 additions and 12 deletions

View File

@@ -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