Add support for anthropic (#1819)

This commit is contained in:
Dev Khant
2024-09-07 02:12:22 +05:30
committed by GitHub
parent 965f7a3735
commit d32ae1a0b1
13 changed files with 82 additions and 84 deletions

View File

@@ -7,17 +7,7 @@ from typing import Dict, List, Optional
try:
from together import Together
except ImportError:
user_input = input("The 'together' library is required. Install it now? [y/N]: ")
if user_input.lower() == 'y':
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)
raise ImportError("The 'together' library is required. Please install it using 'pip install together'.")
from mem0.llms.base import LLMBase
from mem0.configs.llms.base import BaseLlmConfig
@@ -29,7 +19,6 @@ class TogetherLLM(LLMBase):
if not self.config.model:
self.config.model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
self.client = Together()
api_key = self.config.api_key or os.getenv("TOGETHER_API_KEY")
self.client = Together(api_key=api_key)
@@ -92,7 +81,7 @@ class TogetherLLM(LLMBase):
}
if response_format:
params["response_format"] = response_format
if tools:
if tools: # TODO: Remove tools if no issues found with new memory addition logic
params["tools"] = tools
params["tool_choice"] = tool_choice