Poetry and LLM fixes (#1508)

This commit is contained in:
Dev Khant
2024-07-20 10:49:15 +05:30
committed by GitHub
parent 51fd7db205
commit 0c9c5fe9c2
9 changed files with 26 additions and 1556 deletions

View File

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

View File

@@ -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}")

View File

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

View File

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

View File

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

View File

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