dglazkov / polymath

MIT License
132 stars 9 forks source link

Not able to run the sample code #117

Closed hargup closed 1 year ago

hargup commented 1 year ago

Running sample locally fails with following error, enviornment, python=3.8

command: python -m sample.main "How does building a platform differ from building a product?"

Traceback (most recent call last):
  File "/Users/harshwork/opt/anaconda3/envs/py38/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/harshwork/opt/anaconda3/envs/py38/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/harshwork/code/polymath/sample/main.py", line 7, in <module>
    from polymath import ask
  File "/Users/harshwork/code/polymath/polymath/__init__.py", line 1, in <module>
    from polymath.library import Library, Bit, CURRENT_VERSION, EMBEDDINGS_MODEL_ID
  File "/Users/harshwork/code/polymath/polymath/library.py", line 14, in <module>
    from .access import DEFAULT_PRIVATE_ACCESS_TAG, HOST_CONFIG, permitted_access
  File "/Users/harshwork/code/polymath/polymath/access.py", line 2, in <module>
    from polymath.config.types import HostConfig
  File "/Users/harshwork/code/polymath/polymath/config/types.py", line 5, in <module>
    from polymath.base.dataclasses import config, empty
  File "/Users/harshwork/code/polymath/polymath/base/dataclasses.py", line 51, in <module>
    class ConfigDoc:
  File "/Users/harshwork/code/polymath/polymath/base/dataclasses.py", line 53, in ConfigDoc
    attributes: list[AttrDoc]
TypeError: 'type' object is not subscriptable
dglazkov commented 1 year ago

Oh hi @hargup! Welcome to our little place. So far, we've been using Python 3.10 and I think @dalmaer made it run on 3.11. I am pretty sure there will be bits that break on 3.8.

hargup commented 1 year ago

@dglazkov appreciate the quick response :) Getting a different error with Python 3.10

python -m sample.main "How does building a platform differ from building a product?"
Token indices sequence length is longer than the specified maximum sequence length for this model (18994 > 1024). Running this sequence through the model will result in indexing errors
Traceback (most recent call last):
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/harshwork/code/polymath/sample/main.py", line 22, in <module>
    print(ask(query, context))
  File "/Users/harshwork/code/polymath/polymath/ask_embeddings.py", line 124, in ask
    return get_completion_with_context(query, context, answer_length=answer_length, completion_model=completion_model), library.unique_infos
  File "/Users/harshwork/code/polymath/polymath/ask_embeddings.py", line 111, in get_completion_with_context
    return get_completion(prompt, answer_length=answer_length, completion_model=completion_model)
  File "/Users/harshwork/code/polymath/polymath/ask_embeddings.py", line 95, in get_completion
    response : Any = openai.Completion.create(
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/site-packages/openai/api_resources/completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 115, in create
    response, _, api_key = requestor.request(
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/site-packages/openai/api_requestor.py", line 181, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/site-packages/openai/api_requestor.py", line 396, in _interpret_response
    self._interpret_response_line(
  File "/Users/harshwork/opt/anaconda3/envs/py310/lib/python3.10/site-packages/openai/api_requestor.py", line 429, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: -14994 is less than the minimum of 0 - 'max_tokens'
dglazkov commented 1 year ago

Aha! I was able to reproduce.

dglazkov commented 1 year ago

Oh, man, That was a fun rabbit hole. The problem was stale documentation! It was pointing you to sample.main, which was an older and no longer functional way of invoking polymath. I am updating the docs to use sample.client.

dglazkov commented 1 year ago

Thank you for reporting the bug, @hargup!

hargup commented 1 year ago

@dglazkov thanks for quickly resolving the bug ☺️