Skip to content

Commit fef0b4a

Browse files
badbyehassiebp
andauthored
fix(openai): add check for tool_call length
fix openai.py: when `tool_call` is a empty list, it raise an `list index out of range` error Co-authored-by: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com>
1 parent 8bd1533 commit fef0b4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

langfuse/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def _extract_streamed_openai_response(resource: Any, chunks: Any) -> Any:
570570
)
571571
curr["arguments"] += getattr(tool_call_chunk, "arguments", "")
572572

573-
elif delta.get("tool_calls", None) is not None:
573+
elif delta.get("tool_calls", None) is not None and len(delta.get("tool_calls")) > 0:
574574
curr = completion["tool_calls"]
575575
tool_call_chunk = getattr(
576576
delta.get("tool_calls", None)[0], "function", None

0 commit comments

Comments
 (0)