ading2210 / vercel-llm-api

A reverse engineered Python API wrapper for the Vercel AI Playground, which provides free access to many large language models without needing an account.
https://pypi.org/project/vercel-llm-api
GNU General Public License v3.0
159 stars 13 forks source link

Any way to make this work for Python 3.11? #2

Closed mak448a closed 1 year ago

mak448a commented 1 year ago

The installation fails on Python 3.11 because of quickjs.

ading2210 commented 1 year ago

I cannot reproduce this. The library works fine for me on Python 3.11.4.

Console output ``` (.venv) allen@debian-zenbook:/tmp$ pip3 install vercel-llm-api Collecting vercel-llm-api Downloading vercel_llm_api-0.2.1-py3-none-any.whl (18 kB) Collecting quickjs (from vercel-llm-api) Using cached quickjs-1.19.2.tar.gz (455 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting curl-cffi (from vercel-llm-api) Downloading curl_cffi-0.5.6-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.2/7.2 MB 1.3 MB/s eta 0:00:00 Collecting cffi>=1.12.0 (from curl-cffi->vercel-llm-api) Using cached cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (462 kB) Collecting pycparser (from cffi>=1.12.0->curl-cffi->vercel-llm-api) Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) Building wheels for collected packages: quickjs Building wheel for quickjs (pyproject.toml) ... done Created wheel for quickjs: filename=quickjs-1.19.2-cp311-cp311-linux_x86_64.whl size=1713011 sha256=b0dde9da731c5963b1830f371a6c61b426579c843bbb98efa9643f2e598cffee Stored in directory: /home/allen/.cache/pip/wheels/20/16/f1/182c8d825737e142568539e4132160426aa8b4ed4df2749cd7 Successfully built quickjs Installing collected packages: quickjs, pycparser, cffi, curl-cffi, vercel-llm-api Successfully installed cffi-1.15.1 curl-cffi-0.5.6 pycparser-2.21 quickjs-1.19.2 vercel-llm-api-0.2.1 (.venv) allen@debian-zenbook:/tmp$ git clone https://github.com/ading2210/vercel-llm-api Cloning into 'vercel-llm-api'... remote: Enumerating objects: 92, done. remote: Counting objects: 100% (92/92), done. remote: Compressing objects: 100% (46/46), done. remote: Total 92 (delta 28), reused 83 (delta 19), pack-reused 0 Receiving objects: 100% (92/92), 28.06 KiB | 136.00 KiB/s, done. Resolving deltas: 100% (28/28), done. (.venv) allen@debian-zenbook:/tmp$ cd vercel-llm-api/ (.venv) allen@debian-zenbook:/tmp/vercel-llm-api$ python3 examples/chat.py INFO:root:Downloading homepage... INFO:root:Downloading and parsing scripts... INFO:root:Sending to openai:gpt-3.5-turbo: 4 messages INFO:root:Fetching token from https://sdk.vercel.ai/openai.jpeg INFO:root:Waiting for response The 2020 World Series was played at Globe Life Field in Arlington, Texas. (.venv) allen@debian-zenbook:/tmp/vercel-llm-api$ python3 --version Python 3.11.4 (.venv) allen@debian-zenbook:/tmp/vercel-llm-api$ ```
mak448a commented 1 year ago

Here's the output. I'm on Fedora if that helps.

