ading2210 / poe-api

[UNMAINTAINED] A reverse engineered Python API wrapper for Quora's Poe, which provides free access to ChatGPT, GPT-4, and Claude.
https://pypi.org/project/poe-api
GNU General Public License v3.0
2.5k stars 313 forks source link

0.4.13 seems to break Python 3.11 compatibility #187

Open claell opened 1 year ago

claell commented 1 year ago
          note that quickjs package is not compatible with Python 3.11, so you may face an issue while trying to upgrade poe-api 0.4.13 :D

Originally posted by @asce0 in https://github.com/ading2210/poe-api/issues/184#issuecomment-1646871946

See comment above. Creating as separate issue to keep track of the problem.

ading2210 commented 1 year ago

I put a note in the README about this. You need the python-dev package installed if you're on Linux.

claell commented 1 year ago

Hopefully, in the future, Python 3.11 compatibility can be restored, though?

claell commented 1 year ago

I am on Windows, BTW.

asce0 commented 1 year ago

I am on Windows, BTW.

So how did you install quickjs 🤔

claell commented 1 year ago

I didn't install it, I used an older Python version for now.

asce0 commented 1 year ago

Oh, my bad, I thought you did install it 😅

ichuixue commented 1 year ago

@ading2210 You can use js2py instead of quickjs. js2py works fine for Python 3.11

import js2py

def extract_formkey(self, html):
    script_regex = r'<script>(.+?)</script>'
    script_text = "window = {};"
    script_text += "".join(re.findall(script_regex, html))

    function_regex = r'(window\.[a-zA-Z0-9]{17})=function'
    function_text = re.search(function_regex, script_text).group(1)
    script_text += f"{function_text}();"

    formkey = js2py.eval_js(script_text)
    return formkey
ading2210 commented 1 year ago

js2py is not sandboxed, and it's possible for a script to call Python functions.

2-3-5-7 commented 1 year ago

I just found that someone has compiled quickjs for python3.11, and it seems worked for windows

https://github.com/PetterS/quickjs/issues/127

UchihaYuki commented 11 months ago

I put a note in the README about this. You need the python-dev package installed if you're on Linux.

I still can't install quickjs

> apt-get install python3-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-dev is already the newest version (3.11.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> pip install quickjs
...
ERROR: Could not build wheels for quickjs, which is required to install pyproject.toml-based projects