repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: Direct Import |
| #3 | description: 'Bypass the memory deduction phase and directly store pre-defined memories for efficient retrieval' |
| #4 | --- |
| #5 | |
| #6 | ## How to Use Direct Import |
| #7 | |
| #8 | The Direct Import feature allows users to skip the memory deduction phase and directly input pre-defined memories into the system for storage and retrieval. To enable this feature, set the `infer` parameter to `False` in the `add` method. |
| #9 | |
| #10 | |
| #11 | <CodeGroup> |
| #12 | |
| #13 | |
| #14 | ```python Python |
| #15 | messages = [ |
| #16 | {"role": "user", "content": "Alice loves playing badminton"}, |
| #17 | {"role": "assistant", "content": "That's great! Alice is a fitness freak"}, |
| #18 | {"role": "user", "content": "Alice mostly cooks at home because of her gym plan"}, |
| #19 | ] |
| #20 | |
| #21 | |
| #22 | client.add(messages, user_id="alice", infer=False) |
| #23 | ``` |
| #24 | |
| #25 | ```markdown Output |
| #26 | [] |
| #27 | ``` |
| #28 | </CodeGroup> |
| #29 | |
| #30 | You can see that the output of the add call is an empty list. |
| #31 | |
| #32 | <Note>Only messages with the role "user" will be used for storage. Messages with roles such as "assistant" or "system" will be ignored during the storage process.</Note> |
| #33 | |
| #34 | <Warning> |
| #35 | Direct import skips the inference pipeline, so it also skips duplicate detection. If you later send the same fact with `infer=True`, Mem0 will store a second copy. Pick one mode per memory source unless you truly want both versions. |
| #36 | </Warning> |
| #37 | |
| #38 | ## How to Retrieve Memories |
| #39 | |
| #40 | You can retrieve memories using the `search` method. |
| #41 | |
| #42 | <CodeGroup> |
| #43 | |
| #44 | ```python Python |
| #45 | client.search("What is Alice's favorite sport?", user_id="alice") |
| #46 | ``` |
| #47 | |
| #48 | ```json Output |
| #49 | { |
| #50 | "results": [ |
| #51 | { |
| #52 | "id": "19d6d7aa-2454-4e58-96fc-e74d9e9f8dd1", |
| #53 | "memory": "Alice loves playing badminton", |
| #54 | "user_id": "pc123", |
| #55 | "metadata": null, |
| #56 | "categories": null, |
| #57 | "created_at": "2024-10-15T21:52:11.474901-07:00", |
| #58 | "updated_at": "2024-10-15T21:52:11.474912-07:00" |
| #59 | } |
| #60 | ] |
| #61 | } |
| #62 | ``` |
| #63 | |
| #64 | </CodeGroup> |
| #65 | |
| #66 | ## How to Retrieve All Memories |
| #67 | |
| #68 | You can retrieve all memories using the `get_all` method. |
| #69 | |
| #70 | <Callout type="warning" title="Filters Required"> |
| #71 | `get_all()` now requires filters to be specified. |
| #72 | </Callout> |
| #73 | |
| #74 | <CodeGroup> |
| #75 | |
| #76 | ```python Python |
| #77 | client.get_all(filters={"AND": [{"user_id": "alice"}]}) |
| #78 | ``` |
| #79 | |
| #80 | ```json Output |
| #81 | { |
| #82 | "results": [ |
| #83 | { |
| #84 | "id": "19d6d7aa-2454-4e58-96fc-e74d9e9f8dd1", |
| #85 | "memory": "Alice loves playing badminton", |
| #86 | "user_id": "pc123", |
| #87 | "metadata": null, |
| #88 | "categories": null, |
| #89 | "created_at": "2024-10-15T21:52:11.474901-07:00", |
| #90 | "updated_at": "2024-10-15T21:52:11.474912-07:00" |
| #91 | }, |
| #92 | { |
| #93 | "id": "8557f05d-7b3c-47e5-b409-9886f9e314fc", |
| #94 | "memory": "Alice mostly cooks at home because of her gym plan", |
| #95 | "user_id": "pc123", |
| #96 | "metadata": null, |
| #97 | "categories": null, |
| #98 | "created_at": "2024-10-15T21:52:11.474929-07:00", |
| #99 | "updated_at": "2024-10-15T21:52:11.474932-07:00" |
| #100 | } |
| #101 | ] |
| #102 | } |
| #103 | ``` |
| #104 | |
| #105 | </CodeGroup> |
| #106 | |
| #107 | If you have any questions, please feel free to reach out to us using one of the following methods: |
| #108 | |
| #109 | <Snippet file="get-help.mdx" /> |
| #110 |