kaixxx / QualCoder

Qualitative data analysis for text, images, audio, video. Cross platform. Python 3.8 or newer and PyQt6.
https://qualcoder.wordpress.com/
MIT License
6 stars 2 forks source link

AI doesn't start properly on OSX #7

Open rytmisk opened 1 month ago

rytmisk commented 1 month ago

Describe the bug :
I have registered and inputed the API-key on blablabla and when I start the newest Qualcoder on OSX I get the following error pop up:

Traceback (most recent call last):
  File "qualcoder/ai_async_worker.py", line 117, in run

  File "qualcoder/ai_vectorstore.py", line 303, in _open_db

  File "langchain_core/_api/deprecation.py", line 203, in warn_if_direct_instance

  File "langchain_community/embeddings/huggingface.py", line 74, in __init__

ImportError: Could not import sentence_transformers python package. Please install it with `pip install sentence-transformers`.

And I have of course tested to install the sentence-transformers. But it doesn't make a difference.

To Reproduce :
Mention Steps to reproduce the behavior.

Expected behavior :
A description of what you expected to happen.

Screenshots :
If applicable, add screenshots that helps to explain your problem.

Desktop (please complete the following information):

Additional context :
Add any other context about the problem here.

rytmisk commented 1 month ago

More information: Sometimes AI works (on some codes) but more often it does not. I attempt to analyze one with "Code Summary" and get the following error:

Traceback (most recent call last):
  File "qualcoder/ai_async_worker.py", line 117, in run

  File "qualcoder/ai_llm.py", line 309, in _ai_async_stream

  File "langchain_core/language_models/chat_models.py", line 360, in stream

  File "langchain_core/language_models/chat_models.py", line 340, in stream

  File "langchain_openai/chat_models/base.py", line 527, in _stream

TypeError: object of type 'NoneType' has no len()`
rytmisk commented 1 month ago

Another update: I have now tried to upgrade my OSX to the latest and greatest. No difference. Action Log is stuck on "Ai: Starting up" - and the AI chat from the text coding window does not work. Only some from the "AI Chat" window. Strange!!

kaixxx commented 1 month ago

This is strange. It seems that we have multiple issues here. They could be related, but I'm not sure yet. Problem is that I don't have a mac, so I cannot reproduce it easily.

In order to narrow the problem down, please follow these steps:

rytmisk commented 1 month ago

Sure I did. Is starts up and an error window pops up saying: "Traceback (most recent call last): File "qualcoder/ai_async_worker.py", line 117, in run

File "qualcoder/ai_vectorstore.py", line 303, in _open_db

File "langchain_core/_api/deprecation.py", line 203, in warn_if_direct_instance

File "langchain_community/embeddings/huggingface.py", line 74, in init

ImportError: Could not import sentence_transformers python package. Please install it with pip install sentence-transformers

When asking the new general chat anything, I get a pop up saying «The AI is not yet fully loaded. Please wait and retry»

The last line in the Action Log is «AI: Starting up…»

All the best! Ketil

  1. okt. 2024 kl. 11:48 skrev kaixxx @.***>:

This is strange. It seems that we have multiple issues here. They could be related, but I'm not sure yet. Problem is that I don't have a mac, so I cannot reproduce it easily.

In order to narrow the problem down, please follow these steps:

Close QualCoder, open it again and wait for a minute so that everything can start up in the background. Please report any error messages that you get during this process. Got to the AI Chat window, click on "New > New general chat" and ask the AI anything (e.g. "Make me a pizza!"). Do you get a response? This is to test if the very basic interaction with the AI model is working or not. — Reply to this email directly, view it on GitHub https://github.com/kaixxx/QualCoder/issues/7#issuecomment-2401853173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5GRC53TSRIH6222HIXDG3Z2T3V3AVCNFSM6AAAAABORT4HNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBRHA2TGMJXGM. You are receiving this because you authored the thread.

kaixxx commented 1 month ago

OK, thank you. So the initial error is still there. I was a little confused since you mentioned that the AI chat was working at times. Anyhow, I have now looked deeper into the dmg setup file for mac, and it seems that the sentence-transformers library is indeed missing.

Before asking my friend to recompile the setup file for me, I would like to check that the current code is working. Could you please try running it from source by following the instructions here: https://github.com/kaixxx/QualCoder/blob/ai_integration_rework/README.md#macos Let me know if you need any assistance.

rytmisk commented 1 month ago

Thanks! I tested and it installs fine. It also gives no error message at start. However, I experienced the same "The AI is not fully loaded" -error when attempting to ask a new general chat. But - when I changed to a different AI-engine - everything works as expected. So now every engine works in the locally compiled version. Going back to the DMG installed version - there is still no way to get passed teh "The AI is not fully loaded" error

kaixxx commented 1 month ago

Nice to hear that the manually installed version works. You'll have to use this until we've compiled a new DMG.

To get around the "The AI is not fully loaded" error, you might just have to wait a little longer. When you start QualCoder, several heavy and large AI-related libraries are loaded in the background. This can take up to a minute. Try waiting until this is finished and the status bar at the bottom of the app says "AI: ready". This process should be exactly the same no matter if you use Blablador or OpenAI. If you switch to a different model, the "AI: Starting" message is also shown, but only briefly since all the necessary libraries are already in memory.

rytmisk commented 1 month ago

Thanks! For me this is very good! I might ask how to uninstall at one point though - since that is the great advantage of a package. Ketil

kaixxx commented 1 month ago

Great. Is it now working with Blablador also?

When it comes to uninstalling, just delete the folder with the QualCoder code, that's all. If you used a virtual environment in python during the install, you can delete that too.

rytmisk commented 1 month ago

Thank you! It is working with BlaBlador as well as with ChatGPT. All the best!