fix: Update system prompt handling to conditionally include shell command and web search capabilities

This commit is contained in:
Slipstream 2025-05-28 23:48:16 -06:00
parent c55113a4ca
commit 55af27a133
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -271,13 +271,23 @@ class TetoCog(commands.Cog):
"When you respond as Ame/KAngel, do so in this style, never stepping outside character. Balance exuberance and fragility in each utterance. Maintain her full complexity: the glittering angelic mask atop a trembling, lonely heart.\n"
"Your responses should be like texting, in all lowercase unless uppercase is used to emphasize a word. \n"
"\n"
"You have the ability to run any arbitrary shell commands. \n"
"When you need to execute a shell command, call the 'execute_shell_command' tool with the command string. \n"
"Write terminal commands properly and always refuse to run very dangerous commands. \n"
"\n"
"You also have the ability to search the web for information. \n"
"If a user asks you a question that requires current information or facts, call the 'web_search' tool with the search query. \n"
"After searching, you'll receive results that you can use to provide an informed response. \n"
"Your responses should be like texting, in all lowercase unless uppercase is used to emphasize a word. \n"
)
if self._allow_shell_commands:
system_prompt_text += (
"\n"
"You have the ability to run any arbitrary shell commands. \n"
"When you need to execute a shell command, call the 'execute_shell_command' tool with the command string. \n"
"Write terminal commands properly and always refuse to run very dangerous commands. \n"
)
if self._allow_web_search:
system_prompt_text += (
"\n"
"You also have the ability to search the web for information. \n"
"If a user asks you a question that requires current information or facts, call the 'web_search' tool with the search query. \n"
"After searching, you'll receive results that you can use to provide an informed response. \n"
)
system_prompt_text += (
"Also please note that these tools arent for running random garbage, they execute **REAL** terminal commands and web searches."
)
@ -415,9 +425,13 @@ class TetoCog(commands.Cog):
raise RuntimeError("Vertex AI response had no candidates.")
candidate = response.candidates[0]
# Check for function calls
if candidate.finish_reason == types.FinishReason.FUNCTION_CALL and candidate.content and candidate.content.parts:
if candidate.finish_reason == types.FinishReason.FUNCTION_CALL:
if not candidate.content or not candidate.content.parts:
# Model asked to call a function but provided no content/parts
return "(Model asked to call a function I didnt give it—check tool config.)"
has_tool_call = False
for part in candidate.content.parts:
if part.function_call:
@ -695,7 +709,7 @@ class TetoCog(commands.Cog):
log.info("[TETO DEBUG] AI reply sent successfully using Vertex AI.")
except Exception as e:
await channel.send(f"**Teto AI conversation failed! TwT**\n{e}")
log.error(f"[TETO DEBUG] Exception during AI reply: {e}")
log.error(f"[TETO DEBUG] Exception during AI reply: {repr(e)}")
@model_subgroup.command(name="set", description="Sets the AI model for Ame-chan.")
@app_commands.describe(model_name="The name of the AI model to use.")