dspy icon indicating copy to clipboard operation
dspy copied to clipboard

[OpenAI] Using OpenAI > 1 fails due to import errors

Open mikeldking opened this issue 1 year ago • 3 comments

The main readme states that you should be able to use OpenAI > 1 in conjunction with DSPy but there's dirct access to .errors which no longer exists:

) /usr/bin/env /Users/mikeldking/.virtualenvs/phoenix/bin/python /Users/mikeldking/.vscode
/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugp
y/launcher 56834 -- /Users/mikeldking/work/openinference/python/instrumentation/openinfere
nce-instrumentation-dspy/examples/dspy_rag.py 
Traceback (most recent call last):
  File "/Users/mikeldking/.pyenv/versions/3.10.3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/mikeldking/.pyenv/versions/3.10.3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/mikeldking/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/Users/mikeldking/work/openinference/python/instrumentation/openinference-instrumentation-dspy/examples/dspy_rag.py", line 1, in <module>
    import dspy
  File "/Users/mikeldking/.virtualenvs/phoenix/lib/python3.10/site-packages/dspy/__init__.py", line 1, in <module>
    from dsp.modules.hf_client import ChatModuleClient
  File "/Users/mikeldking/.virtualenvs/phoenix/lib/python3.10/site-packages/dsp/__init__.py", line 1, in <module>
    from .modules import *
  File "/Users/mikeldking/.virtualenvs/phoenix/lib/python3.10/site-packages/dsp/modules/__init__.py", line 2, in <module>
    from .gpt3 import *
  File "/Users/mikeldking/.virtualenvs/phoenix/lib/python3.10/site-packages/dsp/modules/gpt3.py", line 7, in <module>
    import openai.error
ModuleNotFoundError: No module named 'openai.error'

Happy to open a PR to remove this error.

mikeldking avatar Jan 23 '24 19:01 mikeldking

Hmm are you perhaps using an old version of dspy?

okhat avatar Jan 24 '24 00:01 okhat

Hmm are you perhaps using an old version of dspy?

I'll try to repo in a clean environment. Will PR with a possible fix if I figure it out!

mikeldking avatar Jan 24 '24 02:01 mikeldking

Basically that line is not there on main now at least. I think it's also not pypi latest

okhat avatar Jan 26 '24 13:01 okhat

I assume this was an old version of DSPy but happy to reopen if not

okhat avatar Feb 03 '24 18:02 okhat