Skip to content

Commit

Permalink
Handle HttpxBinaryResponseContent import flexibly for better compatib…
Browse files Browse the repository at this point in the history
…ility
  • Loading branch information
aaclause committed Apr 1, 2024
1 parent b8efc9f commit 122862b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/globalPlugins/openai/maindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

sys.path.insert(0, LIBS_DIR_PY)
import openai
try:
from openai._legacy_response import HttpxBinaryResponseContent as ClassyHttpxBinary
except ImportError:
from openai._base_client import HttpxBinaryResponseContent as ClassyHttpxBinary
import markdown2
sys.path.remove(LIBS_DIR_PY)

Expand Down Expand Up @@ -1225,7 +1229,7 @@ def OnResult(self, event):
)
return

if isinstance(event.data, openai._base_client.HttpxBinaryResponseContent):
if isinstance(event.data, ClassyHttpxBinary):
if os.path.exists(TTS_FILE_NAME):
os.startfile(TTS_FILE_NAME)
return
Expand Down

0 comments on commit 122862b

Please sign in to comment.