Skip to content

Conversation

@lucifertrj
Copy link

@lucifertrj lucifertrj commented Oct 8, 2025

  • Save the preference in the Mem0.AI for the memory layer
  • Based on the given user query, search and retrieve similar preferences from the memory layer.
  • This example is use case driven that is useful for the recommendation systems and travel or food place planner.
  • It uses Gemini as LLM, Qdrant as Vector Store and FastEmbed as Embeddings (open source)

@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added status:awaiting review PR awaiting review from a maintainer component:examples Issues/PR referencing examples folder labels Oct 8, 2025
@chunduriv chunduriv self-assigned this Oct 8, 2025
@Giom-V
Copy link
Collaborator

Giom-V commented Oct 8, 2025

/gemini review

@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

Copy link
Author

@lucifertrj lucifertrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need it to be in ipynb or should I replace it with py for Gemini code assistant to perform the review.

@chunduriv
Copy link
Contributor

Hi @lucifertrj, thanks for the contribution!

Please keep the example as a Interactive Python Notebook (.ipynb). Notebooks are the standard format for examples in this cookbook.

It looks like the notebook file isn't rendering correctly on GitHub due to a metadata issue.

image

Could you please try clearing all the cell outputs in your notebook and then pushing the updated file to this PR? That should resolve the rendering issue.

If you're still having trouble, feel free to share a Colab Gist so I can review your work in the meantime.

@chunduriv chunduriv added status:awaiting response Awaiting a response from the author and removed status:awaiting review PR awaiting review from a maintainer labels Oct 9, 2025
@lucifertrj
Copy link
Author

sure will modify

@lucifertrj
Copy link
Author

Hey @chunduriv I have removed the cell outputs.

you can view the notebook here: https://github.com/lucifertrj/cookbook/blob/longtermmemory/examples/Long_Term_Memory.ipynb

@lucifertrj
Copy link
Author

@chunduriv chunduriv requested a review from Giom-V October 14, 2025 00:21
@lucifertrj
Copy link
Author

lucifertrj commented Oct 23, 2025

@Giom-V and @chunduriv any updates? I have formatted the notebook -nbfmt.

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use %pip in notebooks


Reply via ReviewNB

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use GEMINI_API_KEY instead? We're going to migrate to this new naming soon.


Reply via ReviewNB

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not the gemini embedding model


Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will switch to gemini embedding

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear to me from the code samples what was saved to memory (all the conversation?). Can you add more explanations?


Reply via ReviewNB

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great to explain what's happening here. Is it searching in the memory?


Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I will add the information with one flowchart

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you save the outputs in the notebook so one can see what it does without running it


Reply via ReviewNB

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually It was present, previously it was mentioned to clear the output cells, so I had removed.

