griptape icon indicating copy to clipboard operation
griptape copied to clipboard

Enhance MetaMemory for providing additional context

Open collindutter opened this issue 10 months ago • 0 comments

Discussed in https://github.com/orgs/griptape-ai/discussions/1744

Originally posted by vachillo February 17, 2025 MetaMemory is set up well to supply additional context to the LLM, however it seems underutilized. Can we introduce types of BaseMetaEntrys to handle common use cases?

ex for supplying the current date:

import os
from attrs import define, field

from griptape.configs import Defaults
from griptape.memory.meta import BaseMetaEntry, MetaMemory
from griptape.structures import Agent
from griptape.tools import WebSearchTool
from griptape.drivers import DuckDuckGoWebSearchDriver
from griptape.tasks import PromptTask
from griptape.utils import Stream
from datetime import datetime


@define
class DateTimeMetaEntry(BaseMetaEntry):
    todays_date_and_time: str = field(factory=lambda: datetime.now().strftime("%Y-%m-%d %H:%M:%S"), metadata={"serializable": True})


agent = Agent(
    prompt_driver=prompt_driver,
    tools=[
        WebSearchTool(
            web_search_driver=DuckDuckGoWebSearchDriver()
        ),
    ],
    meta_memory=MetaMemory(entries=[DateTimeMetaEntry()]),
)
agent.run("whats the headlines today?")

this can also be extended to support something like a user context store, similar to services provided by Memobase. something like a UserMetaEntry that contains contextual information (from previous conversations or data) given the current conversation would be exetremely valueable

collindutter avatar Feb 19 '25 20:02 collindutter