Skip to content

Commit

Permalink
add: @sync_compatible for @ai_powered async use case
Browse files Browse the repository at this point in the history
  • Loading branch information
luochen1990 committed Aug 10, 2024
1 parent c537e7a commit 4818bc2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ai_powered/decorators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
from functools import wraps
from typing import Any, Awaitable, Callable, Generic, overload
from easy_sync import sync_compatible
import openai
from typing_extensions import ParamSpec, TypeVar
import json
Expand Down Expand Up @@ -106,6 +107,7 @@ def wrapper_fn(*args: P.args, **kwargs: P.kwargs) -> R:
return returned_result.result #type: ignore

@wraps(fn)
@sync_compatible
async def wrapper_fn_async(*args: P.args, **kwargs: P.kwargs) -> R:
real_arg = sig.bind(*args, **kwargs)
real_arg_str = msgspec.json.encode(real_arg.arguments).decode('utf-8')
Expand Down

0 comments on commit 4818bc2

Please sign in to comment.