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
da60296c
Commit
da60296c
authored
Feb 03, 2026
by
Kantz
Browse files
update von den Hint übergebenen parametern
parent
5832543c
Changes
3
Show whitespace changes
Inline
Side-by-side
math-tutor/backend/app/LLM_services/hint_LLM.py
View file @
da60296c
...
...
@@ -3,60 +3,34 @@ from app.deterministic_services import llm_client
def
generate_hint
(
task
:
str
,
solution
:
str
,
LLM_solution
:
str
,
math_solution
:
str
|
None
=
None
,
history
:
str
|
None
=
None
,
retrival
:
str
|
None
=
None
,
)
->
str
:
system_prompt
=
(
"Du bist ein didaktischer Tutor. "
"Gebe dem Nutzer hilfreiche Tipps um mathematische Aufgaben zu lösen. "
"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."
)
prompt
=
(
"Aufgabe:
\n
"
+
task
+
"
\n\n
"
"Loesung (vo
m Mathe-Tool
):
\n
"
+
solution
"Loesung (vo
n einem LLM
):
\n
"
+
LLM_
solution
+
"
\n
"
+
"Du bist ein didaktischer Tutor. "
"Schaue dir Aufgabe, die dazugehörige Lösung und die bisherige Historie an."
"Entscheide basierend darauf was der nächste Schritt ist den der Nutzer machen muss um zur Lösung zu kommne"
"Schreibe einen minimalen Tipp zum nächsten Schritt"
"Halte dich kurz und klar. Gibt nicht die Lösung aus."
)
if
math_solution
:
prompt
+=
"Mathematische Loesung:
\n
"
+
math_solution
+
"
\n
"
if
history
:
prompt
=
"
\n
Historie:
\n
"
+
history
+
"
\n
"
+
prompt
prompt
+
=
"
\n
Historie:
\n
"
+
history
+
"
\n
"
if
retrival
:
prompt
=
"
\n
Kontext:
\n
"
+
retrival
+
"
\n
"
+
prompt
result
=
llm_client
.
chat
(
messages
=
[{
"role"
:
"user"
,
"content"
:
prompt
}],
messages
=
[{
"role"
:
"system"
,
"content"
:
system_prompt
},
{
"role"
:
"user"
,
"content"
:
prompt
}],
)
return
llm_client
.
get_message_content
(
result
)
\ No newline at end of file
TOOL_SPEC
=
{
"type"
:
"function"
,
"function"
:
{
"name"
:
"generate_hint"
,
"description"
:
(
"Gibt einen didaktisch wertvollen naechsten Hinweis "
"auf Basis der Aufgabe und der berechneten Loesung."
),
"parameters"
:
{
"type"
:
"object"
,
"properties"
:
{
"task"
:
{
"type"
:
"string"
,
"description"
:
"Die gegebene Aufgabe"
},
"solution"
:
{
"type"
:
"string"
,
"description"
:
"Loesung aus dem Mathe-Tool"
,
},
"history"
:
{
"type"
:
"string"
,
"description"
:
"Optionaler Verlauf, kann leer sein"
,
},
"retrival"
:
{
"type"
:
"string"
,
"description"
:
"Optionales Kontextblatt mit Werkzeug- und Retrieval-Infos"
,
},
},
"required"
:
[
"task"
,
"solution"
],
},
},
}
math-tutor/backend/app/deterministic_services/context_store.py
View file @
da60296c
...
...
@@ -138,6 +138,19 @@ def latest_math_solution(sheet: dict[str, Any]) -> str:
return
""
return
sheet
[
"math_solutions"
][
-
1
].
get
(
"solution"
,
""
)
def
last_LLM_solution
(
sheet
:
dict
[
str
,
Any
])
->
str
:
if
not
sheet
[
"LLM_solutions"
]:
return
""
return
sheet
[
"LLM_solutions"
][
-
1
].
get
(
"solution"
,
""
)
def
get_task
(
sheet
:
dict
[
str
,
Any
])
->
str
:
history
=
sheet
.
get
(
"history"
,
[])
if
history
:
return
history
[
0
].
get
(
"content"
,
""
)
return
""
def
get_history
(
sheet
:
dict
[
str
,
Any
])
->
str
:
return
format_history
(
sheet
.
get
(
"history"
,
[]))
def
first_math_solution
(
sheet
:
dict
[
str
,
Any
])
->
str
:
if
not
sheet
[
"math_solutions"
]:
...
...
math-tutor/backend/app/deterministic_services/orchestrator.py
View file @
da60296c
...
...
@@ -89,9 +89,10 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
# Hinweis und Ausgaben generierung
hint_args
=
{
"task"
:
_extract_user_messages
(
messages
)[
0
],
"solution"
:
context_store
.
first_math_solution
(
sheet
),
"history"
:
history_text
,
"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
.
format_history
(
messages
),
"retrival"
:
context_store
.
get_retrival
(
sheet
),
}
reply
=
hint_LLM
.
generate_hint
(
**
hint_args
)
...
...
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