jpetzke / AutoGPT-YouTube

A plugin for AutoGPT that allows various operations on YouTube, such as downloading Videos
MIT License
128 stars 23 forks source link

Can't instantiate abstract class AutoGPT_YouTube with abstract methods #22

Closed khoody1 closed 1 year ago

khoody1 commented 1 year ago

So, I'm getting this error when I followed the install instructions and try to run Auto-GPT. Any help would be much appreciated. I'm using Docker.

TypeError: Can't instantiate abstract class AutoGPT_YouTube with abstract methods can_handle_report, can_handle_text_embedding, can_handle_user_input, handle_text_embedding, report, user_input

jpetzke commented 1 year ago

Did other plugins work?

khoody1 commented 1 year ago

I haven’t tried other plugins. I asked it to fix itself and that didn’t work either lmao

On Sun, Jun 11, 2023 at 10:38 AM Jonas @.***> wrote:

Did other plugins work?

— Reply to this email directly, view it on GitHub https://github.com/jpetzke/AutoGPT-YouTube/issues/22#issuecomment-1586217309, or unsubscribe https://github.com/notifications/unsubscribe-auth/AII72OK7YASEKAKXMGOJQ2LXKXQ77ANCNFSM6AAAAAAZBFOTYE . You are receiving this because you authored the thread.Message ID: @.***>

--

Best regards,

Kevin M. Hoodwin Texas A&M University '21 -- B.S. in Industrial Distribution https://engineering.tamu.edu/etid/id/index.html - Certified Aggie Ninja https://hlkn.tamu.edu/aggie-ninja-certificate/ University of Arkansas - M.S. in Operations Management https://online.uark.edu/programs/master-science-operations-management.php?utm_source=centro&utm_medium=search&utm_campaign=program-opmgms&dclid=cjkkeqjwhyofbhd9n4lrit32hbsbeiqakbxrunt6i1abl5gk1kb3boykpjlqohvirtqr6xziiqccle3w_wcb

Cell: (214) 906-1998 Feel free to connect with me on LinkedIn http://www.linkedin.com/in/kmhoodwin

yarick commented 1 year ago

Getting the same error. Yes, other plugins loaded ust fine. requirements.txt installed fine.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/root/Auto-GPT/autogpt/__main__.py", line 5, in <module>
    autogpt.cli.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
    rv = super().invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/root/Auto-GPT/autogpt/cli.py", line 96, in main
    run_auto_gpt(
  File "/root/Auto-GPT/autogpt/main.py", line 142, in run_auto_gpt
    cfg.set_plugins(scan_plugins(cfg, cfg.debug_mode))
  File "/root/Auto-GPT/autogpt/plugins.py", line 238, in scan_plugins
    loaded_plugins.append(a_module())
  File "/usr/local/lib/python3.10/site-packages/abstract_singleton/__init__.py", line 14, in __call__
    cls._instances[cls] = super().__call__(*args, **kwargs)
TypeError: Can't instantiate abstract class AutoGPT_YouTube with abstract methods can_handle_report, can_handle_text_embedding, can_handle_user_input, handle_text_embedding, report, user_input
Press any key to continue...
DimDroll commented 1 year ago

Auto-GPT updated their plugin support and introduced new code that needs to be added to all plugins.

Thanks to the owner of the following repo: https://github.com/Yolley/AutoGPT-YouTube

Who added a fix here: https://github.com/Yolley/AutoGPT-YouTube/commit/c817846c57af578b2bbf70e6fee99fdbc42b7c31

Since I'm using docker compose I was able to get it running with:

wget https://github.com/Yolley/AutoGPT-YouTube/archive/refs/heads/master.zip
unzip master.zip
echo -e '\nnltk' >> AutoGPT-YouTube-master/requirements.txt
zip -r AutoGPT-YouTube.zip AutoGPT-YouTube-master
mv AutoGPT-YouTube.zip plugins/

Note, that I'm adding nltk python package as it is missing from the requirements, you need to add following line to the src/autogpt_youtube/youtube_functions.py to make it work too: nltk.download('punkt') I added it to the line #24, as an example:

import youtube_transcript_api
import nltk
import os

def get_youtube_transcript(url: str) -> str:
    """Get the transcript of a YouTube video.

    Args:
        url (str): The URL of the YouTube video.

    Returns:
        str: The transcript of the YouTube video.
    """
    # get the video id
    video_id = url.split("v=")[1]

    # get the transcript
    transcript = youtube_transcript_api.YouTubeTranscriptApi.get_transcript(video_id)

    # convert the transcript to a string
    transcript = "\n".join([line["text"] for line in transcript])

    nltk.download('punkt')

    # check if the transcript has more than 2500 tokens
    tokenized_text = nltk.tokenize.word_tokenize(transcript)
jpetzke commented 1 year ago

fixed it