Auto-Sync: 2026-03-20 23:00

This commit is contained in:
Auto-Sync 2026-03-20 23:00:11 +01:00
parent 1eed2dd712
commit d761ec083c
6 changed files with 151 additions and 3 deletions

View file

@ -1,5 +1,5 @@
# Arakava News — Live State
> Auto-generiert: 2026-03-20 22:45
> Auto-generiert: 2026-03-20 23:00
## Service Status
| Service | CT | Status |

View file

@ -0,0 +1,45 @@
from pathlib import Path
p = Path('/root/homelab-brain/homelab-ai-bot/tools/deep_research.py')
text = p.read_text()
# 1. Add datetime import
text = text.replace(
'import logging\nimport re\nimport time',
'import logging\nimport re\nimport time\nfrom datetime import date'
)
# 2. Add _inject_date_context function before _price_report_quality
text = text.replace(
'def _price_report_quality(report: str):',
'''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
)
def _price_report_quality(report: str):'''
)
# 3. Add year check in _price_report_quality before return
text = text.replace(
' return len(missing) == 0, missing',
''' today = date.today()
ok_years = {str(today.year), str(today.year - 1)}
found = set(re.findall(r"20\d{2}", text))
if found and not (found & ok_years):
missing.append(f"Jahre falsch: {found} statt {ok_years}")
return len(missing) == 0, missing'''
)
# 4. Inject date context in handle_deep_research
text = text.replace(
' log.info("deep_research gestartet: %s", query[:120])',
' query = _inject_date_context(query)\n log.info("deep_research gestartet: %s", query[:200])'
)
p.write_text(text)
print('OK')

View file

@ -0,0 +1,27 @@
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')

View file

@ -0,0 +1,76 @@
from pathlib import Path
p = Path('/root/homelab-brain/homelab-ai-bot/llm.py')
text = p.read_text()
# 1. Replace model config block
old_models = '''MODEL = openai/gpt-4o-mini
VISION_MODEL = openai/gpt-4o
MAX_TOOL_ROUNDS = 3'''
new_models = '''OLLAMA_BASE = http://100.84.255.83:11434
OPENROUTER_BASE = https://openrouter.ai/api/v1
MODEL = qwen2.5:14b
VISION_MODEL = openai/gpt-4o
MAX_TOOL_ROUNDS = 3'''
text = text.replace(old_models, new_models)
# 2. Add date to system prompt (right after first line)
old_prompt_start = 'SYSTEM_PROMPT = """Du bist der Hausmeister-Bot fuer ein Homelab. Deutsch, kurz, direkt, operativ.'
new_prompt_start = '''SYSTEM_PROMPT = f"""Du bist der Hausmeister-Bot fuer ein Homelab. Deutsch, kurz, direkt, operativ.
Heutiges Datum: {__import__('datetime').date.today().strftime('%d. %B %Y')}.'''
text = text.replace(old_prompt_start, new_prompt_start)
# 3. Replace _call_openrouter to support both backends
old_call = '''def _call_openrouter(messages: list, api_key: str, use_tools: bool = True,
model: str = None, max_tokens: int = 600) -> dict:
payload = {
model: model or MODEL,
messages: messages,
max_tokens: max_tokens,
}
if use_tools:
payload[tools] = TOOLS
payload[tool_choice] = auto
r = requests.post(
https://openrouter.ai/api/v1/chat/completions,
headers={Authorization: fBearer {api_key}},
json=payload,
timeout=90,
)
r.raise_for_status()
return r.json()'''
new_call = '''def _call_openrouter(messages: list, api_key: str, use_tools: bool = True,
model: str = None, max_tokens: int = 600) -> dict:
chosen_model = model or MODEL
use_ollama = chosen_model == MODEL
payload = {
model: chosen_model,
messages: messages,
max_tokens: max_tokens,
}
if use_tools:
payload[tools] = TOOLS
payload[tool_choice] = auto
if use_ollama:
url = f{OLLAMA_BASE}/v1/chat/completions
headers = {}
timeout = 180
else:
url = f{OPENROUTER_BASE}/chat/completions
headers = {Authorization: fBearer {api_key}}
timeout = 90
r = requests.post(url, headers=headers, json=payload, timeout=timeout)
r.raise_for_status()
return r.json()'''
text = text.replace(old_call, new_call)
p.write_text(text)
print('OK')

View file

@ -1,5 +1,5 @@
# Infrastruktur — Live State
> Auto-generiert: 2026-03-20 22:45
> Auto-generiert: 2026-03-20 23:00
## pve-hetzner Disk
| Mount | Belegt |

View file

@ -1,5 +1,5 @@
# Smart Home Muldenstein — Live State
> Auto-generiert: 2026-03-20 22:45
> Auto-generiert: 2026-03-20 23:00
## Backup-Status
- Letztes Backup: 563MB, 2026-03-20 04:01