diff --git a/project_history.toml b/project_history.toml index bf16d8e..699fd9d 100644 --- a/project_history.toml +++ b/project_history.toml @@ -8,5 +8,5 @@ active = "main" [discussions.main] git_commit = "" -last_updated = "2026-03-05T19:00:38" +last_updated = "2026-03-05T19:13:27" history = [] diff --git a/src/ai_client.py b/src/ai_client.py index 9960eab..89e05bb 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -712,6 +712,7 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, txt = "".join(txt_chunks) # Final validation of response object for subsequent code resp = final_resp + events.emit("response_received", payload={"provider": "gemini", "model": _model, "usage": usage, "round": r_idx}) else: config = types.GenerateContentConfig( tools=[types.Tool(function_declarations=[types.FunctionDeclaration(**s) for s in mcp_client.get_tool_schemas()])] if enable_tools else [], @@ -728,6 +729,7 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, "cache_read_input_tokens": getattr(resp.usage_metadata, "cached_content_token_count", 0) } reason = resp.candidates[0].finish_reason.name if (resp.candidates and hasattr(resp.candidates[0], "finish_reason")) else "STOP" + events.emit("response_received", payload={"provider": "gemini", "model": _model, "usage": usage, "round": r_idx}) _append_comms("IN", "response", {"round": r_idx, "stop_reason": reason, "text": txt, "tool_calls": [{"name": c.name, "args": dict(c.args)} for c in calls], "usage": usage}) total_in = usage.get("input_tokens", 0) diff --git a/tests/test_api_events.py b/tests/test_api_events.py index 9b00d54..d1e1de5 100644 --- a/tests/test_api_events.py +++ b/tests/test_api_events.py @@ -60,7 +60,7 @@ def test_send_emits_events_proper() -> None: ai_client.events.on("request_start", start_callback) ai_client.events.on("response_received", response_callback) ai_client.set_provider("gemini", "gemini-2.5-flash-lite") - ai_client.send("context", "message", stream_callback=lambda x: None) + ai_client.send("context", "message", ) assert start_callback.called assert response_callback.called args, kwargs = start_callback.call_args