Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Colab Compatible #10

Closed
ImaBlank2 opened this issue May 12, 2023 · 5 comments
Closed

Colab Compatible #10

ImaBlank2 opened this issue May 12, 2023 · 5 comments

Comments

@ImaBlank2
Copy link

Currently works great using it locally but when i tried to use the extension in colab, it never search which kinda left me disappointed as to why it doesn't, is there a way to fix this issue and make it compatible through oobabooga in google colab?

@GiusTex
Copy link
Owner

GiusTex commented May 12, 2023

I never tested it on colab, I'm testing it now to see if it could work.
Edit:
I made a working test (EdgeGPT can read user input and generate an answer), now I have to insert it in the webui
image

@GiusTex
Copy link
Owner

GiusTex commented May 13, 2023

I don't know how to make it work in the text-generation-webui, sorry. When I test the file using this colab Test EdgeGPT colab.txt (rename txt to ipynb and use it on colab) it works:
image

Above I run this file test_script.txt, and EdgeGPT works (if you want to test it, rename txt to py). When the file script.txt is instead inside the webui system (images below) the EdgeGPT part doesn't start, and I don't understand why. If you want to test it, rename txt to py, and upload script.py and the cookies in the EdgeGPT folder. This is an example colab webui made by camenduru and edited a bit by me: pyg-7b-GPTQ-4bit-128g.txt, to use it rename txt to ipynb, and use it on colab.

image
image

@GiusTex
Copy link
Owner

GiusTex commented May 13, 2023

If you find a way to make EdgeGPT work on colab (using the files above or making your new ones) you can open again this issue

@GiusTex GiusTex closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2023
@ImaBlank2
Copy link
Author

Alright, after a day of thinking with my little knowledge of python and tinkering, i was able to make it finally work not only in local but also in colab as well by just simply using the subprocess to call the EdgeGPT function in another python file, since it doesn't work if it's in the main script, i figured that it would be simple to just call the function in another file, i also merged kwisss's version of EdgeGPT which used GoogleWordcloud instead of Bing to let it act as an anti censorship, in case bing doesn't want to respond after getting asked by some NSFW or unethical questions by the user.

Heres the zip file: https://drive.google.com/file/d/1X6J9kuGnCXL8Me-voQWLWNwfdZz1RI1t/view?usp=drivesdk

@GiusTex
Copy link
Owner

GiusTex commented May 15, 2023

Well done 👍🏻, I'm testing it.

  • I don't know though if I can include it in the repository since it uses pieces of kwisss's fork. Alternatively I was thinking of a colab SFW variant, which uses your own search_bot external to the script, with EdgeGPT instead of GoogleWordcloud, and if one doesn't want Bing censorship I can send him to your comment, so I don't directly include parts of kwisss' work; I hope there is no problem using redirection.
  • So would it be okay for you if I changed your files like I described and included them in the repository, I would then add the link to your comment with the uncensored version, or would you prefer I don't add your edited work at all?

I thought about it, in the end there aren't many people asking for colab, and they would probably prefer your version, so if you agree, in order to not always have the zip on your google drive, I should upload it to the repository, so I should probably ask kwisss if we can use those parts (inviting him as a contributor seems like too much).
From what I've seen, the parts taken should be the end of search_bot.py and all of scrap.py

GoogleWordcloud in search_bot.py
except:
    #Anti Bing Censorship, a GoogleWordcloud version of EdgeGPT coded by kwisss
    async def GoogleWordcloud():
      global UserInput, Searchstring, search_results, nouns
      tokens = nltk.word_tokenize(UserInput)
      tagged = nltk.pos_tag(tokens)
      nouns = [word for word, pos in tagged if pos.startswith('N')]        
      nouns_str = ' '.join(nouns)
      search_results = subprocess.Popen(["python", "/content/text-generation-webui/extensions/EdgeGPT/scrape.py",  nouns_str], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      out, err = search_results.communicate()
      if err:
        sys.stderr.write(err.decode())
        print(err.decode())          
      search_results = out.decode()
      return search_results
    asyncio.run(GoogleWordcloud())
  
ai_search(UserInput)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants