Skip to content

Commit 09ad352

Browse files
feat: patch openai v0 APIs too
1 parent f31d4ed commit 09ad352

File tree

1 file changed

+12
-5
lines changed
  • src/promplate_pyodide/utils/openai

1 file changed

+12
-5
lines changed
+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
# type: ignore
2+
13
from ..sync import to_sync
24

35

46
def patch_sync_apis():
5-
from promplate.llm import openai as o
7+
from promplate.llm.openai import v0, v1
8+
9+
v1.SyncTextOpenAI.complete = v1.TextComplete.__call__ = to_sync(v1.AsyncTextComplete.__call__)
10+
v1.SyncTextOpenAI.generate = v1.TextGenerate.__call__ = to_sync(v1.AsyncTextGenerate.__call__)
11+
v1.SyncChatOpenAI.complete = v1.ChatComplete.__call__ = to_sync(v1.AsyncChatComplete.__call__)
12+
v1.SyncChatOpenAI.generate = v1.ChatGenerate.__call__ = to_sync(v1.AsyncChatGenerate.__call__)
613

7-
o.SyncTextOpenAI.complete = o.TextComplete.__call__ = to_sync(o.AsyncTextComplete.__call__) # type: ignore
8-
o.SyncTextOpenAI.generate = o.TextGenerate.__call__ = to_sync(o.AsyncTextGenerate.__call__) # type: ignore
9-
o.SyncChatOpenAI.complete = o.ChatComplete.__call__ = to_sync(o.AsyncChatComplete.__call__) # type: ignore
10-
o.SyncChatOpenAI.generate = o.ChatGenerate.__call__ = to_sync(o.AsyncChatGenerate.__call__) # type: ignore
14+
v0.TextComplete.__call__ = to_sync(v0.AsyncTextComplete.__call__)
15+
v0.TextGenerate.__call__ = to_sync(v0.AsyncTextGenerate.__call__)
16+
v0.ChatComplete.__call__ = to_sync(v0.AsyncChatComplete.__call__)
17+
v0.ChatGenerate.__call__ = to_sync(v0.AsyncChatGenerate.__call__)

0 commit comments

Comments
 (0)