Skip to content

Commit

Permalink
correcting tracing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sethjuarez committed Sep 10, 2024
2 parents 1ad4cff + d934bb3 commit 257ac74
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions runtime/prompty/prompty/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _results(result: Any) -> dict:


def _trace_sync(
func: Callable = None, *, description: str = None, type: str = None
func: Callable = None, *, description: str = None, itemtype: str = None
) -> Callable:
description = description or ""

Expand All @@ -124,8 +124,8 @@ def wrapper(*args, **kwargs):
if description and description != "":
trace("description", description)

if type and type != "":
trace("type", type)
if itemtype and itemtype != "":
trace("type", itemtype)

inputs = _inputs(func, args, kwargs)
trace("inputs", inputs)
Expand Down Expand Up @@ -153,7 +153,7 @@ def wrapper(*args, **kwargs):


def _trace_async(
func: Callable = None, *, description: str = None, type: str = None
func: Callable = None, *, description: str = None, itemtype: str = None
) -> Callable:
description = description or ""

Expand All @@ -165,8 +165,8 @@ async def wrapper(*args, **kwargs):
if description and description != "":
trace("description", description)

if type and type != "":
trace("type", type)
if itemtype and itemtype != "":
trace("type", itemtype)

inputs = _inputs(func, args, kwargs)
trace("inputs", inputs)
Expand All @@ -193,14 +193,14 @@ async def wrapper(*args, **kwargs):


def trace(
func: Callable = None, *, description: str = None, type: str = None
func: Callable = None, *, description: str = None, itemtype: str = None
) -> Callable:
if func is None:
return partial(trace, description=description, type=type)
return partial(trace, description=description, itemtype=itemtype)

wrapped_method = _trace_async if inspect.iscoroutinefunction(func) else _trace_sync

return wrapped_method(func, description=description, type=type)
return wrapped_method(func, description=description, itemtype=itemtype)


class PromptyTracer:
Expand Down

0 comments on commit 257ac74

Please sign in to comment.