Commit 90e48a24 authored by Kantz's avatar Kantz
Browse files

hint Generator tests

parent aab2c5f0
......@@ -14,6 +14,7 @@ def generate_hint(
"Antworte nur mit dem Tipp, ohne weitere Erklärungen."
"Gibe keine komplette Lösung der Aufgabe."
"Die Mathematische Lösung hat immer Vorrang vor der LLM Lösung."
"Halte dich kurz und prägnant."
)
prompt = (
"Aufgabe:\n"
......@@ -29,7 +30,7 @@ def generate_hint(
prompt += "\nHistorie:\n" + history + "\n"
if retrival:
prompt = "\nKontext:\n" + retrival + "\n" + prompt
prompt += "\nGebe einen hilfreichen Tipp zur Lösung der Aufgabe. Halte dich kurz und prägnant."
result = llm_client.chat(
messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}],
)
......
import argparse
import json
import os
from typing import Any
from app.LLM_services import hint_LLM
from app.deterministic_services import context_store
def _load_sheet_from_path(path: str) -> dict[str, Any]:
with open(path, "r", encoding="utf-8") as f:
return json.load(f)
def _resolve_sheet(args: argparse.Namespace) -> dict[str, Any]:
if args.sheet:
return _load_sheet_from_path(args.sheet)
if args.chat_id:
sheet = context_store.load_sheet(args.chat_id)
if sheet is None:
raise FileNotFoundError(f"Kein Context-Sheet gefunden fuer chat_id={args.chat_id}")
return sheet
raise ValueError("Bitte --sheet oder --chat-id angeben.")
def main() -> None:
parser = argparse.ArgumentParser(description="Isolierter Hint-LLM Test mit Context Sheet.")
parser.add_argument("--sheet", help="Pfad zu einem Context Sheet JSON.")
parser.add_argument("--chat-id", help="Chat-ID zum Laden aus logs/context_sheets.")
args = parser.parse_args()
sheet = _resolve_sheet(args)
hint_args = {
"task": context_store.get_task(sheet),
"LLM_solution": context_store.last_LLM_solution(sheet),
"math_solution": context_store.first_math_solution(sheet),
"history": context_store.get_history(sheet),
"retrival": context_store.get_retrival(sheet),
}
reply = hint_LLM.generate_hint(**hint_args)
print(reply)
if __name__ == "__main__":
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment