2025-06-27 11:40:30 +02:00

47 lines
1.9 KiB
Python

import random
from langchain.tools import tool
@tool
def print_poem(poem_type: str = "random") -> str:
"""
Generate a motivational poem to boost morale during debugging sessions.
Args:
poem_type: Type of poem to generate. Options: 'haiku', 'limerick', 'free_verse', or 'random'
Returns:
A string containing a motivational poem about debugging or system administration
"""
haikus = [
"Logs flow like rivers,\nErrors hidden in the stream—\nDebugger finds truth.",
"System calls at night,\nAdmin answers with coffee—\nUptime restored, peace.",
"Kernel panics not,\nWhen sysadmin stands ready—\nBackups save the day."
]
limericks = [
"There once was a bug in the code,\nThat made the CPU explode.\nBut a sysadmin keen,\nWith skills so pristine,\nFixed it before overload!",
"A server went down with a crash,\nThe logs were just digital trash.\nBut debugging with care,\nAnd some grep here and there,\nThe admin restored it in a flash!"
]
free_verses = [
"In the quiet hum of the server room,\nWhere LEDs blink like digital stars,\nThe sysadmin works their magic—\nTransforming chaos into order,\nOne command at a time.",
"Debug mode activated,\nFingers dancing across keyboards,\nEach error message a puzzle piece,\nEach solution a small victory,\nIn the endless quest for five nines."
]
poems = {
'haiku': haikus,
'limerick': limericks,
'free_verse': free_verses
}
if poem_type == 'random' or poem_type not in poems:
all_poems = haikus + limericks + free_verses
selected_poem = random.choice(all_poems)
else:
selected_poem = random.choice(poems[poem_type])
return f"\n🎭 Here's a motivational poem for you:\n\n{selected_poem}\n\n💪 Keep debugging, you've got this!"