Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(context): introduce memory layer #95

Merged
merged 10 commits into from
Jul 31, 2024
Merged

feat(context): introduce memory layer #95

merged 10 commits into from
Jul 31, 2024

Conversation

idiotWu
Copy link
Collaborator

@idiotWu idiotWu commented Jul 30, 2024

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")

@idiotWu idiotWu requested a review from wenfengwang July 30, 2024 14:05
Copy link

vercel bot commented Jul 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
npi-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2024 7:19pm

@wenfengwang wenfengwang merged commit b356a08 into dev Jul 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants