GiusTex / EdgeGPT

Extension for Text Generation Webui based on EdgeGPT, a reverse engineered API of Microsoft's Bing Chat AI
125 stars 5 forks source link

Colab Compatible #10

Closed ImaBlank2 closed 1 year ago

ImaBlank2 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

ImaBlank2 commented 1 year ago

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 commented 1 year ago

Well done 👍🏻, I'm testing it.

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) ````