feat: automates package installation (#1780)
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from typing import Optional, ClassVar, Dict, Any
|
from typing import Optional, ClassVar, Dict, Any
|
||||||
|
|
||||||
from pydantic import BaseModel, Field, model_validator
|
from pydantic import BaseModel, Field, model_validator
|
||||||
@@ -7,9 +9,17 @@ class ChromaDbConfig(BaseModel):
|
|||||||
try:
|
try:
|
||||||
from chromadb.api.client import Client
|
from chromadb.api.client import Client
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input: Any = 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"])
|
||||||
|
from chromadb.api.client import Client
|
||||||
|
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)
|
||||||
Client: ClassVar[type] = Client
|
Client: ClassVar[type] = Client
|
||||||
|
|
||||||
collection_name: str = Field("mem0", description="Default name for the collection")
|
collection_name: str = Field("mem0", description="Default name for the collection")
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from typing import Dict, List, Optional, Any
|
from typing import Dict, List, Optional, Any
|
||||||
@@ -5,9 +7,16 @@ from typing import Dict, List, Optional, Any
|
|||||||
try:
|
try:
|
||||||
import boto3
|
import boto3
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'boto3' library is required. Install it now? [y/N]: ")
|
||||||
"AWS Bedrock requires extra dependencies. Install with `pip install boto3`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "boto3"])
|
||||||
|
import boto3
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'boto3'. Please install it manually using 'pip install boto3'")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
raise ImportError("The required 'boto3' library is not installed.")
|
||||||
|
|
||||||
from mem0.llms.base import LLMBase
|
from mem0.llms.base import LLMBase
|
||||||
from mem0.configs.llms.base import BaseLlmConfig
|
from mem0.configs.llms.base import BaseLlmConfig
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
@@ -5,9 +7,16 @@ from typing import Dict, List, Optional
|
|||||||
try:
|
try:
|
||||||
from groq import Groq
|
from groq import Groq
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'groq' library is required. Install it now? [y/N]: ")
|
||||||
"Groq requires extra dependencies. Install with `pip install groq`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "groq"])
|
||||||
|
from groq import Groq
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'groq'. Please install it manually using 'pip install groq'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
raise ImportError("The required 'groq' library is not installed.")
|
||||||
|
|
||||||
from mem0.llms.base import LLMBase
|
from mem0.llms.base import LLMBase
|
||||||
from mem0.configs.llms.base import BaseLlmConfig
|
from mem0.configs.llms.base import BaseLlmConfig
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
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.")
|
||||||
|
|
||||||
from mem0.llms.base import LLMBase
|
from mem0.llms.base import LLMBase
|
||||||
from mem0.configs.llms.base import BaseLlmConfig
|
from mem0.configs.llms.base import BaseLlmConfig
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
from mem0.llms.base import LLMBase
|
from mem0.llms.base import LLMBase
|
||||||
from mem0.configs.llms.base import BaseLlmConfig
|
from mem0.configs.llms.base import BaseLlmConfig
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
@@ -5,9 +7,17 @@ from typing import Dict, List, Optional
|
|||||||
try:
|
try:
|
||||||
from together import Together
|
from together import Together
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ImportError(
|
user_input = input("The 'together' library is required. Install it now? [y/N]: ")
|
||||||
"Together requires extra dependencies. Install with `pip install together`"
|
if user_input.lower() == 'y':
|
||||||
) from None
|
try:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "together"])
|
||||||
|
from together import Together
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
print("Failed to install 'together'. Please install it manually using 'pip install together'.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("The required 'together' library is not installed.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
from mem0.llms.base import LLMBase
|
from mem0.llms.base import LLMBase
|
||||||
from mem0.configs.llms.base import BaseLlmConfig
|
from mem0.configs.llms.base import BaseLlmConfig
|
||||||
|
|||||||
Reference in New Issue
Block a user