27 lines
935 B
Python
27 lines
935 B
Python
from pathlib import Path
|
|
p = Path('/root/homelab-brain/homelab-ai-bot/tools/deep_research.py')
|
|
text = p.read_text()
|
|
|
|
# Fix the broken _inject_date_context
|
|
old_fn = '''def _inject_date_context(query):
|
|
today = date.today()
|
|
return (
|
|
f"Heutiges Datum: {today.strftime('%d. %B %Y')}. "
|
|
f"'Letzte 3 Monate' = {(today.replace(day=1) - __import__('datetime').timedelta(days=90)).strftime('%B %Y')} bis {today.strftime('%B %Y')}.\n\n"
|
|
+ query
|
|
)'''
|
|
|
|
new_fn = '''def _inject_date_context(query):
|
|
from datetime import timedelta
|
|
today = date.today()
|
|
three_months_ago = today - timedelta(days=90)
|
|
prefix = (
|
|
"Heutiges Datum: " + today.strftime("%d. %B %Y") + ". "
|
|
"'Letzte 3 Monate' = " + three_months_ago.strftime("%B %Y")
|
|
+ " bis " + today.strftime("%B %Y") + ".\n\n"
|
|
)
|
|
return prefix + query'''
|
|
|
|
text = text.replace(old_fn, new_fn)
|
|
p.write_text(text)
|
|
print('OK')
|