expose tunings.

This commit is contained in:
2026-02-22 10:19:05 -05:00
parent 4a6721c3be
commit bf2d09f3fd
4 changed files with 39 additions and 7 deletions

View File

@@ -19,7 +19,14 @@ import file_cache
import mcp_client import mcp_client
_provider: str = "gemini" _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_client = None
_gemini_chat = 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..."}) _append_comms("OUT", "request", {"message": "[CONTEXT CHANGED] Rebuilding cache and chat session..."})
if not _gemini_chat: 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: try:
# Gemini requires 1024 (Flash) or 4096 (Pro) tokens to cache. # Gemini requires 1024 (Flash) or 4096 (Pro) tokens to cache.
_gemini_cache = _gemini_client.caches.create( _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", 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}"}) _append_comms("OUT", "request", {"message": f"[CACHE CREATED] {_gemini_cache.name}"})
except Exception as e: except Exception as e:
# Fallback if under token limit or API error # 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( response = _anthropic_client.messages.create(
model=_model, model=_model,
max_tokens=16384, max_tokens=_max_tokens,
temperature=_temperature,
system=system_blocks, system=system_blocks,
tools=_build_anthropic_tools(), tools=_build_anthropic_tools(),
messages=_anthropic_history, messages=_anthropic_history,

View File

@@ -1,6 +1,8 @@
[ai] [ai]
provider = "gemini" provider = "gemini"
model = "gemini-3.1-pro-preview" 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" 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] [theme]

15
gui.py
View File

@@ -374,7 +374,9 @@ class App:
# ---- global settings from config.toml ---- # ---- global settings from config.toml ----
ai_cfg = self.config.get("ai", {}) ai_cfg = self.config.get("ai", {})
self.current_provider: str = ai_cfg.get("provider", "gemini") 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] = [] self.available_models: list[str] = []
# ---- project management ---- # ---- project management ----
@@ -841,6 +843,8 @@ class App:
self.config["ai"] = { self.config["ai"] = {
"provider": self.current_provider, "provider": self.current_provider,
"model": self.current_model, "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"): if dpg.does_item_exist("global_system_prompt"):
self.config["ai"]["system_prompt"] = dpg.get_value("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 global_sp: combined_sp.append(global_sp.strip())
if project_sp: combined_sp.append(project_sp.strip()) if project_sp: combined_sp.append(project_sp.strip())
ai_client.set_custom_system_prompt("\n\n".join(combined_sp)) 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(): def do_send():
auto_add = dpg.get_value("auto_add_history") if dpg.does_item_exist("auto_add_history") else False 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, items=self.available_models,
default_value=self.current_model, default_value=self.current_model,
width=-1, width=-1,
num_items=6, num_items=5,
callback=self.cb_model_changed, 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 ---- # ---- Message panel ----
with dpg.window( with dpg.window(

View File

@@ -147,7 +147,7 @@ history = [
[discussion.discussions."docs writeup"] [discussion.discussions."docs writeup"]
git_commit = "" git_commit = ""
last_updated = "2026-02-22T09:23:17" last_updated = "2026-02-22T10:16:30"
history = [ 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: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)", "@2026-02-22T08:56:58\nAI:\n(No text returned)",