momegas / megabots

🤖 State-of-the-art, production ready LLM apps made mega-easy, so you don't have to build them from scratch 🤯 Create a bot, now 🫵
MIT License
347 stars 35 forks source link

Import error #1

Closed SAI-sentinal-ai closed 1 year ago

SAI-sentinal-ai commented 1 year ago

Hi, upon import:

from qnabot.QnABot import QnABot

I receive the error:

import os, sys
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xxxxxx/miniforge3/lib/python3.9/site-packages/qnabot/__init__.py", line 1, in <module>
    from .QnABot import QnABot
  File "/Users/xxxxxx/miniforge3/lib/python3.9/site-packages/qnabot/QnABot.py", line 12, in <module>
    class QnABot:
  File "/Users/xxxxxx/miniforge3/lib/python3.9/site-packages/qnabot/QnABot.py", line 16, in QnABot
    index: str | None = None,
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

I am on an M1 Mac if that makes a difference.

momegas commented 1 year ago

I'll have a look

momegas commented 1 year ago

Can you provide the code you used and got this error?

SAI-sentinal-ai commented 1 year ago
from qnabot.QnABot import QnABot
import os, sys

os.environ["OPENAI_API_KEY"] = "sk-xyz"

bot = QnABot(directory="./files")

bot.print_answer("what was the first roster of angers in comics?")
bot.print_answer("Who is Vision?")

saved as example.py

momegas commented 1 year ago

Its possible that you are using an older python. Can you try using python 3.10?

SAI-sentinal-ai commented 1 year ago

That was it. Also, strangely I had to modify the __init__.py in the site-packages/qnabot directory, from from QnABot import QnABot to from .QnABot import QnABot, i.e., add the period ".". Thanks for the effort! Does the input data need to be in a single text file? what happens when it exceeds, say, 8k tokens?

momegas commented 1 year ago

Good catch. I'll change the docs thing as well. It's still early dev and i've only spent 2 afternoons on it, sorry 😅

Thats a good question. the docs are divided when the FAISS index is created. You can see this here.

Im closing this issuea as this is fixed. Ill also add in the notes the supported python versions so that people don't have this problem. I'll also open the discussions at some point for questions.

Ping me if you need something else. Thank you 🤝