-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Long-Term-memory to microchain agent (#129)
* Adding sqlalchemy support * Added long term storage * Using SQLTable for db interactions * Added test for db_storage.py | tested microchain manually * Updated poetry.lock * Minor improvements * Updated poetry.lock * Fixing mypy etc * Added PR comments * Changes after merge * Updated poetry.lock * Fixing mypy * Fixed isort * Implemented PR comments * Fixed isort * Fixed black
- Loading branch information
1 parent
dd79d47
commit de6c70b
Showing
13 changed files
with
268 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# inspired by crewAI's LongTermMemory (https://github.com/joaomdmoura/crewAI/blob/main/src/crewai/memory/long_term/long_term_memory.py) | ||
from typing import Any, Dict, Sequence | ||
|
||
from prediction_market_agent.db.db_storage import DBStorage | ||
from prediction_market_agent.db.models import LongTermMemories | ||
|
||
|
||
# In the future, create a base class which this class extends. | ||
class LongTermMemory: | ||
def __init__(self, task_description: str): | ||
self.task_description = task_description | ||
self.storage = DBStorage() | ||
|
||
def save_history(self, history: list[Dict[str, Any]]) -> None: | ||
"""Save item to storage. Note that score allows many types for easier handling by agent.""" | ||
self.storage.save_multiple( | ||
task_description=self.task_description, | ||
history=history, | ||
) | ||
|
||
def search(self, latest_n: int = 5) -> Sequence[LongTermMemories]: | ||
return self.storage.load(self.task_description, latest_n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.