Browse Source

Poetry and LLM fixes (#1508)

Dev Khant 1 year ago
parent
commit
0c9c5fe9c2
9 changed files with 24 additions and 949 deletions
  1. 1 0
      Makefile
  2. 4 1
      mem0/llms/aws_bedrock.py
  3. 1 1
      mem0/llms/configs.py
  4. 4 1
      mem0/llms/groq.py
  5. 4 1
      mem0/llms/litellm.py
  6. 4 1
      mem0/llms/together.py
  7. 4 0
      mem0/vector_stores/qdrant.py
  8. 1 939
      poetry.lock
  9. 1 5
      pyproject.toml

+ 1 - 0
Makefile

@@ -12,6 +12,7 @@ install:
 
 install_all:
 	poetry install
+	poetry run pip install groq together boto3 litellm
 
 # Format code with ruff
 format:

+ 4 - 1
mem0/llms/aws_bedrock.py

@@ -2,7 +2,10 @@ import os
 import json
 from typing import Dict, List, Optional, Any
 
-import boto3
+try:
+    import boto3
+except ImportError:
+    raise ImportError("AWS Bedrock requires extra dependencies. Install with `pip install boto3`") from None
 
 from mem0.llms.base import LLMBase
 from mem0.configs.llms.base import BaseLlmConfig

+ 1 - 1
mem0/llms/configs.py

@@ -14,7 +14,7 @@ class LlmConfig(BaseModel):
     @field_validator("config")
     def validate_config(cls, v, values):
         provider = values.data.get("provider")
-        if provider in ["openai", "ollama", "groq"]:
+        if provider in ("openai", "ollama", "groq", "together", "aws_bedrock", "litellm"):
             return v
         else:
             raise ValueError(f"Unsupported LLM provider: {provider}")

+ 4 - 1
mem0/llms/groq.py

@@ -1,7 +1,10 @@
 import json
 from typing import Dict, List, Optional
 
-from groq import Groq
+try:
+    from groq import Groq
+except ImportError:
+    raise ImportError("Groq requires extra dependencies. Install with `pip install groq`") from None
 
 from mem0.llms.base import LLMBase
 from mem0.configs.llms.base import BaseLlmConfig

+ 4 - 1
mem0/llms/litellm.py

@@ -1,7 +1,10 @@
 import json
 from typing import Dict, List, Optional
 
-import litellm
+try:
+    import litellm
+except ImportError:
+    raise ImportError("litellm requires extra dependencies. Install with `pip install litellm`") from None
 
 from mem0.llms.base import LLMBase
 from mem0.configs.llms.base import BaseLlmConfig

+ 4 - 1
mem0/llms/together.py

@@ -1,7 +1,10 @@
 import json
 from typing import Dict, List, Optional
 
-from together import Together
+try:
+    from together import Together
+except ImportError:
+    raise ImportError("Together requires extra dependencies. Install with `pip install together`") from None
 
 from mem0.llms.base import LLMBase
 from mem0.configs.llms.base import BaseLlmConfig

+ 4 - 0
mem0/vector_stores/qdrant.py

@@ -1,3 +1,5 @@
+import os
+import shutil
 import logging
 from typing import Optional
 
@@ -50,6 +52,8 @@ class Qdrant(VectorStoreBase):
             params = {}
             if path:
                 params["path"] = path
+                if os.path.exists(path) and os.path.isdir(path):
+                    shutil.rmtree(path)
             if api_key:
                 params["api_key"] = api_key
             if url:

File diff suppressed because it is too large
+ 1 - 939
poetry.lock


+ 1 - 5
pyproject.toml

@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "mem0ai"
-version = "0.0.6"
+version = "0.0.7"
 description = "Long-term memory for AI Agents"
 authors = ["Deshraj Yadav <deshraj@mem0.ai>", "Taranjeet Singh <taranjeet@mem0.ai>"]
 exclude = [
@@ -20,10 +20,6 @@ qdrant-client = "^1.9.1"
 pydantic = "^2.7.3"
 openai = "^1.33.0"
 posthog = "^3.5.0"
-groq = "^0.9.0"
-together = "^1.2.1"
-boto3 = "^1.34.144"
-litellm = "^1.41.24"
 
 [tool.poetry.group.test.dependencies]
 pytest = "^8.2.2"

Some files were not shown because too many files changed in this diff