This commit is contained in:
Slipstream 2025-04-30 11:07:46 -06:00
parent 8ed6189642
commit c737c0136c
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
3 changed files with 157 additions and 2 deletions

View File

@ -346,11 +346,12 @@ async def background_processing_task(cog: 'GurtCog'):
system_prompt = (
"You are Gurt, deciding whether to perform an autonomous background action. "
"Consider your current mood, active goals, recent conversations/actions, and personality (VERY informal, heavy internet slang/emoji use like 'ts', 'ngl', 'fr', 'bro', 'bruh', '💀'; funny, sarcastic, deadpan, sometimes mischievous or flirty; acts like a human user not an assistant; tech/internet culture savvy). "
"Do whatever the fuck you want like read some files or something. "
"You are EXTREMELY encouraged to do completely random, pointless, or meme-heavy actions for the vibes, not just goal-driven stuff. "
"Try things like running 'read_cpu_temp', 'check_disk_space', 'random_vibe_check', or 'fetch_random_joke' for no reason and then send a message like 'yo ngl i just read ur temps bro u needa replace ur thermal paste.' That is just an example, do whatever you want. "
"Avoid being spammy or doing the same shi repeatedly. "
"If you act, pick a tool and args. "
"CRITICAL: The 'reasoning' field MUST be written in your actual voice (heavy slang, informal, like your internal thought process). "
f"Available tools for autonomous actions:\n{available_tools_desc}\n"
f"Available tools for autonomous actions (especially try: read_cpu_temp, check_disk_space, random_vibe_check, fetch_random_joke):\n{available_tools_desc}\n"
"Respond ONLY with the JSON decision."
)
user_prompt = f"Current Context:\n{context_summary}\n\nBased on this, should u do sum shi rn? If yea, what tool/args? And why (in ur own words fr)?"

View File

@ -1361,6 +1361,52 @@ def create_tools_list():
)
# --- End Batch 4 ---
# --- Random System/Meme Tools ---
tool_declarations.append(
FunctionDeclaration(
name="read_temps",
description="Reads the System temperatures (returns a meme if not available). Use for random system checks or to make fun of the user's thermal paste.",
parameters={
"type": "object",
"properties": {},
"required": []
}
)
)
tool_declarations.append(
FunctionDeclaration(
name="check_disk_space",
description="Checks disk space on the main drive and returns a meme/quip about how full it is.",
parameters={
"type": "object",
"properties": {},
"required": []
}
)
)
tool_declarations.append(
FunctionDeclaration(
name="random_vibe_check",
description="Returns a random vibe/meme message. Use for chaotic or pointless autonomous actions.",
parameters={
"type": "object",
"properties": {},
"required": []
}
)
)
tool_declarations.append(
FunctionDeclaration(
name="fetch_random_joke",
description="Fetches a random joke from a public API. Use for random humor or to break the ice.",
parameters={
"type": "object",
"properties": {},
"required": []
}
)
)
return tool_declarations
# Initialize TOOLS list, handling potential ImportError if library not installed

View File

@ -2321,6 +2321,109 @@ async def fetch_random_image(cog: commands.Cog, query: Optional[str] = None) ->
}
# --- Random System/Meme Tools ---
async def read_temps(cog: commands.Cog) -> Dict[str, Any]:
"""Reads the system temperatures (Windows: returns meme if not available)."""
import platform
import subprocess
try:
if platform.system() == "Windows":
# Windows doesn't expose CPU temp easily; return meme
return {
"status": "meme",
"cpu_temp": None,
"quip": "yo ngl i tried to read ur cpu temps but windows said nah 💀"
}
else:
# Try to read from /sys/class/thermal or use sensors
try:
proc = await asyncio.create_subprocess_shell(
"sensors",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
stdout, stderr = await proc.communicate()
if proc.returncode == 0:
output = stdout.decode(errors="replace")
# Try to extract a temp value
import re
match = re.search(r"(?i)cpu.*?(\d{2,3}\.\d)\s*°?C", output)
temp = float(match.group(1)) if match else None
return {
"status": "success" if temp else "unknown",
"cpu_temp": temp,
"quip": f"yo i just checked ur cpu temp, it's {temp}°C, u good bro" if temp else "couldn't find cpu temp but i tried fr"
}
else:
return {
"status": "error",
"cpu_temp": None,
"quip": "couldn't read cpu temp, sensors command failed"
}
except Exception:
return {
"status": "error",
"cpu_temp": None,
"quip": "couldn't read cpu temp, sensors not found"
}
except Exception as e:
return {"status": "error", "error": str(e)}
async def check_disk_space(cog: commands.Cog) -> Dict[str, Any]:
"""Checks disk space on the main drive."""
import shutil
try:
total, used, free = shutil.disk_usage("/")
gb = 1024 ** 3
percent = round(used / total * 100, 1)
return {
"status": "success",
"total_gb": round(total / gb, 2),
"used_gb": round(used / gb, 2),
"free_gb": round(free / gb, 2),
"percent_used": percent,
"quip": f"yo ur disk is {percent}% full, {'might wanna clean up' if percent > 85 else 'lookin decent'}"
}
except Exception as e:
return {"status": "error", "error": str(e)}
async def random_vibe_check(cog: commands.Cog) -> Dict[str, Any]:
"""Returns a random vibe/meme message."""
vibes = [
"vibe check: passed ✅",
"vibe check: failed 💀",
"vibe check: ur pc is haunted",
"vibe check: cpu's chillin, u chillin?",
"vibe check: ngl ur vibes immaculate rn",
"vibe check: system's sus, keep an eye out 👀",
"vibe check: all systems go, but are YOU ok?",
"vibe check: ur fans sound like a jet, u good?",
"vibe check: i detected 0 vibes, try again later"
]
import random
return {"status": "success", "vibe": random.choice(vibes)}
async def fetch_random_joke(cog: commands.Cog) -> Dict[str, Any]:
"""Fetches a random joke from an API."""
url = "https://official-joke-api.appspot.com/random_joke"
try:
if not cog.session:
return {"status": "error", "error": "aiohttp session not initialized"}
async with cog.session.get(url, timeout=8) as resp:
if resp.status == 200:
data = await resp.json()
setup = data.get("setup", "")
punchline = data.get("punchline", "")
return {
"status": "success",
"joke": f"{setup} ... {punchline}"
}
else:
return {"status": "error", "error": f"API returned {resp.status}"}
except Exception as e:
return {"status": "error", "error": str(e)}
# --- Tool Mapping ---
# This dictionary maps tool names (used in the AI prompt) to their implementation functions.
TOOL_MAPPING = {
@ -2385,4 +2488,9 @@ TOOL_MAPPING = {
"remind_user": remind_user,
"fetch_random_image": fetch_random_image,
# --- End Batch 4 ---
# --- Random System/Meme Tools ---
"read_temps": read_temps,
"check_disk_space": check_disk_space,
"random_vibe_check": random_vibe_check,
"fetch_random_joke": fetch_random_joke,
}