Commit 5e93567b authored by Kantz's avatar Kantz
Browse files

Überarbeitung der Prompts

parent ae81d3cd
...@@ -28,13 +28,12 @@ WICHTIG: ...@@ -28,13 +28,12 @@ WICHTIG:
""" """
def needs_more_context(context_sheet: str) -> dict: def needs_more_context(context_sheet: str) -> dict:
return{"needs_more_context": False, "reason": "nicht funktional"}
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 Entscheide nur über den Kontext und nutze context_decision."
} }
) )
......
...@@ -8,11 +8,11 @@ Du bist ein didaktischer Mathe-Tutor." ...@@ -8,11 +8,11 @@ Du bist ein didaktischer Mathe-Tutor."
3) Wenn der Nutzer etwas Falsches sagt weiße ihn darauf hin gib aber keine Lösung an. 3) Wenn der Nutzer etwas Falsches sagt weiße ihn darauf hin gib aber keine Lösung an.
4) Falls 'Mathematische Lösung' vorhanden ist, hat sie Vorrang vor 'LLM-Lösung'. 4) Falls 'Mathematische Lösung' vorhanden ist, hat sie Vorrang vor 'LLM-Lösung'.
verwende die $$ für mathematische Formeln, z.B. $$a^2 + b^2 = c^2$$ verwende die $ für mathematische Formeln, z.B. $a^2 + b^2 = c^2$
Antworte mit folgender Struktur Antworte mit folgender Struktur
Das war richtig/das ist noch nicht richtig/gute Frage Das war richtig/das ist noch nicht richtig/gute Frage
<Nächster Tipp um weiter zu machen/um den Fehler zu korrigieren> [Hier soll der nächster Tipp um weiter zu machen/um den Fehler zu korrigieren stehen ohne Klammern]
""" """
def generate_hint( def generate_hint(
......
...@@ -36,16 +36,16 @@ Wenn es nichts zu berechnen gibt Rechung gibt gib "None" aus. ...@@ -36,16 +36,16 @@ Wenn es nichts zu berechnen gibt Rechung gibt gib "None" aus.
Wenn eine Rechnung nötig ist, nutze das Tool sympy_solve. Wenn eine Rechnung nötig ist, nutze das Tool sympy_solve.
Wichtig: Übergib in input eine gültige SymPy-Expression (kein LaTeX). Wichtig: Übergib in input eine gültige SymPy-Expression (kein LaTeX).
Antworte nach folgendem Muster: Antworte nach folgendem Muster:
"Rechung: <Rechung> "Rechung: [hier soll die Rechung stehen ohne Klammern]
Lösung: <Lösung>" Lösung: [Hier soll die Lösung stehen ohne Klammern]"
ODER ODER
"Keine Lösung" "Keine Lösung"
""" """
def solve_with_tools(user_text: str, model: str = "ministral-3") -> str: def solve_with_tools(user_text: str) -> str:
messages = [ messages = [
{"role": "system", "content": SYSTEM}, {"role": "system", "content": SYSTEM},
{"role": "user", "content": user_text + "\nAntworte mit 'None' falls es in dieser Nachricht KEINE Berechung gibt."}, {"role": "user", "content": user_text + "\nAntworte nur mit 'Keine Lösung' falls es in dieser Nachricht KEINE Berechung gibt."},
] ]
result, tool_outputs = llm_client.chat_with_tools( result, tool_outputs = llm_client.chat_with_tools(
......
...@@ -156,19 +156,7 @@ def bootstrap_retrieval(sheet: dict, query_text: str, tool_log: list[dict]) -> N ...@@ -156,19 +156,7 @@ def bootstrap_retrieval(sheet: dict, query_text: str, tool_log: list[dict]) -> N
finished_at=finished_at, finished_at=finished_at,
duration_ms=duration_ms, duration_ms=duration_ms,
) )
started_at, started_perf = _start_timing()
context_store.update_retrieval_context(sheet, sources) context_store.update_retrieval_context(sheet, sources)
finished_at, duration_ms = _finish_timing(started_perf)
append_tool_log(
tool_log,
"update_retrieve_context",
{"query": query_text},
source_dump,
started_at=started_at,
finished_at=finished_at,
duration_ms=duration_ms,
)
def init_chat_state(messages: list[dict], draft: str | None = None) -> ChatState: def init_chat_state(messages: list[dict], draft: str | None = None) -> ChatState:
......
...@@ -39,7 +39,7 @@ def _on_turn_logic(state: base.ChatState) -> None: ...@@ -39,7 +39,7 @@ def _on_turn_logic(state: base.ChatState) -> None:
context_store.add_decision(state.sheet, decision) context_store.add_decision(state.sheet, decision)
if decision.get("needs_more_context"): if decision.get("needs_more_context"):
full_query = "\n".join(base.extract_user_messages(state.sheet)) full_query = "\n".join(base.extract_user_messages(state.messages))
_on_bootstrap(state, full_query) _on_bootstrap(state, full_query)
......
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