Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
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
aisbf
Commits
724a89dc
Commit
724a89dc
authored
May 19, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coderai model refresh on reconnect
parent
fd742959
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
model_cache.py
aisbf/app/model_cache.py
+11
-0
coderai_broker.py
aisbf/routes/coderai_broker.py
+4
-1
No files found.
aisbf/app/model_cache.py
View file @
724a89dc
...
...
@@ -61,6 +61,17 @@ def _get_cached_provider_models(cache_key: str) -> Optional[list]:
return
_model_cache
.
get
(
cache_key
)
def
invalidate_provider_cache
(
provider_id
:
str
,
user_id
:
Optional
[
int
]
=
None
)
->
None
:
"""Drop cached model data for a provider so the next fetch hits the live source."""
cache_key
=
_cache_key_for_provider
(
provider_id
,
user_id
)
_model_cache
.
pop
(
cache_key
,
None
)
_model_cache_timestamps
.
pop
(
cache_key
,
None
)
# Also drop the endpoint-level cache so a different user_id doesn't serve stale data
for
key
in
list
(
_endpoint_model_cache
.
keys
()):
if
key
.
startswith
(
f
"coderai:"
)
or
provider_id
in
key
:
_endpoint_model_cache
.
pop
(
key
,
None
)
def
_store_provider_models_in_cache
(
cache_key
:
str
,
models
:
list
,
cached_at
:
Optional
[
float
]
=
None
)
->
float
:
now
=
cached_at
if
cached_at
is
not
None
else
time
.
time
()
_model_cache
[
cache_key
]
=
models
...
...
aisbf/routes/coderai_broker.py
View file @
724a89dc
...
...
@@ -21,8 +21,11 @@ logger = logging.getLogger(__name__)
async
def
_broker_refresh_models
(
provider_id
:
str
,
user_id
:
Optional
[
int
])
->
None
:
"""Fetch and cache the model list for a provider that just connected via broker."""
try
:
from
aisbf.app.model_cache
import
fetch_provider_models
from
aisbf.app.model_cache
import
fetch_provider_models
,
invalidate_provider_cache
from
aisbf.config
import
config
as
aisbf_config
# Always bypass the cache so a reconnect or re-register produces a live fetch,
# not a 24-hour stale snapshot.
invalidate_provider_cache
(
provider_id
,
user_id
)
models
=
await
fetch_provider_models
(
provider_id
,
aisbf_config
,
user_id
=
user_id
)
logger
.
info
(
"CoderAI broker model refresh: provider=
%
s user=
%
s models=
%
d"
,
...
...
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