Local models
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { join } from 'node:path';
|
||||
import { createRouter } from '../../create-router';
|
||||
import { DATA_PATH } from '../../data-path';
|
||||
import { syncLocalProvidersToPiConfig } from './sync-pi-config';
|
||||
|
||||
export const piMonoRouter = createRouter();
|
||||
|
||||
@@ -298,6 +299,10 @@ piMonoRouter.post('/local-providers', async (ctx) => {
|
||||
|
||||
providers.push(provider);
|
||||
await writeLocalProviders(providers);
|
||||
|
||||
// Sync to Pi config so Pi knows about this provider
|
||||
await syncLocalProvidersToPiConfig();
|
||||
|
||||
return ctx.json({ ...provider, auth: provider.auth ? { type: provider.auth.type } : undefined });
|
||||
});
|
||||
|
||||
@@ -307,6 +312,10 @@ piMonoRouter.delete('/local-providers/:id', async (ctx) => {
|
||||
const filtered = providers.filter((p) => p.id !== id);
|
||||
if (filtered.length === providers.length) return ctx.json({ error: 'Not found' }, 404);
|
||||
await writeLocalProviders(filtered);
|
||||
|
||||
// Sync to Pi config to remove this provider
|
||||
await syncLocalProvidersToPiConfig();
|
||||
|
||||
return ctx.json({ ok: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user