feat(webui): add model settings runtime refresh
This commit is contained in:
+19
-1
@@ -1,4 +1,4 @@
|
||||
import type { ChatSummary } from "./types";
|
||||
import type { ChatSummary, SettingsPayload, SettingsUpdate } from "./types";
|
||||
|
||||
export class ApiError extends Error {
|
||||
status: number;
|
||||
@@ -104,3 +104,21 @@ export async function deleteSession(
|
||||
);
|
||||
return body.deleted;
|
||||
}
|
||||
|
||||
export async function fetchSettings(
|
||||
token: string,
|
||||
base: string = "",
|
||||
): Promise<SettingsPayload> {
|
||||
return request<SettingsPayload>(`${base}/api/settings`, token);
|
||||
}
|
||||
|
||||
export async function updateSettings(
|
||||
token: string,
|
||||
update: SettingsUpdate,
|
||||
base: string = "",
|
||||
): Promise<SettingsPayload> {
|
||||
const query = new URLSearchParams();
|
||||
if (update.model !== undefined) query.set("model", update.model);
|
||||
if (update.provider !== undefined) query.set("provider", update.provider);
|
||||
return request<SettingsPayload>(`${base}/api/settings/update?${query}`, token);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,28 @@ export interface BootstrapResponse {
|
||||
model_name?: string | null;
|
||||
}
|
||||
|
||||
export interface SettingsPayload {
|
||||
agent: {
|
||||
model: string;
|
||||
provider: string;
|
||||
resolved_provider: string | null;
|
||||
has_api_key: boolean;
|
||||
};
|
||||
providers: Array<{
|
||||
name: string;
|
||||
label: string;
|
||||
}>;
|
||||
runtime: {
|
||||
config_path: string;
|
||||
};
|
||||
requires_restart: boolean;
|
||||
}
|
||||
|
||||
export interface SettingsUpdate {
|
||||
model?: string;
|
||||
provider?: string;
|
||||
}
|
||||
|
||||
export type ConnectionStatus =
|
||||
| "idle"
|
||||
| "connecting"
|
||||
|
||||
Reference in New Issue
Block a user