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
3a6de9fc
Commit
3a6de9fc
authored
Jan 26, 2026
by
Kantz
Browse files
Überarbeitung des Retrivals
parent
1ddd502e
Changes
3
Hide whitespace changes
Inline
Side-by-side
math-tutor/backend/app/LLM_services/hint_LLM.py
View file @
3a6de9fc
...
...
@@ -21,6 +21,8 @@ def generate_hint(
)
if
history
:
prompt
+=
"
\n
Historie:
\n
"
+
history
+
"
\n
"
if
context_sheet
:
prompt
+=
"
\n
Kontext:
\n
"
+
context_sheet
+
"
\n
"
prompt
+=
"Halte dich kurz und klar. Gibt nicht die Lösung aus."
result
=
llm_client
.
chat
(
...
...
math-tutor/backend/app/deterministic_services/context_store.py
View file @
3a6de9fc
...
...
@@ -107,23 +107,25 @@ def add_math_solution(
sheet
[
"updated_at"
]
=
_utc_now
()
def
add_tool_output
(
sheet
:
dict
[
str
,
Any
],
entry
:
dict
[
str
,
Any
])
->
None
:
sheet
[
"tool_outputs"
].
append
(
entry
)
sheet
[
"updated_at"
]
=
_utc_now
()
def
add_decision
(
sheet
:
dict
[
str
,
Any
],
decision
:
dict
[
str
,
Any
])
->
None
:
entry
=
{
"timestamp"
:
_utc_now
(),
**
decision
}
sheet
[
"decisions"
].
append
(
entry
)
sheet
[
"updated_at"
]
=
_utc_now
()
# wird aktuell nicht benutzt
def
latest_math_solution
(
sheet
:
dict
[
str
,
Any
])
->
str
:
if
not
sheet
[
"math_solutions"
]:
return
""
return
sheet
[
"math_solutions"
][
-
1
].
get
(
"solution"
,
""
)
def
first_math_solution
(
sheet
:
dict
[
str
,
Any
])
->
str
:
if
not
sheet
[
"math_solutions"
]:
return
""
return
sheet
[
"math_solutions"
][
0
].
get
(
"solution"
,
""
)
def
format_sheet
(
sheet
:
dict
[
str
,
Any
])
->
str
:
parts
=
[]
history
=
format_history
(
sheet
.
get
(
"history"
,
[]))
...
...
math-tutor/backend/app/deterministic_services/orchestrator.py
View file @
3a6de9fc
...
...
@@ -10,10 +10,6 @@ def _append_tool_log(tool_log: list[dict], name: str, args: dict, response: obje
def
_bootstrap_context
(
sheet
:
dict
,
query_text
:
str
,
tool_log
:
list
[
dict
])
->
None
:
context
,
sources
=
retrieval_service
.
retrieve_context
(
query_text
=
query_text
)
context_store
.
add_retrieval_context
(
sheet
,
query_text
,
context
,
sources
)
context_store
.
add_tool_output
(
sheet
,
{
"name"
:
"retrieve_context"
,
"arguments"
:
{
"query"
:
query_text
},
"response"
:
context
},
)
_append_tool_log
(
tool_log
,
"retrieve_context"
,
{
"query"
:
query_text
},
{
"context"
:
context
,
"sources"
:
sources
})
math_request
=
math_intent_LLM
.
extract_math_request
(
query_text
)
...
...
@@ -26,10 +22,6 @@ def _bootstrap_context(sheet: dict, query_text: str, tool_log: list[dict]) -> No
math_request
.
get
(
"symbols"
),
solution
,
)
context_store
.
add_tool_output
(
sheet
,
{
"name"
:
"sympy_solve"
,
"arguments"
:
math_request
,
"response"
:
solution
},
)
_append_tool_log
(
tool_log
,
"sympy_solve"
,
math_request
,
solution
)
...
...
@@ -68,12 +60,11 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
# Hinweis und Ausgaben generierung
hint_args
=
{
"task"
:
last_user
.
get
(
"content"
,
""
),
"solution"
:
context_store
.
late
st_math_solution
(
sheet
),
"solution"
:
context_store
.
fir
st_math_solution
(
sheet
),
"history"
:
history_text
,
"context_sheet"
:
sheet_text
,
}
reply
=
hint_LLM
.
generate_hint
(
**
hint_args
)
context_store
.
add_tool_output
(
sheet
,
{
"name"
:
"generate_hint"
,
"arguments"
:
hint_args
,
"response"
:
reply
})
_append_tool_log
(
tool_log
,
"generate_hint"
,
hint_args
,
reply
)
if
not
reply
:
...
...
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