pre-commit

This commit is contained in:
Ashwin Bharambe 2025-10-03 16:35:22 -07:00
parent b630988d0d
commit 4e512aec8a
2 changed files with 11 additions and 2 deletions

View file

@ -85,7 +85,7 @@ def _normalize_tool_call_ids(obj: Any, request_hash: str, counter: dict[str, int
if isinstance(obj, dict):
# Normalize tool_calls array
if "tool_calls" in obj and isinstance(obj["tool_calls"], list):
for i, tool_call in enumerate(obj["tool_calls"]):
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']}"
@ -204,7 +204,9 @@ class ResponseStorage:
if "body" in serialized_response:
if isinstance(serialized_response["body"], list):
# Handle streaming responses (list of chunks)
serialized_response["body"] = [_serialize_response(chunk, request_hash) for chunk in serialized_response["body"]]
serialized_response["body"] = [
_serialize_response(chunk, request_hash) for chunk in serialized_response["body"]
]
else:
# Handle single response
serialized_response["body"] = _serialize_response(serialized_response["body"], request_hash)

View file

@ -1,4 +1,10 @@
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the terms described in the LICENSE file in
# the root directory of this source tree.
"""
Utility script to re-normalize existing recording files.
@ -9,6 +15,7 @@ git diffs when recordings are re-recorded.
Usage:
python scripts/normalize_recordings.py [--dry-run]
"""
import argparse
import json
from pathlib import Path