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
2bcba69b
Commit
2bcba69b
authored
Feb 10, 2026
by
Kantz
Browse files
weitere Überarbeitung des retrival, Ingest funktioniert jetzt wieder
parent
9af93f56
Changes
4
Hide whitespace changes
Inline
Side-by-side
math-tutor/README.md
View file @
2bcba69b
...
...
@@ -32,21 +32,21 @@ Init DB schema:
```
powershell
cd
math-tutor/backend
.
\.venv\Scripts\Activate.ps1
python
.
\
scripts
\
retrieval_cli
.py
init-db
python
-m
scripts
.
retrieval_cli
init-db
```
Ingest markdown docs (expects
`markdown/sections`
,
`markdown/subsections`
,
`markdown/childs`
):
```
powershell
cd
math-tutor/backend
.
\.venv\Scripts\Activate.ps1
python
.
\
scripts
\
retrieval_cli
.py
ingest
--base
markdown
--clear
python
-m
scripts
.
retrieval_cli
ingest
--base
markdown
--clear
```
Query via CLI:
```
powershell
cd
math-tutor/backend
.
\.venv\Scripts\Activate.ps1
python
.
\
scripts
\
retrieval_cli
.py
query
--q
"Was ist eine Teilmenge?"
--k
8
--expand
python
-m
scripts
.
retrieval_cli
query
--q
"Was ist eine Teilmenge?"
--k
8
--expand
```
## Configuration
...
...
math-tutor/backend/app/config.py
View file @
2bcba69b
...
...
@@ -91,20 +91,6 @@ def get_ollama_settings() -> OllamaSettings:
temperature
=
_read_float
(
os
.
getenv
(
"OLLAMA_TEMPERATURE"
)),
)
def
get_embedding_settings
()
->
EmbeddingSettings
:
base_url
=
os
.
getenv
(
"OPENAI_BASE_URL"
)
api_key
=
os
.
getenv
(
"OPENAI_API_KEY"
)
model
=
os
.
getenv
(
"OPENAI_EMBED_MODEL"
,
"text-embedding-3-large"
)
if
not
base_url
or
not
api_key
:
raise
ValueError
(
"Missing OPENAI_BASE_URL or OPENAI_API_KEY"
)
return
EmbeddingSettings
(
base_url
=
base_url
,
api_key
=
api_key
,
model
=
model
,
target_dim
=
1024
,
)
def
get_openai_chat_settings
()
->
OpenAIChatSettings
|
None
:
model
=
os
.
getenv
(
"OPENAI_CHAT_MODEL"
)
if
not
model
:
...
...
math-tutor/backend/app/deterministic_services/embeddings.py
View file @
2bcba69b
...
...
@@ -186,8 +186,8 @@ class EmbeddingFactory:
ValueError: Wenn der Typ nicht unterstützt wird.
"""
if
config
.
embedding_type
==
EmbeddingType
.
OPENAI_LIKE
:
return
OpenAILikeEmbeddings
(
config
=
config
.
config
)
return
OpenAILikeEmbeddings
(
config
=
config
)
elif
config
.
embedding_type
==
EmbeddingType
.
SENTENCE_TRANSFORMER
:
return
SentenceTransformerEmbeddings
(
config
=
config
.
config
)
return
SentenceTransformerEmbeddings
(
config
=
config
)
else
:
raise
ValueError
(
f
"Unsupported embedding type:
{
config
.
embedding_type
}
"
)
\ No newline at end of file
math-tutor/backend/scripts/retrieval_cli.py
View file @
2bcba69b
...
...
@@ -59,24 +59,10 @@ def cli_query(args: argparse.Namespace) -> None:
expand_links
=
args
.
expand
,
section_index
=
args
.
section_index
,
subsection_index
=
args
.
subsection_index
,
type_filter
=
args
.
type_filter
,
source_
type_filter
=
args
.
source_
type_filter
,
)
print
(
"=== SECTIONS ==="
)
for
item
in
result
[
"sections"
]:
meta
=
item
.
metadata
print
(
f
"- [
{
item
.
score
:
.
3
f
}
] s
{
meta
.
get
(
'section_index'
)
}
{
meta
.
get
(
'title'
)
or
meta
.
get
(
'section_title'
)
}
"
)
print
(
"=== SUBSECTIONS ==="
)
for
item
in
result
[
"subsections"
]:
meta
=
item
.
metadata
print
(
f
"- [
{
item
.
score
:
.
3
f
}
] s
{
meta
.
get
(
'section_index'
)
}
, ss
{
meta
.
get
(
'subsection_index'
)
}
{
meta
.
get
(
'title'
)
}
"
)
print
(
"=== CHILDREN ==="
)
for
item
in
result
[
"children"
]:
meta
=
item
.
metadata
print
(
f
"- [
{
item
.
score
:
.
3
f
}
] s
{
meta
.
get
(
'section_index'
)
}
, ss
{
meta
.
get
(
'subsection_index'
)
}
, c
{
meta
.
get
(
'child_index'
)
}
"
)
for
item
in
result
:
print
(
f
"- [
{
item
.
score
:
.
3
f
}
]
{
item
.
source_id
.
title
}
(
{
item
.
source_type
}
)"
)
def
main
()
->
int
:
...
...
@@ -101,7 +87,7 @@ def main() -> int:
ap_q
.
add_argument
(
"--expand"
,
action
=
"store_true"
)
ap_q
.
add_argument
(
"--section-index"
,
type
=
int
,
default
=
None
)
ap_q
.
add_argument
(
"--subsection-index"
,
type
=
int
,
default
=
None
)
ap_q
.
add_argument
(
"--type
-
filter"
,
nargs
=
"*"
,
default
=
None
)
ap_q
.
add_argument
(
"--
source_
type
_
filter"
,
nargs
=
"*"
,
default
=
None
)
ap_q
.
set_defaults
(
func
=
cli_query
)
args
=
parser
.
parse_args
()
...
...
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