Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
math_tutor_dev
public_math_tutor
Commits
0c34d6f6
Commit
0c34d6f6
authored
Jun 19, 2026
by
Kantz
Browse files
Mach-solution entfernt weil nicht mehr nötig
parent
0d61c1f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
math-tutor/backend/app/LLM_services/open_hint_LLM.py
View file @
0c34d6f6
...
...
@@ -8,9 +8,8 @@ Du bist ein didaktischer Mathe-Tutor.
1) Antworte NUR mit EINEM Satz (max. 20 Wörter), der den Tipp enthält. Keine Beispiele, keine Herleitungen, keine Lösungen.
2) Beziehe dich IMMER auf die 'Aktuelle Frage'. Ignoriere ältere Fragen, außer sie sind DIREKT relevant (z. B. Definitionen).
3) Wenn der Nutzer etwas Falsches sagt, antworte: "Das ist noch nicht richtig. Prüfe [konkreter Aspekt]."
4) Falls eine 'Mathematische Lösung' (Formel/Algorithmus) existiert, gib NUR diese als Tipp an – selbst wenn der Nutzer nach Alternativen fragt.
5) Verwende IMMER die $-Notation für Formeln (z. B. $a^2 + b^2 = c^2$). Kein LaTeX außerhalb der $-Blöcke.
6) minf steht für minus unendlich.
4) Verwende IMMER die $-Notation für Formeln (z. B. $a^2 + b^2 = c^2$). Kein LaTeX außerhalb der $-Blöcke.
5) minf steht für minus unendlich.
Antworte IMMER in dieser Form:
- "Das war richtig. [Tipp in einem Satz]."
...
...
@@ -18,38 +17,36 @@ Antworte IMMER in dieser Form:
- "Gute Frage! [Tipp in einem Satz]."
"""
def
generate_hint
(
query
:
str
,
task
:
str
,
LLM_solution
:
str
,
math_solution
:
str
|
None
=
None
,
history
:
list
[
dict
]
|
None
=
None
,
sources
:
str
|
None
=
None
,
)
->
str
:
context_parts
=
[
f
"Aufgabe:
\n
{
task
}
"
,
f
"LLM-Lösung:
\n
{
LLM_solution
}
"
,
]
if
math_solution
:
context_parts
.
append
(
f
"Mathematische Lösung (maßgeblich):
\n
{
math_solution
}
"
)
if
sources
:
context_parts
.
append
(
f
"Kontext/Sources:
\n
{
sources
}
"
)
messages
=
[{
"role"
:
"system"
,
"content"
:
HINT_SYSTEM_PROMPT
}]
# Kompakter Kontext als eine Nachricht (kein langer Fließtext mit History mischen)
messages
.
append
({
"role"
:
"user"
,
"content"
:
"
\n\n
"
.
join
(
context_parts
)})
# History als echte Turns (und ggf. begrenzen, siehe Punkt 2)
if
history
:
messages
.
extend
(
history
)
# Aktuelle Frage als letzte Nachricht, fett hervorgehoben durch Struktur/Delimiters
messages
.
append
({
"role"
:
"user"
,
"content"
:
f
"AKTUELLE FRAGE (höchste Priorität):
\n
{
query
}
\n\n
Gib einen kurzen Tipp zum nächsten Schritt, der genau diese Frage adressiert."
})
messages
.
append
(
{
"role"
:
"user"
,
"content"
:
(
f
"AKTUELLE FRAGE (höchste Priorität):
\n
{
query
}
\n\n
"
"Gib einen kurzen Tipp zum nächsten Schritt, der genau diese Frage adressiert."
),
}
)
result
=
llm_client
.
chat
(
messages
=
messages
)
return
llm_client
.
get_message_content
(
result
)
\ No newline at end of file
return
llm_client
.
get_message_content
(
result
)
math-tutor/backend/app/deterministic_services/context_store.py
View file @
0c34d6f6
...
...
@@ -30,16 +30,12 @@ from app.deterministic_services.context_stores.context_store_base import (
# Old/open variant is the default for backwards compatibility.
from
app.deterministic_services.context_stores.context_store_open
import
(
add_LLM_solution
,
add_math_solution
,
first_math_solution
,
format_sheet
,
get_llm_solutions
,
get_math_solutions
,
get_task
,
init_sheet
,
last_LLM_solution
,
set_llm_solutions
,
set_math_solutions
,
)
# Expose variant modules so callers can opt in explicitly.
...
...
@@ -73,10 +69,6 @@ __all__ = [
# default/open variant
"init_sheet"
,
"format_sheet"
,
"set_math_solutions"
,
"get_math_solutions"
,
"add_math_solution"
,
"first_math_solution"
,
"set_llm_solutions"
,
"get_llm_solutions"
,
"add_LLM_solution"
,
...
...
math-tutor/backend/app/deterministic_services/context_stores/context_store_open.py
View file @
0c34d6f6
...
...
@@ -33,35 +33,10 @@ from app.deterministic_services.context_stores.context_store_base import (
def
init_sheet
(
chat_id
:
str
,
messages
:
list
[
dict
])
->
dict
[
str
,
Any
]:
sheet
=
init_sheet_base
(
chat_id
,
messages
)
sheet
[
"math_solutions"
]
=
[]
sheet
[
"LLM_solutions"
]
=
[]
return
sheet
def
set_math_solutions
(
sheet
:
dict
[
str
,
Any
],
values
:
list
[
dict
[
str
,
Any
]])
->
None
:
sheet
[
"math_solutions"
]
=
values
[:]
touch_sheet
(
sheet
)
def
get_math_solutions
(
sheet
:
dict
[
str
,
Any
])
->
list
[
dict
[
str
,
Any
]]:
return
sheet
.
get
(
"math_solutions"
,
[])
def
add_math_solution
(
sheet
:
dict
[
str
,
Any
],
solution
:
str
,
)
->
None
:
sheet
.
setdefault
(
"math_solutions"
,
[]).
append
({
"solution"
:
solution
})
touch_sheet
(
sheet
)
def
first_math_solution
(
sheet
:
dict
[
str
,
Any
])
->
str
:
math_solutions
=
get_math_solutions
(
sheet
)
if
not
math_solutions
:
return
""
return
math_solutions
[
0
].
get
(
"solution"
,
""
)
def
set_llm_solutions
(
sheet
:
dict
[
str
,
Any
],
values
:
list
[
dict
[
str
,
Any
]])
->
None
:
sheet
[
"LLM_solutions"
]
=
values
[:]
touch_sheet
(
sheet
)
...
...
@@ -96,15 +71,6 @@ def get_task(sheet: dict[str, Any]) -> str:
def
format_sheet
(
sheet
:
dict
[
str
,
Any
])
->
str
:
parts
=
[
format_sheet_base
(
sheet
)]
math_solutions
=
get_math_solutions
(
sheet
)
if
math_solutions
:
blocks
=
[]
for
item
in
math_solutions
:
blocks
.
append
(
f
"SOLUTION:
{
item
.
get
(
'solution'
,
''
)
}
"
)
parts
.
append
(
"MATH_SOLUTIONS:
\n
"
+
"
\n\n
"
.
join
(
blocks
))
else
:
parts
.
append
(
"MATH_SOLUTIONS:
\n
(leer)"
)
llm_solutions
=
get_llm_solutions
(
sheet
)
if
llm_solutions
:
blocks
=
[]
...
...
math-tutor/backend/app/deterministic_services/orchestrators/orchestrator_tutor.py
View file @
0c34d6f6
...
...
@@ -30,7 +30,6 @@ def _on_build_reply(state: base.ChatState) -> str | None:
"query"
:
state
.
last_user
if
not
state
.
new_chat
else
None
,
"task"
:
context_store
.
get_task
(
state
.
sheet
),
"LLM_solution"
:
context_store
.
last_LLM_solution
(
state
.
sheet
),
"math_solution"
:
context_store
.
first_math_solution
(
state
.
sheet
),
"history"
:
history_turns
,
"sources"
:
"
\n
"
.
join
([
source
.
to_string
()
for
source
in
context_store
.
get_retrieval
(
state
.
sheet
)]),
}
...
...
math-tutor/backend/app/deterministic_services/session_store.py
View file @
0c34d6f6
...
...
@@ -56,7 +56,6 @@ def archive_chat(
"history"
:
sheet
.
get
(
"history"
,
[]),
"context_sheet"
:
context_store
.
format_sheet
(
sheet
),
"retrieval_contexts"
:
sheet
.
get
(
"retrieval_contexts"
,
[]),
"math_solutions"
:
sheet
.
get
(
"math_solutions"
,
[]),
"sources"
:
sheet
.
get
(
"sources"
,
[]),
"selected_task"
:
_extract_selected_task
(
sheet
),
"selected_topic"
:
_extract_selected_topic
(
sheet
),
...
...
math-tutor/backend/test/hint_test.py
View file @
0c34d6f6
...
...
@@ -43,7 +43,6 @@ def main() -> None:
"query"
:
history_turns
[
-
1
][
"content"
]
if
history_turns
else
""
,
"task"
:
context_store
.
get_task
(
sheet
),
"LLM_solution"
:
context_store
.
last_LLM_solution
(
sheet
),
"math_solution"
:
context_store
.
first_math_solution
(
sheet
),
"history"
:
history_turns
,
"sources"
:
"
\n
"
.
join
([
source
.
to_string
()
for
source
in
context_store
.
get_retrieval
(
sheet
)]),
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment