yukiarimo / yuna-ai

Your Private Companion. The future AGI takeover starts here!
https://www.yuna-ai.com/
GNU Affero General Public License v3.0
109 stars 14 forks source link

menu.py Windows error 6 #83

Closed Kolouch-Dominik closed 6 months ago

Kolouch-Dominik commented 6 months ago

Describe the bug A clear and concise description of what the bug is.

Traceback (most recent call last): File "D:\Git\yuna-ai-6.3\index.py", line 178, in app.run(host='0.0.0.0', port=4848, ssl_context=('cert.pem', 'key.pem')) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\flask\app.py", line 610, in run cli.show_server_banner(self.debug, self.name) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\flask\cli.py", line 758, in show_server_banner click.echo(f" * Serving Flask app '{app_import_path}'") File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\click\utils.py", line 318, in echo file.write(out) # type: ignore File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\click_compat.py", line 542, in _safe_write return _write(s) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\colorama\ansitowin32.py", line 47, in write self.__convertor.write(text) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\colorama\ansitowin32.py", line 177, in write self.write_and_convert(text) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text self.wrapped.write(text[start:end]) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\click_winconsole.py", line 192, in write return self._text_stream.write(x) File "C:\Users\Dominik\miniconda3\envs\CondaPython\lib\site-packages\click_winconsole.py", line 177, in write raise OSError(self._get_error_message(GetLastError())) OSError: Windows error 6 Expected behavior A clear and concise description of what you expected to happen.

yukiarimo commented 6 months ago

Please generate SSL certificates. You can use this command: openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365

Kolouch-Dominik commented 6 months ago

Please generate SSL certificates. You can use this command: openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365

There is nothing about ssl in the installation requirements. Anyway, I get an error message when I run the command. (CondaPython) PS D:\yuna-ai-6.3> openssl req -x509 -newkey rsa:4096 -nodes -keyout key.pem -out cert.pem -days 365 Can't open "C:\Program Files\Common Files\ssl/openssl.cnf" for reading, No such file or directory 942E0000:error:80000003:system library:BIO_new_file:No such process:crypto\bio\bss_file.c:67:calling fopen(C:\Program Files\Common Files\ssl/openssl.cnf, r) 942E0000:error:10000080:BIO routines:BIO_new_file:no such file:crypto\bio\bss_file.c:75:

yukiarimo commented 6 months ago

Please download OpenSSL from the official website, and then you should try again or use the generated certificates in the project.

Kolouch-Dominik commented 6 months ago

I guess I don't understand you. When I try to run index.py, I get the error in the original post. You say there is a certificate that I can use, how and where? Plus your reactions (thumbs down) are out of place when there is no mention of it anywhere.

Kolouch-Dominik commented 6 months ago

I was able to start the server using the visual studio debugger, but just like the website (https://www.yuna-ai.live/yuna.html) there is an error in the chat https://ctrlv.cz/kFkr https://ctrlv.cz/ZQb4

yukiarimo commented 6 months ago
  1. Certificates were uploaded in the last release to both the main and the dev branches: https://github.com/yukiarimo/yuna-ai/blob/main/key.pem https://github.com/yukiarimo/yuna-ai/blob/main/cert.pem
  2. I have no idea why this error happened, but there could be a few reasons: 2.1. The OpenSSL tool should installed on your machine (you can find an installation manual online). Here's a download link: https://www.openssl.org/source/ 2.2. Maybe you can't use my certificates and should have your own, so please try the first step
  3. About your initial Win 6 error, you can check this solution: https://stackoverflow.com/questions/63325149/running-exe-without-a-console-oserror-winerror-6-the-handle-is-invalid (never heard of it before)
  4. Additional stuff could help: https://stackoverflow.com/questions/7360602/openssl-and-error-in-reading-openssl-conf-file
yukiarimo commented 6 months ago

The website https://www.yuna-ai.live/ serves as a landing page for now. Therefore, you shouldn't use it as a live demo (of AI), mainly because it's not even connected to any server!

We're already resolving this. But because of the GitHub Pages requirement, I wasn't able to link it to the running server + the server is not always live (VPS)

Kolouch-Dominik commented 6 months ago

Thank you for your help.

Nu70ry commented 5 months ago

Thank you for your help.

how did you get it working? i have the exact same error

i downloaded OpenSSL 3.2.1 binary (Installed on C:/program files) added openssl to path so it can be actually called (not sure if it's required) ran the command from yukiarimo created a certificate in the yuna-ai folder with yuna-ai environment activated. Certificate key.pem and cert.pem was successfully created. (see it on timestamp in windows explorer) but still get windows error 6, exact same as in op.

note: i use python 3.10.14 in yuna-ai conda env on win11, cuda toolkit 12.4.1

yukiarimo commented 5 months ago

I don't know if this is related, but you could try using Python 3.8 instead. It seems to fix a lot of issues in any project!

Nu70ry commented 5 months ago

Thanks for your swift response. its a bit different windows error 6 with python 3.8

ggml_cuda_init: GGML_CUDA_FORCE_MMQ: no ggml_cuda_init: CUDA_USE_TENSOR_CORES: yes ggml_cuda_init: found 1 CUDA devices: Device 0: NVIDIA GeForce RTX 4070, compute capability 8.9, VMM: yes Traceback (most recent call last): File "index.py", line 178, in app.run(host='0.0.0.0', port=4848, ssl_context=('cert.pem', 'key.pem')) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\flask\app.py", line 620, in run cli.show_server_banner(self.debug, self.name) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\flask\cli.py", line 756, in show_server_banner click.echo(f" * Serving Flask app '{app_import_path}'") File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\click\utils.py", line 318, in echo file.write(out) # type: ignore File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\click_compat.py", line 542, in _safe_write return _write(s) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\colorama\ansitowin32.py", line 47, in write self.__convertor.write(text) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\colorama\ansitowin32.py", line 177, in write self.write_and_convert(text) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\colorama\ansitowin32.py", line 205, in write_and_convert self.write_plain_text(text, cursor, len(text)) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\colorama\ansitowin32.py", line 210, in write_plain_text self.wrapped.write(text[start:end]) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\click_winconsole.py", line 192, in write return self._text_stream.write(x) File "C:\Users\Nu70ry.conda\envs\YunaAI\lib\site-packages\click_winconsole.py", line 177, in write raise OSError(self._get_error_message(GetLastError())) OSError: Windows error 6 Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> OSError: [WinError 6] The handle is invalid

edit: i tried now also with python 3.9 cuz why not, its the same with 3.8

edit 2: not sure if its related to the problem but the menu script could not download yuna-ai-v2-q6_k.gguf i got a file not found error, it could download yuna-emotion and yuna-vision tho. i did download yuna-ai-v2-q6_k.gguf manual and put it in the lib>models>yuna folder. This was on all python versions the case

Nu70ry commented 5 months ago

ok, i got it working sort of. but i'm not a python dev, so i most likely broke some stuff i dont know i broke.

workaround: i did go into the conda env of Yuna Lib>site-packages>flask and opened app.py i commented the cli.show_server_banner(self.debug, self.name) like this #cli.show_server_banner(self.debug, self.name) saved and got at first attempt some flask errors after restarting the server again it worked. i don't get a login screen tho, im auto logged in.

i did some google search and it seems show_server_banner only is resposible for displaying a msg, not sure tho. hope this info helps to fix this issue and others to get it working sort of.

edit: it works with the cert and key in this repo tho, no need to create it myself.

yukiarimo commented 5 months ago

It works with the cert and key in this repo tho, no need to create it myself

Thanks, good to know!

Lib>site-packages>flask and opened app.py I commented the

Do you want to say that's a Flask's problem?

Nu70ry commented 5 months ago

Lib>site-packages>flask and opened app.py I commented the

Do you want to say that's a Flask's problem?

I dont really know exactly where the issue is, i just follow some leads till i find any function i can disable. I'm missing any context of the code, i just found out while looking into the code that _winconsole.py can't for some reason write bytes down which seems to throw windows error 6 out. It's part of a text conversion into plain text. the first thing that came into my mind was that the cert or key is maybe corrupt but that is not the case.

all starts with the show_server_banner function of cli.py the easiest way is just to disable the function call in app.py.

i think about if it's a dependencies incompatiblity, these happen often in python. But i'm not a py dev so i don't know if flask even can be incompatible with other dependencies. the only thing i know for sure is that this function is not executed successfully.

Also the Yuna-AI is pretty broken with this workaround. The first time i type a msg the script is not able to fetch the chat history and throws error. after a restart of Yuna-AI, a chat history was created and Yuna-AI works without any issues. But i'm stuck with default settings i can't change her profile and such.

edit: i did test which branch of show_server_banner get executed. it's this one that seem to lead to the error:

if app_import_path is not None:
    click.echo(f" * Serving Flask app '{app_import_path}'")

Yuna-AI starts without error if i just give a return in this statement before click.echo gets executed

yukiarimo commented 5 months ago

But I'm stuck with default settings. I can't change her profile and such

You can modify the config.json for the model run and the "kanojo" on the profile page (don't forget to click save; it should work). Yes, the new release is coming this week with MORE customization specifically for ya ;)

After a restart of Yuna-AI, a chat history was created, and Yuna-AI works without any issues

Often, you just need to reload the page to fetch new data and write configs. I can't make it automatically because it causes infinite loops and errors. If you're talking about the server, this is probably again your Flask issue :(

yukiarimo commented 5 months ago

I'll convert this issue to a discussion for the future people :)