The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
Improvement/add getting api key from env (#1710)
dbcontributions0e0d0b8fc7c8
diff --git a/mem0/llms/azure_openai.py b/mem0/llms/azure_openai.pyindex 0998a03ab..3de9cedc4 100644--- a/mem0/llms/azure_openai.py+++ b/mem0/llms/azure_openai.py@@ -1,3 +1,4 @@+import osimport jsonfrom typing import Dict, List, Optional@@ -15,6 +16,9 @@ class AzureOpenAILLM(LLMBase):if not self.config.model:self.config.model = "gpt-4o"self.client = AzureOpenAI()++ api_key = os.getenv("AZURE_OPENAI_API_KEY") or self.config.api_key+ self.client = AzureOpenAI(api_key=api_key)def _parse_response(self, response, tools):"""diff --git a/mem0/llms/groq.py b/mem0/llms/groq.pyindex d66d92a9a..e5b9015ec 100644--- a/mem0/llms/groq.py+++ b/mem0/llms/groq.py@@ -1,3 +1,4 @@+import osimport jsonfrom typing import Dict, List, Optional@@ -20,6 +21,9 @@ class GroqLLM(LLMBase):self.config.model = "llama3-70b-8192"self.client = Groq()+ api_key = os.getenv("GROQ_API_KEY") or self.config.api_key+ self.client = Groq(api_key=api_key)+def _parse_response(self, response, tools):"""Process the response based on whether tools are used or not.diff --git a/mem0/llms/together.py b/mem0/llms/together.pyindex 4dbc9ae60..1d827d3e3 100644--- a/mem0/llms/together.py+++ b/mem0/llms/together.py@@ -1,3 +1,4 @@+import osimport jsonfrom typing import Dict, List, Optional@@ -20,6 +21,9 @@ class TogetherLLM(LLMBase):self.config.model = "mistralai/Mixtral-8x7B-Instruct-v0.1"self.client = Together()+ api_key = os.getenv("TOGETHER_API_KEY") or self.config.api_key+ self.client = Together(api_key=api_key)+def _parse_response(self, response, tools):"""Process the response based on whether tools are used or not.