gemini "fixes"

This commit is contained in:
2026-02-22 11:32:54 -05:00
parent 4755f4b590
commit 1b598972fb
3 changed files with 131 additions and 256 deletions

28
gui.py
View File

@@ -121,10 +121,19 @@ def _add_kv_row(parent: str, key: str, val, val_color=None):
def _render_usage(parent: str, usage: dict):
"""Render Anthropic usage dict as a compact token table."""
"""Render Anthropic usage dict as a compact token table, with true totals."""
if not usage:
return
dpg.add_text("usage:", color=_SUBHDR_COLOR, parent=parent)
cache_read = usage.get("cache_read_input_tokens", 0)
cache_create = usage.get("cache_creation_input_tokens", 0)
raw_input = usage.get("input_tokens", 0)
total_in = cache_read + cache_create + raw_input
if total_in > raw_input:
_add_kv_row(parent, " total_input_tokens", total_in, _NUM_COLOR)
order = [
"input_tokens",
"cache_read_input_tokens",
@@ -855,7 +864,7 @@ class App:
}
theme.save_to_config(self.config)
def _do_generate(self) -> tuple[str, Path, list]:
def _do_generate(self) -> tuple[str, str, Path, list]:
self._flush_to_project()
self._save_active_project()
self._flush_to_config()
@@ -1110,8 +1119,9 @@ class App:
def cb_md_only(self):
try:
md, path, _file_items = self._do_generate()
self.last_md = md
s_md, d_md, path, _file_items = self._do_generate()
self.last_static_md = s_md
self.last_dynamic_md = d_md
self.last_md_path = path
self._update_status(f"md written: {path.name}")
except Exception as e:
@@ -1134,8 +1144,9 @@ class App:
if self.send_thread and self.send_thread.is_alive():
return
try:
md, path, file_items = self._do_generate()
self.last_md = md
s_md, d_md, path, file_items = self._do_generate()
self.last_static_md = s_md
self.last_dynamic_md = d_md
self.last_md_path = path
self.last_file_items = file_items
except Exception as e:
@@ -1152,6 +1163,7 @@ class App:
if global_sp: combined_sp.append(global_sp.strip())
if project_sp: combined_sp.append(project_sp.strip())
ai_client.set_custom_system_prompt("\n\n".join(combined_sp))
temp = dpg.get_value("ai_temperature") if dpg.does_item_exist("ai_temperature") else 0.0
max_tok = dpg.get_value("ai_max_tokens") if dpg.does_item_exist("ai_max_tokens") else 8192
trunc = dpg.get_value("ai_history_trunc") if dpg.does_item_exist("ai_history_trunc") else 8000
@@ -1162,7 +1174,7 @@ class App:
if auto_add:
self._queue_history_add("User", user_msg)
try:
response = ai_client.send(self.last_md, user_msg, base_dir, self.last_file_items)
response = ai_client.send(getattr(self, "last_static_md", ""), getattr(self, "last_dynamic_md", ""), user_msg, base_dir, self.last_file_items)
self._update_response(response)
self._update_status("done")
self._trigger_blink = True
@@ -2119,4 +2131,4 @@ def main():
if __name__ == "__main__":
main()
main()