Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/openlayer/lib/tracing/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ def decorator(func):
step_kwargs["name"] = func.__name__
step_name = step_kwargs["name"]

_raw_step_type = step_kwargs.get("step_type", enums.StepType.USER_CALL)
if isinstance(_raw_step_type, str):
_raw_step_type = enums.StepType(_raw_step_type)
step_type = _raw_step_type
step_kwargs["step_type"] = step_type

# Check if it's a generator function
if inspect.isgeneratorfunction(func):
# For sync generators, use class-based approach to delay trace creation
Expand Down Expand Up @@ -601,7 +607,7 @@ def __next__(self):
self._step, self._is_root_step, self._token = (
_create_and_initialize_step(
step_name=step_name,
step_type=enums.StepType.USER_CALL,
step_type=step_type,
inputs=None,
output=None,
metadata=None,
Expand Down Expand Up @@ -847,6 +853,12 @@ def decorator(func):
step_kwargs["name"] = func.__name__
step_name = step_kwargs["name"]

_raw_step_type = step_kwargs.get("step_type", enums.StepType.USER_CALL)
if isinstance(_raw_step_type, str):
_raw_step_type = enums.StepType(_raw_step_type)
step_type = _raw_step_type
step_kwargs["step_type"] = step_type

if asyncio.iscoroutinefunction(func) or inspect.isasyncgenfunction(func):
# Check if it's specifically an async generator function
if inspect.isasyncgenfunction(func):
Expand All @@ -873,7 +885,7 @@ async def __anext__(self):
self._step, self._is_root_step, self._token = (
_create_and_initialize_step(
step_name=step_name,
step_type=enums.StepType.USER_CALL,
step_type=step_type,
inputs=None,
output=None,
metadata=None,
Expand Down Expand Up @@ -1772,6 +1784,9 @@ def _process_wrapper_inputs_and_outputs(
context_kwarg=context_kwarg,
question_kwarg=question_kwarg,
)
if isinstance(step, steps.ToolStep):
step.function_name = step.name
step.arguments = inputs
_finalize_step_logging(
step=step,
inputs=inputs,
Expand Down