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
Raise import error if Ollama and Google not found (#1432)
Dev Khante3e107b31d07
diff --git a/embedchain/llm/google.py b/embedchain/llm/google.pyindex 5409b7134..c0002fa99 100644--- a/embedchain/llm/google.py+++ b/embedchain/llm/google.py@@ -1,10 +1,12 @@-import importlibimport loggingimport osfrom collections.abc import Generatorfrom typing import Any, Optional, Union-import google.generativeai as genai+try:+ import google.generativeai as genai+except ImportError:+ raise ImportError("GoogleLlm requires extra dependencies. Install with `pip install google-generativeai`") from Nonefrom embedchain.config import BaseLlmConfigfrom embedchain.helpers.json_serializable import register_deserializable@@ -16,14 +18,6 @@ logger = logging.getLogger(__name__)@register_deserializableclass GoogleLlm(BaseLlm):def __init__(self, config: Optional[BaseLlmConfig] = None):- try:- importlib.import_module("google.generativeai")- except ModuleNotFoundError:- raise ModuleNotFoundError(- "The required dependencies for GoogleLlm are not installed."- 'Please install with `pip install --upgrade "embedchain[google]"`'- ) from None-super().__init__(config)if not self.config.api_key and "GOOGLE_API_KEY" not in os.environ:raise ValueError("Please set the GOOGLE_API_KEY environment variable or pass it in the config.")diff --git a/embedchain/llm/ollama.py b/embedchain/llm/ollama.pyindex c21c522dc..e34ff38e1 100644--- a/embedchain/llm/ollama.py+++ b/embedchain/llm/ollama.py@@ -6,7 +6,11 @@ from langchain.callbacks.manager import CallbackManagerfrom langchain.callbacks.stdout import StdOutCallbackHandlerfrom langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandlerfrom langchain_community.llms.ollama import Ollama-from ollama import Client++try:+ from ollama import Client+except ImportError:+ raise ImportError("Ollama requires extra dependencies. Install with `pip install ollama`") from Nonefrom embedchain.config import BaseLlmConfigfrom embedchain.helpers.json_serializable import register_deserializable