Pip output ```shell Collecting vercel-llm-api Downloading vercel_llm_api-0.2.1-py3-none-any.whl (18 kB) Collecting quickjs Using cached quickjs-1.19.2.tar.gz (455 kB) Preparing metadata (setup.py) ... done Collecting curl-cffi Using cached curl_cffi-0.5.6-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.2 MB) Collecting cffi>=1.12.0 Using cached cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (462 kB) Collecting pycparser Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) Installing collected packages: quickjs, pycparser, cffi, curl-cffi, vercel-llm-api DEPRECATION: quickjs is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 Running setup.py install for quickjs ... error error: subprocess-exited-with-error × Running setup.py install for quickjs did not run successfully. │ exit code: 1 ╰─> [19 lines of output] running install /home/mak448a/venv/lib64/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py creating build creating build/lib.linux-x86_64-cpython-311 creating build/lib.linux-x86_64-cpython-311/quickjs copying quickjs/__init__.py -> build/lib.linux-x86_64-cpython-311/quickjs running build_ext building '_quickjs' extension creating build/temp.linux-x86_64-cpython-311 creating build/temp.linux-x86_64-cpython-311/upstream-quickjs gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -I/home/mak448a/venv/include -I/usr/include/python3.11 -c module.c -o build/temp.linux-x86_64-cpython-311/module.o -Werror=incompatible-pointer-types module.c:1:10: fatal error: Python.h: No such file or directory 1 | #include | ^~~~~~~~~~ compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> quickjs note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. [notice] A new release of pip available: 22.3.1 -> 23.1.2 [notice] To update, run: pip install --upgrade pip ```
ading2210 commented 1 year ago

Maybe this could help you?

mak448a commented 1 year ago

Oh ok thanks, I didn't know I had to install a package. It works now :)

FanaticExplorer commented 1 year ago

@ading2210, the problem is still here for me.

Collecting vercel-llm-api
  Obtaining dependency information for vercel-llm-api from https://files.pythonhosted.org/packages/b5/15/e4f6bcc4b75d11a34c529c860a9599325528e616a7ce63688c14b893e5e4/vercel_llm_api-0.2.1-py3-none-any.whl.metadata
  Using cached vercel_llm_api-0.2.1-py3-none-any.whl.metadata (7.6 kB)
Collecting quickjs (from vercel-llm-api)
  Using cached quickjs-1.19.2.tar.gz (455 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: curl-cffi in d:\python\fanaticexploreruserbot\.venv\lib\site-packages (from vercel-llm-api) (0.5.7)
Requirement already satisfied: cffi>=1.12.0 in d:\python\fanaticexploreruserbot\.venv\lib\site-packages (from curl-cffi->vercel-llm-api) (1.15.1)
Requirement already satisfied: pycparser in d:\python\fanaticexploreruserbot\.venv\lib\site-packages (from cffi>=1.12.0->curl-cffi->vercel-llm-api) (2.21)
Using cached vercel_llm_api-0.2.1-py3-none-any.whl (18 kB)
Building wheels for collected packages: quickjs
  Building wheel for quickjs (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for quickjs (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\quickjs
      copying quickjs\__init__.py -> build\lib.win-amd64-cpython-311\quickjs
      running build_ext
      building '_quickjs' extension
      creating build\temp.win-amd64-cpython-311
      creating build\temp.win-amd64-cpython-311\Release
      creating build\temp.win-amd64-cpython-311\Release\upstream-quickjs
      "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DCONFIG_VERSION=\"2021-03-27\" -DCONFIG_BIGNUM -ID:\Python\FanaticExplorerUserboDCONFIG_BIGNUM -ID:\Python\FanaticExplorerUserbot\.venv\include -IC:\Users\andre\AppData\Local\Programs\Python\Python311\include -IC:\Users\andre\AppDatarogram Files (x86)\Microsoft Visual Studio 14.0\\Local\Programs\Python\Python311\Include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual St" /Tcmodule.c /Fobuild\temp.win-amd64-cpython-31udio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" /Tcmodule.c /Fobuild\temp.win-amd64-cpython-311\Release\module.obj -Werror=incompatible-pointer-types
      cl: Є®¬ ­¤­ п бва®Є  error D8021: ­Ґ¤®ЇгбвЁ¬л© зЁб«®ў®©  аЈг¬Ґ­в "/Werror=incompatible-pointer-types"
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 2

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for quickjs
Failed to build quickjs
ERROR: Could not build wheels for quickjs, which is required to install pyproject.toml-based projects

I'm on Windows, and I hadn't found python-dev for it yet. Using usual venv.

ading2210 commented 1 year ago

Apparently it's already included with the main Python installation. See https://stackoverflow.com/questions/16448710/how-to-get-python-dev-for-windows