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
c58be6a8
Commit
c58be6a8
authored
Jan 26, 2026
by
Kantz
Browse files
nur noch ein tool_logging datei
parent
52993fbc
Changes
2
Hide whitespace changes
Inline
Side-by-side
math-tutor/backend/app/deterministic_services/orchestrator.py
View file @
c58be6a8
...
...
@@ -71,5 +71,9 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
reply
=
"Dazu steht nichts im Material"
context_store
.
save_sheet
(
sheet
)
tool_logging
.
write_tool_log
(
tool_log
)
tool_logging
.
write_tool_log
(
tool_log
,
created_at
=
sheet
.
get
(
"created_at"
),
chat_id
=
sheet
.
get
(
"chat_id"
),
)
return
{
"reply"
:
reply
,
"sources"
:
sheet
.
get
(
"sources"
,
[]),
"tool_log"
:
tool_log
}
math-tutor/backend/app/deterministic_services/tool_logging.py
View file @
c58be6a8
...
...
@@ -3,10 +3,30 @@ import os
from
datetime
import
datetime
def
write_tool_log
(
entries
:
list
[
dict
])
->
str
:
def
_format_log_timestamp
(
created_at
:
str
|
None
)
->
str
:
if
not
created_at
:
return
datetime
.
utcnow
().
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
try
:
parsed
=
datetime
.
strptime
(
created_at
,
"%Y-%m-%dT%H:%M:%SZ"
)
return
parsed
.
strftime
(
"%Y-%m-%dT%H:%M:%SZ"
)
except
ValueError
:
return
created_at
def
_format_filename_timestamp
(
timestamp
:
str
)
->
str
:
try
:
parsed
=
datetime
.
strptime
(
timestamp
,
"%Y-%m-%dT%H:%M:%SZ"
)
return
parsed
.
strftime
(
"%Y%m%d_%H%M%S"
)
except
ValueError
:
return
timestamp
.
replace
(
"-"
,
""
).
replace
(
":"
,
""
).
replace
(
"T"
,
"_"
).
replace
(
"Z"
,
""
)
def
write_tool_log
(
entries
:
list
[
dict
],
created_at
:
str
|
None
=
None
,
chat_id
:
str
|
None
=
None
)
->
str
:
os
.
makedirs
(
"logs"
,
exist_ok
=
True
)
timestamp
=
datetime
.
now
().
strftime
(
"%Y%m%d_%H%M%S"
)
path
=
os
.
path
.
join
(
"logs"
,
f
"tool_calls_
{
timestamp
}
.json"
)
timestamp
=
_format_log_timestamp
(
created_at
)
filename_ts
=
_format_filename_timestamp
(
timestamp
)
suffix
=
chat_id
or
"latest"
path
=
os
.
path
.
join
(
"logs"
,
f
"tool_calls_
{
suffix
}
_
{
filename_ts
}
.json"
)
payload
=
{
"timestamp"
:
timestamp
,
"entries"
:
entries
,
...
...
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