This PR introduces the memory layer provided by mem0.
Usage
from typing import Annotated
from npiai import FunctionTool, function, FromContext
class MyTool(FunctionTool):
@function
def get_test_id(self, test_id: Annotated[int, FromContext(query="test id")]):
...
Workflow
Any tool parameter with Annotated[Type, FromContext("<query>", "<constraints">)] type hint will be regarded as a context variable. For such a variable, we will first search the memory using the given query and constraints. If no matches are found, we will invoke HITL to ask human for necessary information and save the result into memory, and then rerun the search process to retrieve memory.
If you use a string template as the query, e.g., "{user} id", we will fill in the templates using LLMs (e.g., "@alice id")
This PR introduces the memory layer provided by mem0.
Usage
Workflow
Any tool parameter with
Annotated[Type, FromContext("<query>", "<constraints">)]
type hint will be regarded as a context variable. For such a variable, we will first search the memory using the givenquery
andconstraints
. If no matches are found, we will invoke HITL to ask human for necessary information and save the result into memory, and then rerun the search process to retrieve memory.If you use a string template as the query, e.g.,
"{user} id"
, we will fill in the templates using LLMs (e.g.,"@alice id"
)