ericmjl / llamabot

Pythonic class-based interface to LLMs
https://ericmjl.github.io/llamabot/
112 stars 19 forks source link

Import error #3

Closed wusixer closed 1 year ago

wusixer commented 1 year ago

Dear @ericmjl, I have tried installing llamabot separately through pip install llamabot and through pyproject.toml by cloning the repository. In both scenarios, I wasn't able to import the bots correctly. The error message is as following:

Python 3.9.7 (default, Sep 16 2021, 08:50:36)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from llamabot import SimpleBot
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/coxji1/Documents/llamabot/git_repo/llamabot/llamabot/__init__.py", line 12, in <module>
    from .bot import ChatBot, QueryBot, SimpleBot
  File "/Users/coxji1/Documents/llamabot/git_repo/llamabot/llamabot/bot/__init__.py", line 13, in <module>
    from .querybot import QueryBot
  File "/Users/coxji1/Documents/llamabot/git_repo/llamabot/llamabot/bot/querybot.py", line 32, in <module>
    class QueryBot:
  File "/Users/coxji1/Documents/llamabot/git_repo/llamabot/llamabot/bot/querybot.py", line 40, in QueryBot
    doc_paths: List[str] | List[Path] | str | Path = None,
TypeError: unsupported operand type(s) for |: '_GenericAlias' and '_GenericAlias'

I wasn't able to find _GenericAlias therefore I don't know how to debug it. Could you please help me?

Thanks! Jiayi :)

ericmjl commented 1 year ago

Hey @wusixer!

I think this one is solvable by using Python=3.10. Could you try that?

I'll also update pyproject.toml to reflect that Python 3.10 is the minimum version required.

Specifically, the | syntax here for indicating the union of four possible types is the reason for the failure. That was, I think, introduced in py310.

wusixer commented 1 year ago

Hi @ericmjl , it worked after I switched to 3.10, thanks!. However, I ran into another error when running the tutorial feynman("Enzyme function annotation..."),

openai.error.InvalidRequestError: The model: `gpt-4-32k` does not exist

I checked the available models using

import openai
import pprint

openai.api_key = "MYSECRETKEYBLAHBLAHBLAH"

GPT4 = 'gpt-4-32k'
MODEL_NAME = GPT4
model = openai.Model(MODEL_NAME)

def list_all_models():
    model_list = openai.Model.list()['data']
    model_ids = [x['id'] for x in model_list]
    model_ids.sort()
    pprint.pprint(model_ids)

list_all_models()

I don't see gpt-4-32k in the list, I have this list returned instead:

['ada',
 'ada-code-search-code',
 'ada-code-search-text',
 'ada-search-document',
 'ada-search-query',
 'ada-similarity',
 'babbage',
 'babbage-code-search-code',
 'babbage-code-search-text',
 'babbage-search-document',
 'babbage-search-query',
 'babbage-similarity',
 'code-davinci-edit-001',
 'code-search-ada-code-001',
 'code-search-ada-text-001',
 'code-search-babbage-code-001',
 'code-search-babbage-text-001',
 'curie',
 'curie-instruct-beta',
 'curie-search-document',
 'curie-search-query',
 'curie-similarity',
 'davinci',
 'davinci-instruct-beta',
 'davinci-search-document',
 'davinci-search-query',
 'davinci-similarity',
 'gpt-3.5-turbo',
 'gpt-3.5-turbo-0301',
 'gpt-3.5-turbo-0613',
 'gpt-3.5-turbo-16k',
 'gpt-3.5-turbo-16k-0613',
 'gpt-4',
 'gpt-4-0314',
 'gpt-4-0613',
 'text-ada-001',
 'text-babbage-001',
 'text-curie-001',
 'text-davinci-001',
 'text-davinci-002',
 'text-davinci-003',
 'text-davinci-edit-001',
 'text-embedding-ada-002',
 'text-search-ada-doc-001',
 'text-search-ada-query-001',
 'text-search-babbage-doc-001',
 'text-search-babbage-query-001',
 'text-search-curie-doc-001',
 'text-search-curie-query-001',
 'text-search-davinci-doc-001',
 'text-search-davinci-query-001',
 'text-similarity-ada-001',
 'text-similarity-babbage-001',
 'text-similarity-curie-001',
 'text-similarity-davinci-001',
 'whisper-1']
wusixer commented 1 year ago

the import issue was solved here

ericmjl commented 1 year ago

@wusixer I released llamabot v0.0.64 -- it now comes with a configuration for the default model to use. Please see the tutorial here: https://ericmjl.github.io/llamabot/cli/llamabot/