Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitffb9f23

Browse files
authored
Refresh models (#1961)
* Add model refresh API and refactor model loadingIntroduces a POST /models/refresh endpoint for admins to trigger a model refresh and receive a summary of changes. Refactors model loading logic in models.ts to support dynamic refresh, exposes refreshModels and lastModelRefreshSummary, and adds a test script (test-refresh.mjs) to verify refresh functionality. Minor code cleanup and improved override handling included.* Delete test-refresh.mjs
1 parentd0827b7 commitffb9f23

File tree

3 files changed

+354
-178
lines changed

3 files changed

+354
-178
lines changed

‎src/lib/components/chat/ChatMessage.svelte‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
let editFormEl:HTMLFormElement|undefined=$state();
6969
7070
// Zero-config reasoning autodetection: detect <think> blocks in content
71-
const THINK_BLOCK_REGEX=/(<think>[\s\S]*?(?:<\/think>|$))/gi;
71+
const THINK_BLOCK_REGEX=/(<think>[\s\S]*?(?:<\/think>|$))/gi;
7272
let hasClientThink=$derived(message.content.split(THINK_BLOCK_REGEX).length>1);
7373
7474
// Strip think blocks for clipboard copy (always, regardless of detection)

‎src/lib/server/api/routes/groups/models.ts‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import{Elysia}from"elysia";
1+
import{Elysia,status}from"elysia";
2+
import{refreshModels,lastModelRefreshSummary}from"$lib/server/models";
23
importtype{BackendModel}from"$lib/server/models";
34
import{authPlugin}from"../../authPlugin";
45
import{authCondition}from"$lib/server/auth";
@@ -70,6 +71,42 @@ export const modelGroup = new Elysia().group("/models", (app) =>
7071
.get("/old",async()=>{
7172
return[]asGETOldModelsResponse;
7273
})
74+
.group("/refresh",(app)=>
75+
app.use(authPlugin).post("",async({ locals})=>{
76+
if(!locals.user&&!locals.sessionId){
77+
throwstatus(401,"Unauthorized");
78+
}
79+
if(!locals.isAdmin){
80+
throwstatus(403,"Admin privileges required");
81+
}
82+
83+
constprevious=lastModelRefreshSummary;
84+
85+
try{
86+
constsummary=awaitrefreshModels();
87+
88+
return{
89+
refreshedAt:summary.refreshedAt.toISOString(),
90+
durationMs:summary.durationMs,
91+
added:summary.added,
92+
removed:summary.removed,
93+
changed:summary.changed,
94+
total:summary.total,
95+
hadChanges:
96+
summary.added.length>0||summary.removed.length>0||summary.changed.length>0,
97+
previous:
98+
previous.refreshedAt.getTime()>0
99+
?{
100+
refreshedAt:previous.refreshedAt.toISOString(),
101+
total:previous.total,
102+
}
103+
:null,
104+
};
105+
}catch(err){
106+
throwstatus(502,"Model refresh failed");
107+
}
108+
})
109+
)
73110
.group("/:namespace/:model?",(app)=>
74111
app
75112
.derive(async({ params, error})=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp