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
Lint and formatting fixes (#554)
Dev Khant129242534d61
diff --git a/embedchain/bots/__init__.py b/embedchain/bots/__init__.pyindex b7f4d5a00..34cef58f2 100644--- a/embedchain/bots/__init__.py+++ b/embedchain/bots/__init__.py@@ -1,4 +1,5 @@-from embedchain.bots.poe import PoeBot-from embedchain.bots.whatsapp import WhatsAppBot+from embedchain.bots.poe import PoeBot # noqa: F401+from embedchain.bots.whatsapp import WhatsAppBot # noqa: F401+# TODO: fix discord import-# from embedchain.bots.discord import DiscordBot\ No newline at end of file+# from embedchain.bots.discord import DiscordBotdiff --git a/embedchain/bots/whatsapp.py b/embedchain/bots/whatsapp.pyindex cd9d1eaf6..4cdd1a94c 100644--- a/embedchain/bots/whatsapp.py+++ b/embedchain/bots/whatsapp.py@@ -1,4 +1,5 @@import argparse+import importlibimport loggingimport signalimport sys@@ -11,8 +12,14 @@ from .base import BaseBot@register_deserializableclass WhatsAppBot(BaseBot):def __init__(self):- from flask import Flask, request- from twilio.twiml.messaging_response import MessagingResponse+ try:+ self.flask = importlib.import_module("flask")+ self.twilio = importlib.import_module("twilio")+ except ModuleNotFoundError:+ raise ModuleNotFoundError(+ "The required dependencies for WhatsApp are not installed. "+ 'Please install with `pip install --upgrade "embedchain[whatsapp]"`'+ ) from Nonesuper().__init__()def handle_message(self, message):@@ -41,7 +48,7 @@ class WhatsAppBot(BaseBot):return responsedef start(self, host="0.0.0.0", port=5000, debug=True):- app = Flask(__name__)+ app = self.flask.Flask(__name__)def signal_handler(sig, frame):logging.info("\nGracefully shutting down the WhatsAppBot...")@@ -51,9 +58,9 @@ class WhatsAppBot(BaseBot):@app.route("/chat", methods=["POST"])def chat():- incoming_message = request.values.get("Body", "").lower()+ incoming_message = self.flask.request.values.get("Body", "").lower()response = self.handle_message(incoming_message)- twilio_response = MessagingResponse()+ twilio_response = self.twilio.twiml.messaging_response.MessagingResponse()twilio_response.message(response)return str(twilio_response)diff --git a/embedchain/embedchain.py b/embedchain/embedchain.pyindex 38f12d734..e35d7eb4d 100644--- a/embedchain/embedchain.py+++ b/embedchain/embedchain.py@@ -82,7 +82,7 @@ class EmbedChain(JSONSerializable):# Send anonymous telemetryself.s_id = self.config.id if self.config.id else str(uuid.uuid4())self.u_id = self._load_or_generate_user_id()- # NOTE: Uncomment the next two lines when running tests to see if any test fires a telemetry event.+ # NOTE: Uncomment the next two lines when running tests to see if any test fires a telemetry event.# if (self.config.collect_metrics):# raise ConnectionRefusedError("Collection of metrics should not be allowed.")thread_telemetry = threading.Thread(target=self._send_telemetry_event, args=("init",))diff --git a/embedchain/llm/antrophic_llm.py b/embedchain/llm/antrophic_llm.pyindex b996e2be1..90950fa6d 100644--- a/embedchain/llm/antrophic_llm.py+++ b/embedchain/llm/antrophic_llm.py@@ -2,9 +2,8 @@ import loggingfrom typing import Optionalfrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/embedchain/llm/azure_openai_llm.py b/embedchain/llm/azure_openai_llm.pyindex 4ced9ca16..40703446a 100644--- a/embedchain/llm/azure_openai_llm.py+++ b/embedchain/llm/azure_openai_llm.py@@ -2,9 +2,8 @@ import loggingfrom typing import Optionalfrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/embedchain/llm/base_llm.py b/embedchain/llm/base_llm.pyindex 4c25173dd..ef4923923 100644--- a/embedchain/llm/base_llm.py+++ b/embedchain/llm/base_llm.py@@ -3,12 +3,12 @@ from typing import List, Optionalfrom langchain.memory import ConversationBufferMemoryfrom langchain.schema import BaseMessage-from embedchain.helper_classes.json_serializable import JSONSerializablefrom embedchain.config import BaseLlmConfigfrom embedchain.config.llm.base_llm_config import (DEFAULT_PROMPT, DEFAULT_PROMPT_WITH_HISTORY_TEMPLATE,DOCS_SITE_PROMPT_TEMPLATE)+from embedchain.helper_classes.json_serializable import JSONSerializableclass BaseLlm(JSONSerializable):diff --git a/embedchain/llm/gpt4all_llm.py b/embedchain/llm/gpt4all_llm.pyindex 1624ae9f8..36ea325b5 100644--- a/embedchain/llm/gpt4all_llm.py+++ b/embedchain/llm/gpt4all_llm.py@@ -1,9 +1,8 @@from typing import Iterable, Optional, Unionfrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/embedchain/llm/llama2_llm.py b/embedchain/llm/llama2_llm.pyindex 6a2d90a6e..42ec1eff2 100644--- a/embedchain/llm/llama2_llm.py+++ b/embedchain/llm/llama2_llm.py@@ -4,9 +4,8 @@ from typing import Optionalfrom langchain.llms import Replicatefrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/embedchain/llm/openai_llm.py b/embedchain/llm/openai_llm.pyindex 320079f75..f22b271fd 100644--- a/embedchain/llm/openai_llm.py+++ b/embedchain/llm/openai_llm.py@@ -3,9 +3,8 @@ from typing import Optionalimport openaifrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/embedchain/llm/vertex_ai_llm.py b/embedchain/llm/vertex_ai_llm.pyindex b1d47ad6a..a5a9927a0 100644--- a/embedchain/llm/vertex_ai_llm.py+++ b/embedchain/llm/vertex_ai_llm.py@@ -2,9 +2,8 @@ import loggingfrom typing import Optionalfrom embedchain.config import BaseLlmConfig-from embedchain.llm.base_llm import BaseLlm-from embedchain.helper_classes.json_serializable import register_deserializable+from embedchain.llm.base_llm import BaseLlm@register_deserializablediff --git a/tests/llm/test_chat.py b/tests/llm/test_chat.pyindex cb50a8953..a5340b079 100644--- a/tests/llm/test_chat.py+++ b/tests/llm/test_chat.py@@ -1,7 +1,6 @@-import osimport unittest-from unittest.mock import patch, MagicMock+from unittest.mock import MagicMock, patchfrom embedchain import Appfrom embedchain.config import AppConfig, BaseLlmConfig@@ -88,8 +87,8 @@ class TestApp(unittest.TestCase):self.assertEqual(answer, "Test answer")_args, kwargs = mock_retrieve.call_args- self.assertEqual(kwargs.get('input_query'), "Test query")- self.assertEqual(kwargs.get('where'), {"attribute": "value"})+ self.assertEqual(kwargs.get("input_query"), "Test query")+ self.assertEqual(kwargs.get("where"), {"attribute": "value"})mock_answer.assert_called_once()@patch("chromadb.api.models.Collection.Collection.add", MagicMock)@@ -120,6 +119,6 @@ class TestApp(unittest.TestCase):self.assertEqual(answer, "Test answer")_args, kwargs = mock_database_query.call_args- self.assertEqual(kwargs.get('input_query'), "Test query")- self.assertEqual(kwargs.get('where'), {"attribute": "value"})+ self.assertEqual(kwargs.get("input_query"), "Test query")+ self.assertEqual(kwargs.get("where"), {"attribute": "value"})mock_answer.assert_called_once()diff --git a/tests/llm/test_query.py b/tests/llm/test_query.pyindex 55bbb7660..e16ebc90b 100644--- a/tests/llm/test_query.py+++ b/tests/llm/test_query.py@@ -109,8 +109,8 @@ class TestApp(unittest.TestCase):self.assertEqual(answer, "Test answer")_args, kwargs = mock_retrieve.call_args- self.assertEqual(kwargs.get('input_query'), "Test query")- self.assertEqual(kwargs.get('where'), {"attribute": "value"})+ self.assertEqual(kwargs.get("input_query"), "Test query")+ self.assertEqual(kwargs.get("where"), {"attribute": "value"})mock_answer.assert_called_once()@patch("chromadb.api.models.Collection.Collection.add", MagicMock)@@ -142,6 +142,6 @@ class TestApp(unittest.TestCase):self.assertEqual(answer, "Test answer")_args, kwargs = mock_database_query.call_args- self.assertEqual(kwargs.get('input_query'), "Test query")- self.assertEqual(kwargs.get('where'), {"attribute": "value"})+ self.assertEqual(kwargs.get("input_query"), "Test query")+ self.assertEqual(kwargs.get("where"), {"attribute": "value"})mock_answer.assert_called_once()diff --git a/tests/vectordb/test_chroma_db.py b/tests/vectordb/test_chroma_db.pyindex 3188289bc..91a386bbe 100644--- a/tests/vectordb/test_chroma_db.py+++ b/tests/vectordb/test_chroma_db.py@@ -7,7 +7,6 @@ from chromadb.config import Settingsfrom embedchain import Appfrom embedchain.config import AppConfig, ChromaDbConfig-from embedchain.models import EmbeddingFunctions, Providersfrom embedchain.vectordb.chroma_db import ChromaDB@@ -86,7 +85,6 @@ class TestChromaDbHostsLoglevel(unittest.TestCase):"""Test if the `App` instance is initialized without a config that does not contain default hosts and ports."""- config = AppConfig(log_level="DEBUG")_app = App(config=AppConfig(collect_metrics=False))