1
0
Fork 0
polaris-task-force/src/migrations/20261019_121500_use_env_ai_model.ts
Z8MB1E 15e434998a feat(ai): configure Compose model and label via env
UNSLOTH_MODEL selects the model the Compose plugin calls, and the optional UNSLOTH_MODEL_NAME labels it in the admin (derived from the model id when omitted). The model-id select keeps its stable internal key, a Postgres enum, so switching models needs no schema change.

The seeded per-prompt model value is cleared so the env var applies; an admin can still pin a model on a single prompt row. Migration 20261019_121500_use_env_ai_model drops the column default and clears the seeded value.
2026-10-19 12:13:22 -04:00

25 lines
1.1 KiB
TypeScript

import { MigrateDownArgs, MigrateUpArgs, sql } from "@payloadcms/db-postgres";
/**
* The per-prompt model override no longer carries a hardcoded default. An empty
* value falls back to the UNSLOTH_MODEL environment variable at request time.
* Clear the previously seeded value so the env var takes effect; rows an admin
* deliberately set to a different model are left alone.
*/
export async function up({ db }: MigrateUpArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "plugin_ai_instructions" ALTER COLUMN "ornith_9b_settings_model" DROP DEFAULT;
UPDATE "plugin_ai_instructions"
SET "ornith_9b_settings_model" = NULL
WHERE "ornith_9b_settings_model" = 'unsloth/Ornith-1.0-9B-GGUF';
`);
}
export async function down({ db }: MigrateDownArgs): Promise<void> {
await db.execute(sql`
ALTER TABLE "plugin_ai_instructions" ALTER COLUMN "ornith_9b_settings_model" SET DEFAULT 'unsloth/Ornith-1.0-9B-GGUF';
UPDATE "plugin_ai_instructions"
SET "ornith_9b_settings_model" = 'unsloth/Ornith-1.0-9B-GGUF'
WHERE "ornith_9b_settings_model" IS NULL;
`);
}