mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-14 17:52:36 +00:00
fix
This commit is contained in:
parent
4e512aec8a
commit
2bb8055646
2 changed files with 0 additions and 65 deletions
|
|
@ -80,31 +80,6 @@ def setup_inference_recording():
|
|||
return inference_recording(mode=mode, storage_dir=storage_dir)
|
||||
|
||||
|
||||
def _normalize_tool_call_ids(obj: Any, request_hash: str, counter: dict[str, int]) -> Any:
|
||||
"""Recursively normalize tool call IDs in an object structure."""
|
||||
if isinstance(obj, dict):
|
||||
# Normalize tool_calls array
|
||||
if "tool_calls" in obj and isinstance(obj["tool_calls"], list):
|
||||
for tool_call in obj["tool_calls"]:
|
||||
if isinstance(tool_call, dict) and "id" in tool_call:
|
||||
# Generate deterministic tool call ID
|
||||
tool_call["id"] = f"toolcall-{request_hash[:8]}-{counter['count']}"
|
||||
counter["count"] += 1
|
||||
# Recurse into nested structures
|
||||
_normalize_tool_call_ids(tool_call, request_hash, counter)
|
||||
|
||||
# Recurse into all dict values
|
||||
for key, value in obj.items():
|
||||
if key != "tool_calls": # Already handled above
|
||||
obj[key] = _normalize_tool_call_ids(value, request_hash, counter)
|
||||
|
||||
elif isinstance(obj, list):
|
||||
# Recurse into list items
|
||||
return [_normalize_tool_call_ids(item, request_hash, counter) for item in obj]
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
def _normalize_response_data(data: dict[str, Any], request_hash: str) -> dict[str, Any]:
|
||||
"""Normalize fields that change between recordings but don't affect functionality.
|
||||
|
||||
|
|
@ -134,10 +109,6 @@ def _normalize_response_data(data: dict[str, Any], request_hash: str) -> dict[st
|
|||
if "eval_duration" in data and data["eval_duration"] is not None:
|
||||
data["eval_duration"] = 0
|
||||
|
||||
# Normalize tool call IDs in delta/choices (for streaming responses)
|
||||
counter = {"count": 0}
|
||||
_normalize_tool_call_ids(data, request_hash, counter)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue