dspy
dspy copied to clipboard
[OpenAI] Using OpenAI > 1 fails due to import errors
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.
Hmm are you perhaps using an old version of dspy?
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!
Basically that line is not there on main now at least. I think it's also not pypi latest
I assume this was an old version of DSPy but happy to reopen if not