@@ -0,0 +1,465 @@
{
Copy link
Collaborator

@Giom-V Giom-V Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you indent the text like this?

SYSTEM_PROMPT = """
  You are an expert executive assistant who thinks carefully before responding,
  adapting to the poliet communication style based on the previous user's established PREFERENCES and the complexity of their query.
  
  
  Maintain a polished, professional tone that is warm yet efficient—concise for
  simple questions, moderate for complex topics, and comprehensive for open-ended discussions.
  
  
  Act as a trusted advisor who doesn't just answer questions but adds value through insights, anticipates needs,
  and prioritizes what matters most while respecting the user's time with clear,   actionable responses.
  """

Reply via ReviewNB

@Giom-V
Copy link
Collaborator

Giom-V commented Oct 31, 2025

@lucifertrj I left you some comments. Basically add more explanations about what's happening.
Can you also add a "what's next?" section at the end?
I'll just try to run the gemini review, but take it with a grain of salt, it can be a bit picky.

@Giom-V
Copy link
Collaborator

Giom-V commented Oct 31, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new example notebook demonstrating long-term memory for Gemini using Mem0.AI, Qdrant, and FastEmbed. The example is a valuable addition, showcasing a practical use case for recommendation systems. However, the notebook has several areas that need improvement to align with the repository's style guide. Key issues include incorrect markdown formatting (title, headings, Colab badge URL), use of !pip instead of %pip, hardcoded model names instead of using Colab forms, and formatting issues like line length and inconsistent code style. Additionally, the notebook appears to have not been fully run and formatted before submission, as indicated by populated execution_count fields and missing cell outputs. Finally, this new notebook needs to be added to the examples/README.md file.

"source": [
"## Long Memory Layer using - Mem0, Gemini and Qdrant\n",
"\n",
"<a target=\"_blank\" href=\"https://colab.research.google.com/drive/13PYVsCenlKOI2iUnPE0A_LcfGDElOWTR?usp=sharing\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" height=30/></a>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The URL for the 'Open in Colab' badge is incorrect. It should point to the notebook's location within the GitHub repository, not a Google Drive link, to allow users to open it directly.1

Suggested change
"<a target=\"_blank\" href=\"https://colab.research.google.com/drive/13PYVsCenlKOI2iUnPE0A_LcfGDElOWTR?usp=sharing\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" height=30/></a>"
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/google-gemini/cookbook/blob/main/examples/Long_Term_Memory.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" height=30/></a>"

Style Guide References

Footnotes

  1. The style guide provides a specific format for the 'Open in Colab' badge URL, which should point to the notebook on GitHub.

"id": "4L89T6n6qibs"
},
"source": [
"## Long Memory Layer using - Mem0, Gemini and Qdrant\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The main title of the notebook should be a level 1 heading (H1) and use sentence case, as per the style guide.12

Suggested change
"## Long Memory Layer using - Mem0, Gemini and Qdrant\n",
"# Long memory layer using Mem0, Gemini and Qdrant\n",

Style Guide References

Footnotes

  1. The style guide requires using one H1 header (# in Markdown) for the title.

  2. The style guide specifies using sentence case for titles and headings.

},
{
"cell_type": "code",
"execution_count": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The execution_count for this cell is 1, and for many others it is not null. This indicates that the notebook formatting script has not been run. Please run the formatter on the notebook before submitting to clear execution counts and ensure consistent formatting.1

Style Guide References

Footnotes

  1. If the execution_count has changed to something other than null, it usually indicates that the formatting script has not been run. A warning should be raised.

Comment on lines 79 to 80
"!pip install agno mem0ai google-genai\n",
"!pip install langchain langchain-community fastembed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The style guide requires using %pip instead of !pip for installations. It's also recommended to combine installations into a single command and use the -U -q flags for google-genai as specified in the guide.12

Suggested change
"!pip install agno mem0ai google-genai\n",
"!pip install langchain langchain-community fastembed"
"%pip install -U -q agno mem0ai 'google-genai>=1.0.0' langchain langchain-community fastembed"

Style Guide References

Footnotes

  1. The style guide specifies using %pip instead of !pip.

  2. The style guide specifies the correct way to install the google-genai SDK, including version and quiet flags.

"id": "3FSrgmEPuC4R"
},
"source": [
"### Define the Memory Configuration\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Headings should use sentence case as per the style guide.1

Suggested change
"### Define the Memory Configuration\n",
"### Define the memory configuration\n",

Style Guide References

Footnotes

  1. The style guide requires using sentence case in titles/headings.

},
"outputs": [],
"source": [
"result1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This cell is expected to display the content of result1, but its output is missing. To improve readability, notebooks should be saved with their outputs so users can see the results without running the code themselves.1 Please run the notebook to completion and save it with the outputs included. This also applies to other cells where output is expected but missing (e.g., lines 298, 351, 449).

Style Guide References

Footnotes

  1. Ideally we want the ouputs to be saved in the notebooks so that one can see what the code does without runnning it.

"source": [
"SYSTEM_PROMPT = \"\"\"\n",
"You are an expert executive assistant who thinks carefully before responding,\n",
"adapting to the poliet communication style based on the previous user's established PREFERENCES and the complexity of their query.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the word "poliet". It should be "polite".

adapting to the polite communication style based on the previous user's established PREFERENCES and the complexity of their query.\n,

Comment on lines +398 to +406
" USER_PROMPT = f\"\"\"\n",
" <question>\n",
" QUESTION: {query}\n",
" </question>\n",
"\n",
" <PREFERENCE>\n",
" Preference: {context}\n",
" </PREFERENCE>\n",
" \"\"\"\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The indentation in this multi-line f-string is inconsistent. Please format it according to the style guide for long strings to improve readability.1

    USER_PROMPT = f"""
      <question>
      QUESTION: {query}
      </question>

      <PREFERENCE>
      Preference: {context}
      </PREFERENCE>
    """

Style Guide References

Footnotes

  1. Long text variables should use triple double quotes and proper indentation for better readability.

"\n",
" # Config the system prompt and make sure to define the input variables inside the USER PROMPT\n",
" response = llm_client.models.generate_content(\n",
" model=\"gemini-2.5-pro\",\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The model ID is hardcoded. For better maintainability and ease of use, the style guide recommends using a Colab form selector to choose the model.1 Please define the model in a separate cell using a parameter, for example:

MODEL_ID = "gemini-2.5-pro" # @param ["gemini-2.5-flash", "gemini-2.5-pro"]

Then, use this MODEL_ID variable here.

Style Guide References

Footnotes

  1. When selecting a model, use a colab selector for easier maintainability.

@lucifertrj
Copy link
Author

@lucifertrj I left you some comments. Basically add more explanations about what's happening. Can you also add a "what's next?" section at the end? I'll just try to run the gemini review, but take it with a grain of salt, it can be a bit picky.

sure. will make the modifications

@lucifertrj
Copy link
Author

@Giom-V I have resolved the comments:

  • replace the !pip install to %pip install
  • replace GOOGLE_API_KEY to GEMINI_API_KEY
  • Switched the embedding model to Google embedding model (previously it was FastEmbed)
  • Added more information details for memory add operation and search operation
  • Removed the dependency of langchain, earlier we used it for fastembed, now its not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:examples Issues/PR referencing examples folder status:awaiting response Awaiting a response from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants