mem0ai / mem0

The Memory layer for your AI apps
https://mem0.ai
Apache License 2.0
22.8k stars 2.09k forks source link

Automate Package Installation for Missing Dependencies #1768

Closed Jai0401 closed 2 months ago

Jai0401 commented 2 months ago

🚀 The feature

Description:

Currently, missing dependencies require users to manually install packages, leading to potential errors. I propose adding functionality to automate this process.

Proposed Solution:

Implement a mechanism to automatically prompt users to install missing packages. If they agree, the required package will be installed using pip.

Example Implementation:

Current Implementation:

try:
    from ollama import Client
except ImportError:
    raise ImportError(
        "Ollama requires extra dependencies. Install with `pip install ollama`"
    ) from None

Proposed Implementation:

import subprocess
import sys

try:
    from ollama import Client
except ImportError:
    user_agree = input("The 'ollama' library is required. Install it now? [y/N]: ")
    if user_agree.lower() == 'y':
        try:
            subprocess.check_call([sys.executable, "-m", "pip", "install", "ollama"])
            from ollama import Client
        except subprocess.CalledProcessError:
            print("Failed to install 'ollama'. Please install it manually.")
            sys.exit(1)
    else:
        raise ImportError("The required 'ollama' library is not installed.")

Motivation, pitch

Tasks (Files to be Changed):

NavyaAlapati13 commented 2 months ago

Can you assign me this issue @Dev-Khant ? I am willing to work on it.

Dev-Khant commented 2 months ago

@NavyaAlapati13 Please feel free to work on it. Thanks.

Jai0401 commented 2 months ago

Hi @Dev-Khant , I was already working on this issue and was waiting for the maintainers' approval before proceeding. Could I continue with the implementation? Thank you!

Dev-Khant commented 2 months ago

Hey @Jai0401 Sure, you can work on this. And please it is advisible to inform prior or mention in description that you are awaiting maintainer approval. Feel free to work on this. Looking forward for a PR!

@NavyaAlapati13 Sorry I'll have to unassign this issue from you as the author is already working on it. Feel free to work on other issues. Thanks!

Jai0401 commented 2 months ago

Got it, @Dev-Khant! I'll make sure to mention it next time. Thanks for the guidance!

Jai0401 commented 2 months ago

@Dev-Khant Could you please review these sample changes in pr #1780 ? I’ll proceed based on your feedback.

deshraj commented 2 months ago

Sorry, I should have communicated it earlier but we don't want to support this feature since it can cause issues in user's python environment without them being aware of it.

Will close this issue now. Thanks!