circular import

pull/48/head
Kye 1 year ago
parent 079507a713
commit fc9a985d67

@ -6,12 +6,10 @@ from langchain.chains.llm import LLMChain
from pydantic import ValidationError
from swarms.agents.memory.base import VectorStoreRetriever
from swarms.agents.memory.base_memory import ChatMessageHistory, BaseChatMessageHistory
from swarms.agents.memory.base_memory import BaseChatMessageHistory, ChatMessageHistory
from swarms.agents.memory.document import Document
from swarms.agents.models.base import AbstractModel
from swarms.agents.models.prompts.agent_output_parser import AgentOutputParser
from swarms.agents.models.prompts.agent_prompt import (
AIMessage,

@ -1,19 +1,13 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Dict, List
from abc import ABC
from typing import Any, Dict, Optional, Tuple
from pydantic import Field
from typing import Any, Dict, List, Optional, Tuple
from langchain.memory.utils import get_prompt_input_key
from pydantic import BaseModel, Field
from swarms.agents.models.prompts.base import AIMessage, BaseMessage, HumanMessage
from swarms.utils.serializable import Serializable
from swarms.agents.memory.chat_message_history import ChatMessageHistory
from langchain.memory.utils import get_prompt_input_key
class BaseMemory(Serializable, ABC):
@ -132,6 +126,20 @@ class BaseChatMessageHistory(ABC):
"""Remove all messages from the store"""
class ChatMessageHistory(BaseChatMessageHistory, BaseModel):
"""In memory implementation of chat message history.
Stores messages in an in memory list.
"""
messages: List[BaseMessage] = []
def add_message(self, message: BaseMessage) -> None:
"""Add a self-created message to the store"""
self.messages.append(message)
def clear(self) -> None:
self.messages = []
class BaseChatMemory(BaseMemory, ABC):
"""Abstract base class for chat memory."""
@ -164,4 +172,5 @@ class BaseChatMemory(BaseMemory, ABC):
def clear(self) -> None:
"""Clear memory contents."""
self.chat_memory.clear()
self.chat_memory.clear()

@ -1,21 +0,0 @@
from typing import List
from pydantic import BaseModel
from swarms.agents.memory.base_memory import BaseChatMessageHistory, BaseMessage
class ChatMessageHistory(BaseChatMessageHistory, BaseModel):
"""In memory implementation of chat message history.
Stores messages in an in memory list.
"""
messages: List[BaseMessage] = []
def add_message(self, message: BaseMessage) -> None:
"""Add a self-created message to the store"""
self.messages.append(message)
def clear(self) -> None:
self.messages = []
Loading…
Cancel
Save