Commit bc0fbd71 authored by Kantz's avatar Kantz
Browse files

test überarbeitet decision schläge aktuell fehl

parent 7f4548ea
...@@ -67,7 +67,7 @@ Retrieval settings: ...@@ -67,7 +67,7 @@ Retrieval settings:
- Core retrieval logic is in `math-tutor/backend/app/services/vector_store.py` (`retrieve`). - Core retrieval logic is in `math-tutor/backend/app/services/vector_store.py` (`retrieve`).
## Testing ## Testing
python -m test.hint_test ... python -m test.hint_test --chat-id draft_session_mlgmxxzc_avmjfb
python -m test.vector_store_test --query "Was ist eine Teilmenge?" --k 8 --expand python -m test.vector_store_test --query "Was ist eine Teilmenge?" --k 8 --expand
python -m test.math_intent_test --input "Integrate x^2" --input "Was ist 2+2?" python -m test.math_intent_test --input "Integrate x^2" --input "Was ist 2+2?"
python -m test.decision_test --chat-id draft_session_mlgeyn5z_unpxyh python -m test.decision_test --chat-id draft_session_mlgmxxzc_avmjfb
\ No newline at end of file \ No newline at end of file
...@@ -27,19 +27,16 @@ WICHTIG: ...@@ -27,19 +27,16 @@ WICHTIG:
- Löse nicht die Aufgabe, sondern bewerte nur die Situation bzgl. der nächsten didaktischen Schritte. - Löse nicht die Aufgabe, sondern bewerte nur die Situation bzgl. der nächsten didaktischen Schritte.
""" """
def needs_more_context(history: list[dict], context_sheet: str, model: str = "ministral-3") -> dict: def needs_more_context(context_sheet: str) -> dict:
messages = [{"role": "system", "content": CLASSIFIER_SYSTEM}] messages = [{"role": "system", "content": CLASSIFIER_SYSTEM}]
messages.append( messages.append(
{ {
"role": "user", "role": "user",
"content": "Kontextblatt:\n" "content": "Kontextblatt:\n"
f"{context_sheet}\n\n" f"{context_sheet}\n\n"
"Beachte die folgende Historie.",
} }
) )
if history: messages.append({"role": "user", "content": "Treffe eine Entscheidung. Zu der letzten Nachricht"})
messages.extend(history)
messages.append({"role": "user", "content": "Treffe eine Entscheidung."})
resp, tool_outputs = llm_client.chat_with_tools( resp, tool_outputs = llm_client.chat_with_tools(
messages=messages, messages=messages,
......
...@@ -28,7 +28,7 @@ def _on_turn_logic(state: base.ChatState) -> None: ...@@ -28,7 +28,7 @@ def _on_turn_logic(state: base.ChatState) -> None:
context_store.add_LLM_solution(state.sheet, llm_solution) context_store.add_LLM_solution(state.sheet, llm_solution)
return return
decision = decision_LLM.needs_more_context(history_turns, sheet_text) decision = decision_LLM.needs_more_context(sheet_text)
base.append_tool_log(state.tool_log, "decision", {"sheet": sheet_text}, decision) base.append_tool_log(state.tool_log, "decision", {"sheet": sheet_text}, decision)
context_store.add_decision(state.sheet, decision) context_store.add_decision(state.sheet, decision)
......
...@@ -33,21 +33,15 @@ def main() -> None: ...@@ -33,21 +33,15 @@ def main() -> None:
parser = argparse.ArgumentParser(description="Isolierter Decision-LLM Test mit Context Sheet.") parser = argparse.ArgumentParser(description="Isolierter Decision-LLM Test mit Context Sheet.")
parser.add_argument("--sheet", help="Pfad zu einem Context Sheet JSON.") 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.") parser.add_argument("--chat-id", help="Chat-ID zum Laden aus logs/context_sheets.")
parser.add_argument(
"--last-user-count",
type=int,
default=1,
help="Wie viele der letzten Nutzer-Eingaben ausgegeben werden sollen.",
)
args = parser.parse_args() args = parser.parse_args()
sheet = _resolve_sheet(args) sheet = _resolve_sheet(args)
history_text = context_store.get_history(sheet)
context_text = context_store.format_sheet(sheet) context_text = context_store.format_sheet(sheet)
decision = decision_LLM.needs_more_context(history_text, context_text) decision = decision_LLM.needs_more_context(context_text)
last_inputs = _last_user_inputs(sheet.get("history", []), args.last_user_count) history_turns = context_store.get_history_turns(sheet)
last_inputs = history_turns[-1]["content"] if history_turns else ""
print("LAST_USER_INPUTS:", json.dumps(last_inputs, ensure_ascii=True)) print("LAST_USER_INPUTS:", json.dumps(last_inputs, ensure_ascii=True))
print("OUTPUT:", json.dumps(decision, ensure_ascii=True)) print("OUTPUT:", json.dumps(decision, ensure_ascii=True))
......
...@@ -31,14 +31,16 @@ def main() -> None: ...@@ -31,14 +31,16 @@ def main() -> None:
sheet = _resolve_sheet(args) sheet = _resolve_sheet(args)
hint_args = { history_turns = context_store.get_history_turns(sheet)
args = {
"query": history_turns[-1]["content"] if history_turns else "",
"task": context_store.get_task(sheet), "task": context_store.get_task(sheet),
"LLM_solution": context_store.last_LLM_solution(sheet), "LLM_solution": context_store.last_LLM_solution(sheet),
"math_solution": context_store.first_math_solution(sheet), "math_solution": context_store.first_math_solution(sheet),
"history": context_store.get_history(sheet), "history": history_turns,
"retrival": context_store.get_retrieval(sheet), "sources": "\n".join([source.to_string() for source in context_store.get_retrieval(sheet)]),
} }
reply = hint_LLM.generate_hint(**hint_args) reply = hint_LLM.generate_hint(**args)
print(reply) print(reply)
......
...@@ -49,7 +49,7 @@ def main() -> None: ...@@ -49,7 +49,7 @@ def main() -> None:
print(f"Gefundene Quellen: {len(sources)}") print(f"Gefundene Quellen: {len(sources)}")
for source in sources: for source in sources:
print(source.to_string()) print(f"[{source.score:.4f}] {source.source_id.title} ({source.source_type})")
if __name__ == "__main__": if __name__ == "__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