Private
Public Access
refactor(schemas): remove NormalizedResponse backward-compat __init__; use canonical API
This commit is contained in:
+4
-3
@@ -2025,6 +2025,7 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
|
||||
stream_callback: Optional[Callable[[str], None]] = None,
|
||||
patch_callback: Optional[Callable[[str, str], Optional[str]]] = None) -> Result[str]:
|
||||
from src.openai_compatible import OpenAICompatibleRequest, NormalizedResponse
|
||||
from src.openai_schemas import UsageStats
|
||||
"""
|
||||
[C: src/ai_server.py:_handle_send]
|
||||
Functional Purpose: Sends requests to Gemini via the headless Gemini CLI subprocess adapter.
|
||||
@@ -2051,7 +2052,7 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
|
||||
|
||||
def _send(r_idx: int) -> NormalizedResponse:
|
||||
if adapter is None:
|
||||
return NormalizedResponse(text="(adapter unavailable)", tool_calls=[], usage_input_tokens=0, usage_output_tokens=0, usage_cache_read_tokens=0, usage_cache_creation_tokens=0, raw_response=None)
|
||||
return NormalizedResponse(text="(adapter unavailable)", tool_calls=[], usage=UsageStats(input_tokens=0, output_tokens=0, cache_read_tokens=0, cache_creation_tokens=0), raw_response=None)
|
||||
send_result = _send_cli_round_result(r_idx, adapter, payload, safety_settings, sys_instr, stream_callback)
|
||||
if not send_result.ok:
|
||||
raise cast(Exception, send_result.errors[0].original) from None
|
||||
@@ -2085,7 +2086,7 @@ def _send_gemini_cli(md_content: str, user_message: str, base_dir: str,
|
||||
"kind": "history_add",
|
||||
"payload": {"role": "AI", "content": txt}
|
||||
})
|
||||
return NormalizedResponse(text=txt, tool_calls=calls, usage_input_tokens=usage.get("prompt_tokens", 0), usage_output_tokens=usage.get("completion_tokens", 0), usage_cache_read_tokens=0, usage_cache_creation_tokens=0, raw_response=resp_data)
|
||||
return NormalizedResponse(text=txt, tool_calls=calls, usage=UsageStats(input_tokens=usage.get("prompt_tokens", 0), output_tokens=usage.get("completion_tokens", 0), cache_read_tokens=0, cache_creation_tokens=0), raw_response=resp_data)
|
||||
|
||||
def _pre_dispatch(r_idx: int, calls: list[Metadata]) -> list[Metadata]:
|
||||
nonlocal payload, cumulative_tool_bytes, file_items
|
||||
@@ -2569,7 +2570,7 @@ def _send_grok(md_content: str, user_message: str, base_dir: str,
|
||||
Runs synchronously in the caller thread; synchronizes Grok history using _grok_history_lock.
|
||||
"""
|
||||
from src.openai_compatible import OpenAICompatibleRequest, _classify_openai_compatible_error
|
||||
from src.openai_schemas import ChatMessage
|
||||
from src.openai_schemas import ChatMessage, UsageStats
|
||||
try:
|
||||
client = _ensure_grok_client()
|
||||
tools: list[Metadata] | None = _get_deepseek_tools() or None
|
||||
|
||||
Reference in New Issue
Block a user