diff --git a/ai_client.py b/ai_client.py index 308eeea..509ee7c 100644 --- a/ai_client.py +++ b/ai_client.py @@ -19,7 +19,14 @@ import file_cache import mcp_client _provider: str = "gemini" -_model: str = "gemini-2.0-flash" +_model: str = "gemini-2.5-flash" +_temperature: float = 0.0 +_max_tokens: int = 8192 + +def set_model_params(temp: float, max_tok: int): + global _temperature, _max_tokens + _temperature = temp + _max_tokens = max_tok _gemini_client = None _gemini_chat = None @@ -445,7 +452,13 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, file_items: _append_comms("OUT", "request", {"message": "[CONTEXT CHANGED] Rebuilding cache and chat session..."}) if not _gemini_chat: - chat_config = types.GenerateContentConfig(system_instruction=sys_instr, tools=tools_decl) + chat_config = types.GenerateContentConfig( + system_instruction=sys_instr, + tools=tools_decl, + temperature=_temperature, + max_output_tokens=_max_tokens, + safety_settings=[types.SafetySetting(category="HARM_CATEGORY_DANGEROUS_CONTENT", threshold="BLOCK_ONLY_HIGH")] + ) try: # Gemini requires 1024 (Flash) or 4096 (Pro) tokens to cache. _gemini_cache = _gemini_client.caches.create( @@ -456,7 +469,12 @@ def _send_gemini(md_content: str, user_message: str, base_dir: str, file_items: ttl="3600s", ) ) - chat_config = types.GenerateContentConfig(cached_content=_gemini_cache.name) + chat_config = types.GenerateContentConfig( + cached_content=_gemini_cache.name, + temperature=_temperature, + max_output_tokens=_max_tokens, + safety_settings=[types.SafetySetting(category="HARM_CATEGORY_DANGEROUS_CONTENT", threshold="BLOCK_ONLY_HIGH")] + ) _append_comms("OUT", "request", {"message": f"[CACHE CREATED] {_gemini_cache.name}"}) except Exception as e: # Fallback if under token limit or API error @@ -771,7 +789,8 @@ def _send_anthropic(md_content: str, user_message: str, base_dir: str, file_item response = _anthropic_client.messages.create( model=_model, - max_tokens=16384, + max_tokens=_max_tokens, + temperature=_temperature, system=system_blocks, tools=_build_anthropic_tools(), messages=_anthropic_history, diff --git a/config.toml b/config.toml index 7b3b0d1..37c1d7c 100644 --- a/config.toml +++ b/config.toml @@ -1,6 +1,8 @@ [ai] provider = "gemini" model = "gemini-3.1-pro-preview" +temperature = 0.6000000238418579 +max_tokens = 12000 system_prompt = "DO NOT EVER make a shell script unless told to. DO NOT EVER make a readme or a file describing your changes unless your are told to. If you have commands I should be entering into the command line or if you have something to explain to me, please just use code blocks or normal text output. DO NOT DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TODO. DO NOT EVER, EVER DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TO DO. IF YOU WANT TO DO OTHER THINGS, SIMPLY SUGGEST THEM, AND THEN I WILL REVIEW YOUR CHANGES, AND MAKE THE DECISION ON HOW TO PROCEED. WHEN WRITING SCRIPTS USE A 120-160 character limit per line. I don't want to see scrunched code.\n" [theme] diff --git a/gui.py b/gui.py index 9c23b47..4da3671 100644 --- a/gui.py +++ b/gui.py @@ -374,7 +374,9 @@ class App: # ---- global settings from config.toml ---- ai_cfg = self.config.get("ai", {}) self.current_provider: str = ai_cfg.get("provider", "gemini") - self.current_model: str = ai_cfg.get("model", "gemini-2.0-flash") + self.current_model: str = ai_cfg.get("model", "gemini-2.5-flash") + self.temperature: float = ai_cfg.get("temperature", 0.0) + self.max_tokens: int = ai_cfg.get("max_tokens", 8192) self.available_models: list[str] = [] # ---- project management ---- @@ -841,6 +843,8 @@ class App: self.config["ai"] = { "provider": self.current_provider, "model": self.current_model, + "temperature": dpg.get_value("ai_temperature") if dpg.does_item_exist("ai_temperature") else self.temperature, + "max_tokens": dpg.get_value("ai_max_tokens") if dpg.does_item_exist("ai_max_tokens") else self.max_tokens, } if dpg.does_item_exist("global_system_prompt"): self.config["ai"]["system_prompt"] = dpg.get_value("global_system_prompt") @@ -1147,6 +1151,9 @@ 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 + ai_client.set_model_params(temp, max_tok) def do_send(): auto_add = dpg.get_value("auto_add_history") if dpg.does_item_exist("auto_add_history") else False @@ -1771,9 +1778,13 @@ class App: items=self.available_models, default_value=self.current_model, width=-1, - num_items=6, + num_items=5, callback=self.cb_model_changed, ) + dpg.add_separator() + dpg.add_text("Parameters") + dpg.add_input_float(tag="ai_temperature", label="Temperature", default_value=self.temperature, min_value=0.0, max_value=2.0) + dpg.add_input_int(tag="ai_max_tokens", label="Max Tokens (Output)", default_value=self.max_tokens, step=1024) # ---- Message panel ---- with dpg.window( diff --git a/manual_slop.toml b/manual_slop.toml index 73ab024..87f8746 100644 --- a/manual_slop.toml +++ b/manual_slop.toml @@ -147,7 +147,7 @@ history = [ [discussion.discussions."docs writeup"] git_commit = "" -last_updated = "2026-02-22T09:23:17" +last_updated = "2026-02-22T10:16:30" history = [ "@2026-02-22T08:56:39\nUser:\nLets write extensive documentation in the same style that I used for my VEFontCache-Oodin project.\nI added it's directories to your context.", "@2026-02-22T08:56:58\nAI:\n(No text returned)",