feat: admin controls
This commit is contained in:
@@ -134,7 +134,7 @@ export const useModels = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
const updateProvider = async (id: string, updates: Partial<Provider>) => {
|
||||
const updateProvider = async (id: string, updates: Partial<Provider>, expectedUpdatedAt?: string) => {
|
||||
const provider = providers.value.find(p => p.id === id);
|
||||
if (!provider) return;
|
||||
|
||||
@@ -142,10 +142,14 @@ export const useModels = async () => {
|
||||
|
||||
await $fetch(`/api/provider/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: updates,
|
||||
body: {
|
||||
...updates,
|
||||
expectedUpdatedAt: expectedUpdatedAt ?? new Date(original.updatedAt).toISOString(),
|
||||
},
|
||||
onRequest() {
|
||||
// a config update only carries the fields that changed
|
||||
providers.value = providers.value.map(p =>
|
||||
p.id === id ? { ...p, ...updates } : p
|
||||
p.id === id ? { ...p, ...updates, config: { ...p.config, ...updates.config } } : p
|
||||
);
|
||||
},
|
||||
onRequestError() {
|
||||
@@ -166,6 +170,7 @@ export const useModels = async () => {
|
||||
|
||||
return {
|
||||
providers,
|
||||
refresh,
|
||||
allModels,
|
||||
getModel,
|
||||
getProvider,
|
||||
|
||||
Reference in New Issue
Block a user