Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coderai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
coderai
Commits
f31e99bd
Commit
f31e99bd
authored
May 06, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: remove legacy whisper-server settings flow
parent
7f1a84e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
76 deletions
+113
-76
routes.py
codai/admin/routes.py
+0
-9
config.py
codai/config.py
+1
-5
test_whisper_server_local_models.py
tests/test_whisper_server_local_models.py
+112
-62
No files found.
codai/admin/routes.py
View file @
f31e99bd
...
@@ -1357,10 +1357,6 @@ async def api_get_settings(username: str = Depends(require_admin)):
...
@@ -1357,10 +1357,6 @@ async def api_get_settings(username: str = Depends(require_admin)):
"device_id"
:
c
.
vulkan
.
device_id
,
"device_id"
:
c
.
vulkan
.
device_id
,
"single_gpu"
:
c
.
vulkan
.
single_gpu
,
"single_gpu"
:
c
.
vulkan
.
single_gpu
,
},
},
"whisper"
:
{
"server_path"
:
c
.
whisper
.
server_path
,
"server_port"
:
c
.
whisper
.
server_port
,
},
"system_prompt"
:
c
.
system_prompt
,
"system_prompt"
:
c
.
system_prompt
,
"tools_closer_prompt"
:
c
.
tools_closer_prompt
,
"tools_closer_prompt"
:
c
.
tools_closer_prompt
,
"grammar_guided"
:
c
.
grammar_guided
,
"grammar_guided"
:
c
.
grammar_guided
,
...
@@ -1420,11 +1416,6 @@ async def api_save_settings(request: Request, username: str = Depends(require_ad
...
@@ -1420,11 +1416,6 @@ async def api_save_settings(request: Request, username: str = Depends(require_ad
c
.
vulkan
.
device_id
=
int
(
vk
.
get
(
"device_id"
,
c
.
vulkan
.
device_id
))
c
.
vulkan
.
device_id
=
int
(
vk
.
get
(
"device_id"
,
c
.
vulkan
.
device_id
))
c
.
vulkan
.
single_gpu
=
bool
(
vk
.
get
(
"single_gpu"
,
c
.
vulkan
.
single_gpu
))
c
.
vulkan
.
single_gpu
=
bool
(
vk
.
get
(
"single_gpu"
,
c
.
vulkan
.
single_gpu
))
if
"whisper"
in
data
:
wh
=
data
[
"whisper"
]
c
.
whisper
.
server_path
=
wh
.
get
(
"server_path"
)
or
None
c
.
whisper
.
server_port
=
int
(
wh
.
get
(
"server_port"
,
c
.
whisper
.
server_port
))
if
"system_prompt"
in
data
:
if
"system_prompt"
in
data
:
c
.
system_prompt
=
data
[
"system_prompt"
]
or
None
c
.
system_prompt
=
data
[
"system_prompt"
]
or
None
if
"tools_closer_prompt"
in
data
:
if
"tools_closer_prompt"
in
data
:
...
...
codai/config.py
View file @
f31e99bd
...
@@ -341,10 +341,6 @@ class ConfigManager:
...
@@ -341,10 +341,6 @@ class ConfigManager:
"vae_tiling"
:
self
.
config
.
image
.
vae_tiling
,
"vae_tiling"
:
self
.
config
.
image
.
vae_tiling
,
"clip_on_cpu"
:
self
.
config
.
image
.
clip_on_cpu
"clip_on_cpu"
:
self
.
config
.
image
.
clip_on_cpu
},
},
"whisper"
:
{
"server_path"
:
self
.
config
.
whisper
.
server_path
,
"server_port"
:
self
.
config
.
whisper
.
server_port
},
"system_prompt"
:
self
.
config
.
system_prompt
,
"system_prompt"
:
self
.
config
.
system_prompt
,
"tools_closer_prompt"
:
self
.
config
.
tools_closer_prompt
,
"tools_closer_prompt"
:
self
.
config
.
tools_closer_prompt
,
"grammar_guided"
:
self
.
config
.
grammar_guided
,
"grammar_guided"
:
self
.
config
.
grammar_guided
,
...
@@ -369,4 +365,4 @@ class ConfigManager:
...
@@ -369,4 +365,4 @@ class ConfigManager:
def
reload
(
self
):
def
reload
(
self
):
"""Reload all configuration files."""
"""Reload all configuration files."""
return
self
.
load
()
return
self
.
load
()
\ No newline at end of file
tests/test_whisper_server_local_models.py
View file @
f31e99bd
from
pathlib
import
Path
from
types
import
SimpleNamespace
from
types
import
SimpleNamespace
import
pytest
from
fastapi
import
HTTPException
from
fastapi.testclient
import
TestClient
from
fastapi.testclient
import
TestClient
def
test_model_configure_persists_whisper_server_audio_model
(
monkeypatch
,
tmp_path
):
def
_base_models_data
():
from
codai.admin
import
routes
return
{
from
codai.api.app
import
app
"text_models"
:
[],
"image_models"
:
[],
"audio_models"
:
[],
"vision_models"
:
[],
"tts_models"
:
[],
"gguf_models"
:
[],
"video_models"
:
[],
"audio_gen_models"
:
[],
"embedding_models"
:
[],
"aliases"
:
{},
}
def
_build_config
(
tmp_path
):
from
codai.config
import
(
from
codai.config
import
(
BackendConfig
,
BackendConfig
,
Config
,
Config
,
...
@@ -19,18 +35,7 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
...
@@ -19,18 +35,7 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
)
)
cfg
=
ConfigManager
(
str
(
tmp_path
))
cfg
=
ConfigManager
(
str
(
tmp_path
))
cfg
.
models_data
=
{
cfg
.
models_data
=
_base_models_data
()
"text_models"
:
[],
"image_models"
:
[],
"audio_models"
:
[],
"vision_models"
:
[],
"tts_models"
:
[],
"gguf_models"
:
[],
"video_models"
:
[],
"audio_gen_models"
:
[],
"embedding_models"
:
[],
"aliases"
:
{},
}
cfg
.
config
=
Config
(
cfg
.
config
=
Config
(
version
=
"1.0"
,
version
=
"1.0"
,
server
=
ServerConfig
(),
server
=
ServerConfig
(),
...
@@ -41,6 +46,14 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
...
@@ -41,6 +46,14 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
image
=
ImageConfig
(),
image
=
ImageConfig
(),
whisper
=
WhisperConfig
(),
whisper
=
WhisperConfig
(),
)
)
return
cfg
def
test_model_configure_persists_whisper_server_audio_model
(
monkeypatch
,
tmp_path
):
from
codai.admin
import
routes
from
codai.api.app
import
app
cfg
=
_build_config
(
tmp_path
)
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
cfg
,
raising
=
False
)
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
cfg
,
raising
=
False
)
app
.
dependency_overrides
[
routes
.
require_admin
]
=
lambda
:
"admin"
app
.
dependency_overrides
[
routes
.
require_admin
]
=
lambda
:
"admin"
...
@@ -82,51 +95,19 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
...
@@ -82,51 +95,19 @@ def test_model_configure_persists_whisper_server_audio_model(monkeypatch, tmp_pa
def
test_model_configure_rejects_duplicate_whisper_server_model_id
(
monkeypatch
,
tmp_path
):
def
test_model_configure_rejects_duplicate_whisper_server_model_id
(
monkeypatch
,
tmp_path
):
from
codai.admin
import
routes
from
codai.admin
import
routes
from
codai.api.app
import
app
from
codai.api.app
import
app
from
codai.config
import
(
BackendConfig
,
Config
,
ConfigManager
,
ImageConfig
,
ModelsConfig
,
OffloadConfig
,
ServerConfig
,
VulkanConfig
,
WhisperConfig
,
)
cfg
=
ConfigManager
(
str
(
tmp_path
))
cfg
=
_build_config
(
tmp_path
)
cfg
.
models_data
=
{
cfg
.
models_data
[
"audio_models"
]
=
[
"text_models"
:
[],
{
"image_models"
:
[],
"id"
:
"whisper-vulkan-base"
,
"audio_models"
:
[
"backend"
:
"whisper-server"
,
{
"server_path"
:
"/usr/local/bin/whisper-server"
,
"id"
:
"whisper-vulkan-base"
,
"model_path"
:
"/models/ggml-base.bin"
,
"backend"
:
"whisper-server"
,
"port"
:
8744
,
"server_path"
:
"/usr/local/bin/whisper-server"
,
"gpu_device"
:
0
,
"model_path"
:
"/models/ggml-base.bin"
,
"load_mode"
:
"on-request"
,
"port"
:
8744
,
}
"gpu_device"
:
0
,
]
"load_mode"
:
"on-request"
,
}
],
"vision_models"
:
[],
"tts_models"
:
[],
"gguf_models"
:
[],
"video_models"
:
[],
"audio_gen_models"
:
[],
"embedding_models"
:
[],
"aliases"
:
{},
}
cfg
.
config
=
Config
(
version
=
"1.0"
,
server
=
ServerConfig
(),
backend
=
BackendConfig
(),
models
=
ModelsConfig
(),
offload
=
OffloadConfig
(),
vulkan
=
VulkanConfig
(),
image
=
ImageConfig
(),
whisper
=
WhisperConfig
(),
)
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
cfg
,
raising
=
False
)
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
cfg
,
raising
=
False
)
app
.
dependency_overrides
[
routes
.
require_admin
]
=
lambda
:
"admin"
app
.
dependency_overrides
[
routes
.
require_admin
]
=
lambda
:
"admin"
...
@@ -209,9 +190,6 @@ def test_model_load_and_unload_manage_whisper_server_runtime(monkeypatch):
...
@@ -209,9 +190,6 @@ def test_model_load_and_unload_manage_whisper_server_runtime(monkeypatch):
def
test_transcription_requires_configured_whisper_server_model_id
():
def
test_transcription_requires_configured_whisper_server_model_id
():
import
asyncio
import
asyncio
import
pytest
from
fastapi
import
HTTPException
from
codai.api
import
transcriptions
from
codai.api
import
transcriptions
from
codai.models.manager
import
multi_model_manager
from
codai.models.manager
import
multi_model_manager
...
@@ -240,3 +218,75 @@ def test_transcription_requires_configured_whisper_server_model_id():
...
@@ -240,3 +218,75 @@ def test_transcription_requires_configured_whisper_server_model_id():
assert
exc
.
value
.
status_code
in
{
400
,
404
}
assert
exc
.
value
.
status_code
in
{
400
,
404
}
assert
"not configured"
in
str
(
exc
.
value
.
detail
)
.
lower
()
or
"not available"
in
str
(
exc
.
value
.
detail
)
.
lower
()
assert
"not configured"
in
str
(
exc
.
value
.
detail
)
.
lower
()
or
"not available"
in
str
(
exc
.
value
.
detail
)
.
lower
()
def
test_get_all_allowed_identifiers_includes_configured_whisper_server_id_without_legacy_alias
(
monkeypatch
):
from
codai.admin
import
routes
from
codai.models.manager
import
MultiModelManager
manager
=
MultiModelManager
()
manager
.
audio_models
[:]
=
[
"whisper-vulkan-base"
]
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
SimpleNamespace
(
models_data
=
{
"text_models"
:
[],
"image_models"
:
[],
"audio_models"
:
[{
"id"
:
"whisper-vulkan-base"
,
"backend"
:
"whisper-server"
}],
"vision_models"
:
[],
"tts_models"
:
[],
"gguf_models"
:
[],
"video_models"
:
[],
"audio_gen_models"
:
[],
"embedding_models"
:
[],
"aliases"
:
{},
}
),
raising
=
False
,
)
allowed
=
manager
.
get_all_allowed_identifiers
()
assert
"whisper-vulkan-base"
in
allowed
assert
"audio:whisper-vulkan-base"
in
allowed
assert
"whisper-server"
not
in
allowed
def
test_main_startup_registration_code_uses_entry_local_whisper_server_settings
():
content
=
Path
(
"codai/main.py"
)
.
read_text
()
assert
'm.get("backend") == "whisper-server"'
in
content
assert
'server_path=m.get("server_path", "")'
in
content
assert
'port=int(m.get("port", 8744))'
in
content
assert
'gpu_device=int(m.get("gpu_device", 0))'
in
content
assert
'config.whisper.server_path'
not
in
content
[
content
.
index
(
'audio_models = models_config.get("audio_models", [])'
):
content
.
index
(
'# Image models'
)]
def
test_settings_api_does_not_return_whisper_fields
(
monkeypatch
):
from
codai.admin
import
routes
from
codai.api.app
import
app
from
codai.config
import
Config
,
ServerConfig
,
BackendConfig
,
ModelsConfig
,
OffloadConfig
,
VulkanConfig
,
ImageConfig
,
WhisperConfig
cfg
=
SimpleNamespace
(
config
=
Config
(
version
=
"1.0"
,
server
=
ServerConfig
(),
backend
=
BackendConfig
(),
models
=
ModelsConfig
(),
offload
=
OffloadConfig
(),
vulkan
=
VulkanConfig
(),
image
=
ImageConfig
(),
whisper
=
WhisperConfig
(
server_path
=
"/usr/local/bin/whisper-server"
,
server_port
=
8744
),
)
)
monkeypatch
.
setattr
(
routes
,
"config_manager"
,
cfg
,
raising
=
False
)
app
.
dependency_overrides
[
routes
.
require_admin
]
=
lambda
:
"admin"
client
=
TestClient
(
app
)
response
=
client
.
get
(
"/admin/api/settings"
)
assert
response
.
status_code
==
200
assert
"whisper"
not
in
response
.
json
()
app
.
dependency_overrides
.
clear
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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