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
eaecc684
Commit
eaecc684
authored
Jan 20, 2026
by
Kantz
Browse files
Konfigurierung des Modells
parent
e6256e64
Changes
3
Hide whitespace changes
Inline
Side-by-side
math-tutor/README.md
View file @
eaecc684
...
@@ -48,3 +48,16 @@ cd math-tutor/backend
...
@@ -48,3 +48,16 @@ cd math-tutor/backend
.
\.venv\Scripts\Activate.ps1
.
\.venv\Scripts\Activate.ps1
python
.
\scripts\retrieval_cli.py
query
--q
"Was ist eine Teilmenge?"
--k
8
--expand
python
.
\scripts\retrieval_cli.py
query
--q
"Was ist eine Teilmenge?"
--k
8
--expand
```
```
## Configuration
System prompt (LLM):
-
Edit
`math-tutor/backend/app/api/chat.py`
and update
`SYSTEM_PROMPT`
.
Retrieval settings:
-
Frontend request parameters live in
`math-tutor/frontend/src/pages/App.tsx`
:
-
`k`
-
`expand_links`
-
`neighbor_expand`
-
Backend defaults are in
`math-tutor/backend/app/api/retrieval.py`
(
`QueryRequest`
).
-
Core retrieval logic is in
`math-tutor/backend/app/services/vector_store.py`
(
`retrieve`
).
math-tutor/backend/app/api/chat.py
View file @
eaecc684
...
@@ -16,6 +16,16 @@ OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL")
...
@@ -16,6 +16,16 @@ OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL")
OPENAI_API_KEY
=
os
.
getenv
(
"OPENAI_API_KEY"
)
OPENAI_API_KEY
=
os
.
getenv
(
"OPENAI_API_KEY"
)
OPENAI_MODEL
=
os
.
getenv
(
"OPENAI_MODEL"
,
"gpt-4o-mini"
)
OPENAI_MODEL
=
os
.
getenv
(
"OPENAI_MODEL"
,
"gpt-4o-mini"
)
SYSTEM_PROMPT
=
"""Du bist ein Mathe-Tutor. Antworte auf Deutsch, klar und korrekt.
Nutze ausschließlich den bereitgestellten Kontext.
Gib wenn möglich eine kurze Struktur:
(1) Idee,
(2) Definition,
(3) kurzer Begründungs-/Rechenweg,
(4) Mini-Beispiel.
Zitiere Quellen inline mit den eckigen Klammern, die im Kontext vorangestellt sind, z.B. [s2/ss1/c3 | definition | ...].
Wenn nichts zur Frage im Kontext steht, antworte mit "Dazu steht nichts im Material" und gib nichts weiter aus.
"""
class
ChatMessage
(
BaseModel
):
class
ChatMessage
(
BaseModel
):
role
:
str
=
Field
(...,
pattern
=
"^(user|assistant)$"
)
role
:
str
=
Field
(...,
pattern
=
"^(user|assistant)$"
)
...
@@ -42,7 +52,7 @@ def chat(request: ChatRequest) -> ChatResponse:
...
@@ -42,7 +52,7 @@ def chat(request: ChatRequest) -> ChatResponse:
reply
=
f
"Mock reply to:
{
last
.
text
}
"
reply
=
f
"Mock reply to:
{
last
.
text
}
"
return
ChatResponse
(
reply
=
reply
,
sources
=
[
"doc:example"
])
return
ChatResponse
(
reply
=
reply
,
sources
=
[
"doc:example"
])
messages_payload
=
[
messages_payload
=
[
{
"role"
:
"system"
,
"content"
:
SYSTEM_PROMPT
}]
+
[
{
"role"
:
message
.
role
,
"content"
:
message
.
text
}
{
"role"
:
message
.
role
,
"content"
:
message
.
text
}
for
message
in
request
.
messages
for
message
in
request
.
messages
]
]
...
...
math-tutor/frontend/src/pages/App.tsx
View file @
eaecc684
...
@@ -7,11 +7,10 @@ import type { ChatMessage } from "../components/Chat/MessageList";
...
@@ -7,11 +7,10 @@ import type { ChatMessage } from "../components/Chat/MessageList";
import
type
{
RetrievedDoc
}
from
"
../components/Retrieval/DocPanel
"
;
import
type
{
RetrievedDoc
}
from
"
../components/Retrieval/DocPanel
"
;
const
initialMessages
:
ChatMessage
[]
=
[
const
initialMessages
:
ChatMessage
[]
=
[
{
id
:
"
m1
"
,
role
:
"
user
"
,
text
:
"
How do I factor $x^2 - 5x + 6?$
"
},
{
{
id
:
"
m2
"
,
id
:
"
m2
"
,
role
:
"
assistant
"
,
role
:
"
assistant
"
,
text
:
"
We look for two numbers that multiply to 6 and add to -5.
"
,
text
:
"
How can I help you? $2+2=5$
"
,
},
},
];
];
...
@@ -50,7 +49,7 @@ export default function App() {
...
@@ -50,7 +49,7 @@ export default function App() {
headers
:
{
"
Content-Type
"
:
"
application/json
"
},
headers
:
{
"
Content-Type
"
:
"
application/json
"
},
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
query
:
trimmed
,
query
:
trimmed
,
k
:
8
,
k
:
4
,
expand_links
:
true
,
expand_links
:
true
,
}),
}),
}).
then
(
async
(
res
)
=>
{
}).
then
(
async
(
res
)
=>
{
...
...
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