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
3eb6567e
Commit
3eb6567e
authored
Mar 18, 2026
by
Kantz
Browse files
vermeidung doppeltere Context_sheets
parent
0d77c8d6
Changes
3
Hide whitespace changes
Inline
Side-by-side
math-tutor/backend/app/deterministic_services/orchestrators/orchestrator_base.py
View file @
3eb6567e
...
...
@@ -3,7 +3,7 @@ from __future__ import annotations
import
time
from
dataclasses
import
dataclass
from
datetime
import
datetime
,
timezone
from
typing
import
Callable
,
List
,
TypeVar
from
typing
import
Any
,
Callable
,
List
,
TypeVar
import
app.config
as
config
from
app.deterministic_services
import
(
...
...
@@ -176,7 +176,11 @@ def bootstrap_retrieval(sheet: dict, query_text: str, tool_log: list[dict]) -> N
# Chat Status
# --
def
init_chat_state
(
messages
:
list
[
dict
],
draft
:
str
|
None
=
None
)
->
ChatState
:
def
init_chat_state
(
messages
:
list
[
dict
],
draft
:
str
|
None
=
None
,
init_sheet_fn
:
Callable
[[
str
,
list
[
dict
]],
dict
[
str
,
Any
]]
|
None
=
None
,
)
->
ChatState
:
if
not
messages
:
raise
ValueError
(
"messages required"
)
...
...
@@ -188,8 +192,9 @@ def init_chat_state(messages: list[dict], draft: str | None = None) -> ChatState
chat_id
=
context_store
.
get_chat_id
(
messages
,
draft
=
draft
)
new_chat
=
is_new_chat
(
messages
)
sheet
=
context_store
.
load_sheet
(
chat_id
)
if
new_chat
or
not
sheet
:
sheet
=
context_store
.
init_sheet
(
chat_id
,
messages
)
if
not
sheet
:
create_sheet
=
init_sheet_fn
or
context_store
.
init_sheet
sheet
=
create_sheet
(
chat_id
,
messages
)
context_store
.
update_history
(
sheet
,
messages
)
return
ChatState
(
...
...
@@ -236,9 +241,10 @@ def run_chat_common(
on_bootstrap
:
Callable
[[
ChatState
,
str
],
None
],
on_turn_logic
:
Callable
[[
ChatState
],
None
],
on_build_reply
:
Callable
[[
ChatState
],
str
|
None
],
init_sheet_fn
:
Callable
[[
str
,
list
[
dict
]],
dict
[
str
,
Any
]]
|
None
=
None
,
)
->
dict
:
init_started_at
,
init_started_perf
=
_start_timing
()
state
=
init_chat_state
(
messages
,
draft
)
state
=
init_chat_state
(
messages
,
draft
,
init_sheet_fn
=
init_sheet_fn
)
init_finished_at
,
init_duration_ms
=
_finish_timing
(
init_started_perf
)
append_tool_log
(
state
.
tool_log
,
...
...
math-tutor/backend/app/deterministic_services/orchestrators/orchestrator_feedback.py
View file @
3eb6567e
...
...
@@ -148,4 +148,5 @@ def run_chat(
on_bootstrap
=
on_bootstrap
,
on_turn_logic
=
on_turn_logic
,
on_build_reply
=
_on_build_reply
,
init_sheet_fn
=
context_store
.
context_store_new
.
init_sheet
,
)
math-tutor/backend/app/deterministic_services/orchestrators/orchestrator_task.py
View file @
3eb6567e
...
...
@@ -151,4 +151,5 @@ def run_chat(
on_bootstrap
=
on_bootstrap
,
on_turn_logic
=
on_turn_logic
,
on_build_reply
=
_on_build_reply
,
init_sheet_fn
=
context_store
.
context_store_new
.
init_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