feat: mem0 ai memory block (#9285)

We want to have some more intelligent and less user managed memory
methods, so we add mem0


### Changes 🏗️

- Adds user_id to kwargs for blocks
- Add mem0 blocks

<!-- Concisely describe all of the changes made in this pull request:
-->

### Checklist 📋

- [x] document adding user_id to kwargs for blocks
- [x] Add run and agent Id as optional checkboxes that will be passed
down to mem0

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [ ] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
- [ ] Build and submit an agent to @Torantulino and the marketplace for
a personal AI tutor based on recommendations from the mem0 team

---------

Co-authored-by: Aarushi <50577581+aarushik93@users.noreply.github.com>
Co-authored-by: Zamil Majdy <zamil.majdy@agpt.co>
This commit is contained in:
Nicholas Tindle
2025-01-28 15:15:29 +00:00
committed by GitHub
parent e3190b6234
commit c5747c59d7
19 changed files with 729 additions and 6 deletions

View File

@@ -102,6 +102,13 @@ Follow these steps to create and test a new block:
- **API request**: Send a GET request to the Wikipedia API.
- **Error handling**: Handle various exceptions that might occur during the API request and data processing. We don't need to catch all exceptions, only the ones we expect and can handle. The uncaught exceptions will be automatically yielded as `error` in the output. Any block that raises an exception (or yields an `error` output) will be marked as failed. Prefer raising exceptions over yielding `error`, as it will stop the execution immediately.
- **Yield**: Use `yield` to output the results. Prefer to output one result object at a time. If you are calling a function that returns a list, you can yield each item in the list separately. You can also yield the whole list as well, but do both rather than yielding the list. For example: If you were writing a block that outputs emails, you'd yield each email as a separate result object, but you could also yield the whole list as an additional single result object. Yielding output named `error` will break the execution right away and mark the block execution as failed.
- **kwargs**: The `kwargs` parameter is used to pass additional arguments to the block. It is not used in the example above, but it is available to the block. You can also have args as inline signatures in the run method ala `def run(self, input_data: Input, *, user_id: str, **kwargs) -> BlockOutput:`.
Available kwargs are:
- `user_id`: The ID of the user running the block.
- `graph_id`: The ID of the agent that is executing the block. This is the same for every version of the agent
- `graph_exec_id`: The ID of the execution of the agent. This changes every time the agent has a new "run"
- `node_exec_id`: The ID of the execution of the node. This changes every time the node is executed
- `node_id`: The ID of the node that is being executed. It changes every version of the graph, but not every time the node is executed.
### Field Types