openai-python
openai-python copied to clipboard
Use the openai library in conjunction with the kivy library.
Hi everyone, I'm messing around with the library a bit as I try to use it in conjunction with Kivy. The project as such works when executing the venv virtualization window within Windows, but when passing the project to .APK it closes unexpectedly.
I have tried simpler projects in the conversion from .py to .apk using the Kivy library and they work perfectly. When I apply my OpenAI command lines the APK does not respond.
I have the project in this repository for possible viewing: https://github.com/FoxyCTG21/chatbotapp_public
For the conversion from .py to .apk I use the buildozer library in a Google Colab notebook: https://colab.research.google.com/github/MagnoEfren/kivy/blob/main/KivyApp_a_APK.ipynb?hl=es
I hope I can understand why I can't use the library at the end.
Hi @FoxyCTG21! Thanks for the issue.
We'll try to help where we can though we've tended to find that issues like this are application specific and are thus a bit outside of what we can do on our end to help. Can you tell me a bit more about your issue? Are you getting any logs that might be helpful to debug the issue we can look at?
log fail.txt I don't have much experience in programming, but I give you the log that I always end up seeing when I use android studio to virtualize an android to run the apk. In the log it is displayed that it indicates that the X library is missing. The problem is that now it is X then it is Y then it is Z then it is H and then it is an infinity of libraries and this every time I pass the project from .py to .apk in google colab as mentioned before.
The tests in the project commenting the lines of code that openai appears, ends up in an APK that is executable. Based on this, I ended up deducing that there is some controversy in passing an openai library to APK to use it on Android.
This unfortunately looks like an issue with the build system you're using and not with this library. I'm happy to look at this again if you think the issue is on our end but given that most users have been able to install our package and all of the requirements, I'm inclined to think the issue isn't with our requirements.
I'll keep working on it then. If I can find the error, I will comment on this thread, in case it is going to be closed due to time, there is no problem.
I'm going to close this for now. Feel free to reopen it if there's an update
You must import urllib3 in your builsozer scpec cuz its missing
Traceback (most recent call last):
2022-12-14 23:06:03.299 9964-9992/org.test.chatapp I/python: File "/content/.buildozer/android/app/main.py", line 2, in
requirements = python3, kivy, openai, aiohttp==3.8.4, aiosignal, frozenlist, async-timeout==4.0.2, attrs, multidict, yarl, idna, typing-extensions==4.4.0, charset_normalizer==2.1.1, urllib3, tqdm, requests.This worked for me, hope it works for you.
Thank you @TLQB for sharing this information. I can build the app but get an error while using openai in: api_requestor.py line 409 -> platform.platform() The error is: IsADirectoryError: [Errno 21] Is a directory: '/data/data/org.test.myapp/files/app'
I tried a few things to modify the openai (modify and use it as a local package, to patch it in a recipe as so on) but nothing seems to work good in buildozer. Any ideas please?
@airmaciej You have to change line 409 in file
buildozer/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/"your-app"/armeabi-v7a/openai/api_requestor.py (build-armeabi-v7a or build-arm64-v8a_armeabi-v7a ,...) :
from
"platform": platform.platform()
to
"platform": 'Windows-10-10.0.19044-SP0'
or
"platform":'Linux-5.15.0-69-generic-x86_64-with-glibc2.29'
And for it to work you need to make sure the changes have been applied during deploy android builder debug
. For me, I switched to a sub "requirements" build that proceeds to build (comment (1) and open (2)) and back to the official "requirements" (comment (2) and open (1)) and build back, it will be working!
Sorry my english is not good!
Thanks!
вт, 25 апр. 2023 г., 12:51 TranLeQuyBao @.***>:
@airmaciej https://github.com/airmaciej You have to change line 409 in file buildozer/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/"your-app"/armeabi-v7a/openai/api_requestor.py (build-armeabi-v7a or build-arm64-v8a_armeabi-v7a ,...) : from "platform": platform.platform() to "platform": 'Windows-10-10.0.19044-SP0' or "platform":'Linux-5.15.0-69-generic-x86_64-with-glibc2.29'
And for it to work you need to make sure the changes have been applied during deploy android builder debug. For me, I switched to a sub "requirements" build that proceeds to build (comment (1) and open (2)) and back to the official "requirements" (comment (2) and open (1)) and build back, it will be working!
[image: Screenshot from 2023-04-25 16-36-44] https://user-images.githubusercontent.com/59725425/234237131-77716c88-747c-46df-82fa-bebdcc353665.png
Sorry my english is not good!
— Reply to this email directly, view it on GitHub https://github.com/openai/openai-python/issues/152#issuecomment-1521502306, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3WXFHH3X2HZ4IS2IX3UMOTXC6NBHANCNFSM6AAAAAAS7V2UCE . You are receiving this because you commented.Message ID: @.***>
Thank you @TLQB ! My problem was that I couldn't get the modified openai module to link properly into the buildozer. I am sure there is a better way doing it, what was warked for me is: -> downloading openai python package (with setup.py and so on) into the ./libs -> in buildozer.spec requirements = python3, openai @ file:///mnt/c/path_to_downloaded_package (I didn't use relative path here) -> building for the first time failed because p4a generates wrong requirements.txt tile (with @ operator at the beginning of the file) -> I modified requirements.txt manually and write protected it -> I modified build.py in p4a to catch error if the requirements.txt cannot be regenerated -> started build process again -> it worked
I am aware that this is ugly workaround, but maybe someone will get some usefull information reading this :)
Maybe final information: I used it all in WSL under Windows 10