mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-04-28 03:20:01 +00:00
Major refactor: API, providers, messaging, and Anthropic protocol
Some checks are pending
CI / checks (push) Waiting to run
Some checks are pending
CI / checks (push) Waiting to run
Consolidates the incremental refactor work into a single change set: modular web tools (api/web_tools), native Anthropic request building and SSE block policy, OpenAI conversion and error handling, provider transports and rate limiting, messaging handler and tree queue, safe logging, smoke tests, and broad test coverage.
This commit is contained in:
parent
b9ed704095
commit
f3a7528d49
139 changed files with 7460 additions and 2422 deletions
48
api/validation_log.py
Normal file
48
api/validation_log.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"""Safe metadata summaries for HTTP 422 validation logging (no raw text content)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def summarize_request_validation_body(
|
||||
body: Any,
|
||||
) -> tuple[list[dict[str, Any]], list[str]]:
|
||||
"""Return message shape summary and tool name list for debug logs."""
|
||||
messages = body.get("messages") if isinstance(body, dict) else None
|
||||
message_summary: list[dict[str, Any]] = []
|
||||
if isinstance(messages, list):
|
||||
for msg in messages:
|
||||
if not isinstance(msg, dict):
|
||||
message_summary.append({"message_kind": type(msg).__name__})
|
||||
continue
|
||||
content = msg.get("content")
|
||||
item: dict[str, Any] = {
|
||||
"role": msg.get("role"),
|
||||
"content_kind": type(content).__name__,
|
||||
}
|
||||
if isinstance(content, list):
|
||||
item["block_types"] = [
|
||||
block.get("type", "dict")
|
||||
if isinstance(block, dict)
|
||||
else type(block).__name__
|
||||
for block in content[:12]
|
||||
]
|
||||
item["block_keys"] = [
|
||||
sorted(str(key) for key in block)[:12]
|
||||
for block in content[:5]
|
||||
if isinstance(block, dict)
|
||||
]
|
||||
elif isinstance(content, str):
|
||||
item["content_length"] = len(content)
|
||||
message_summary.append(item)
|
||||
|
||||
tool_names: list[str] = []
|
||||
if isinstance(body, dict) and isinstance(body.get("tools"), list):
|
||||
tool_names = [
|
||||
str(tool.get("name", ""))
|
||||
for tool in body["tools"]
|
||||
if isinstance(tool, dict)
|
||||
]
|
||||
|
||||
return message_summary, tool_names
|
||||
Loading…
Add table
Add a link
Reference in a new issue