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
aab2c5f0
Commit
aab2c5f0
authored
Feb 03, 2026
by
Kantz
Browse files
temperaturen hinzugefügt
parent
da60296c
Changes
3
Hide whitespace changes
Inline
Side-by-side
math-tutor/backend/.env-Example
View file @
aab2c5f0
...
@@ -4,11 +4,13 @@ MATHPIX_APP_KEY=""
...
@@ -4,11 +4,13 @@ MATHPIX_APP_KEY=""
OPENAI_BASE_URL=""
OPENAI_BASE_URL=""
OPENAI_API_KEY=""
OPENAI_API_KEY=""
OPENAI_CHAT_MODEL=""
OPENAI_CHAT_MODEL=""
OPENAI_CHAT_TEMPERATURE=""
OPENAI_EMBED_MODEL=""
OPENAI_EMBED_MODEL=""
POSTGRES_URL=""
POSTGRES_URL=""
OLLAMA_URL=""
OLLAMA_URL=""
OLLAMA_MODEL= ""
OLLAMA_MODEL= ""
OLLAMA_TEMPERATURE=""
FRONTEND_URL=""
FRONTEND_URL=""
\ No newline at end of file
math-tutor/backend/app/config.py
View file @
aab2c5f0
...
@@ -12,6 +12,7 @@ class OllamaSettings:
...
@@ -12,6 +12,7 @@ class OllamaSettings:
model
:
str
model
:
str
timeout
:
float
|
None
timeout
:
float
|
None
keepalive
:
str
|
None
keepalive
:
str
|
None
temperature
:
float
|
None
@
dataclass
(
frozen
=
True
)
@
dataclass
(
frozen
=
True
)
...
@@ -27,6 +28,7 @@ class OpenAIChatSettings:
...
@@ -27,6 +28,7 @@ class OpenAIChatSettings:
api_key
:
str
api_key
:
str
model
:
str
model
:
str
timeout
:
float
|
None
timeout
:
float
|
None
temperature
:
float
|
None
@
dataclass
(
frozen
=
True
)
@
dataclass
(
frozen
=
True
)
class
MathpixSettings
:
class
MathpixSettings
:
...
@@ -60,6 +62,7 @@ def get_ollama_settings() -> OllamaSettings:
...
@@ -60,6 +62,7 @@ def get_ollama_settings() -> OllamaSettings:
model
=
os
.
getenv
(
"OLLAMA_MODEL"
,
"qwen3"
),
model
=
os
.
getenv
(
"OLLAMA_MODEL"
,
"qwen3"
),
timeout
=
_read_float
(
os
.
getenv
(
"OLLAMA_TIMEOUT"
)),
timeout
=
_read_float
(
os
.
getenv
(
"OLLAMA_TIMEOUT"
)),
keepalive
=
os
.
getenv
(
"OLLAMA_KEEPALIVE"
),
keepalive
=
os
.
getenv
(
"OLLAMA_KEEPALIVE"
),
temperature
=
_read_float
(
os
.
getenv
(
"OLLAMA_TEMPERATURE"
)),
)
)
...
@@ -89,6 +92,7 @@ def get_openai_chat_settings() -> OpenAIChatSettings | None:
...
@@ -89,6 +92,7 @@ def get_openai_chat_settings() -> OpenAIChatSettings | None:
api_key
=
api_key
,
api_key
=
api_key
,
model
=
model
,
model
=
model
,
timeout
=
_read_float
(
os
.
getenv
(
"OPENAI_CHAT_TIMEOUT"
)),
timeout
=
_read_float
(
os
.
getenv
(
"OPENAI_CHAT_TIMEOUT"
)),
temperature
=
_read_float
(
os
.
getenv
(
"OPENAI_CHAT_TEMPERATURE"
)),
)
)
...
...
math-tutor/backend/app/deterministic_services/llm_client.py
View file @
aab2c5f0
...
@@ -21,10 +21,10 @@ def _chat_openai(messages: list[dict]) -> dict:
...
@@ -21,10 +21,10 @@ def _chat_openai(messages: list[dict]) -> dict:
timeout
=
settings
.
timeout
or
60.0
timeout
=
settings
.
timeout
or
60.0
client
=
OpenAI
(
api_key
=
settings
.
api_key
,
base_url
=
settings
.
base_url
,
timeout
=
timeout
)
client
=
OpenAI
(
api_key
=
settings
.
api_key
,
base_url
=
settings
.
base_url
,
timeout
=
timeout
)
response
=
client
.
chat
.
completions
.
create
(
kwargs
=
{
"messages"
:
messages
,
"model"
:
settings
.
model
}
messages
=
messages
,
if
settings
.
temperature
is
not
None
:
model
=
settings
.
model
,
kwargs
[
"temperature"
]
=
settings
.
temperature
)
response
=
client
.
chat
.
completions
.
create
(
**
kwargs
)
message
=
response
.
choices
[
0
].
message
if
response
.
choices
else
{}
message
=
response
.
choices
[
0
].
message
if
response
.
choices
else
{}
return
{
"raw"
:
response
,
"message"
:
message
}
return
{
"raw"
:
response
,
"message"
:
message
}
...
@@ -47,6 +47,8 @@ def chat(
...
@@ -47,6 +47,8 @@ def chat(
kwargs
[
"tools"
]
=
tools
kwargs
[
"tools"
]
=
tools
if
settings
.
keepalive
:
if
settings
.
keepalive
:
kwargs
[
"keep_alive"
]
=
settings
.
keepalive
kwargs
[
"keep_alive"
]
=
settings
.
keepalive
if
settings
.
temperature
is
not
None
:
kwargs
[
"options"
]
=
{
"temperature"
:
settings
.
temperature
}
response
=
client
.
chat
(
**
_filter_kwargs
(
client
.
chat
,
kwargs
))
response
=
client
.
chat
(
**
_filter_kwargs
(
client
.
chat
,
kwargs
))
return
{
"raw"
:
response
,
"message"
:
_extract_message
(
response
)}
return
{
"raw"
:
response
,
"message"
:
_extract_message
(
response
)}
...
...
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