Commit eaecc684 authored by Kantz's avatar Kantz
Browse files

Konfigurierung des Modells

parent e6256e64
......@@ -48,3 +48,16 @@ cd math-tutor/backend
.\.venv\Scripts\Activate.ps1
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`).
......@@ -16,6 +16,16 @@ OPENAI_BASE_URL = os.getenv("OPENAI_BASE_URL")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
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):
role: str = Field(..., pattern="^(user|assistant)$")
......@@ -42,7 +52,7 @@ def chat(request: ChatRequest) -> ChatResponse:
reply = f"Mock reply to: {last.text}"
return ChatResponse(reply=reply, sources=["doc:example"])
messages_payload = [
messages_payload = [{"role": "system", "content": SYSTEM_PROMPT}] + [
{"role": message.role, "content": message.text}
for message in request.messages
]
......
......@@ -7,11 +7,10 @@ import type { ChatMessage } from "../components/Chat/MessageList";
import type { RetrievedDoc } from "../components/Retrieval/DocPanel";
const initialMessages: ChatMessage[] = [
{ id: "m1", role: "user", text: "How do I factor $x^2 - 5x + 6?$" },
{
id: "m2",
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() {
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: trimmed,
k: 8,
k: 4,
expand_links: true,
}),
}).then(async (res) => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment