Skip to content

Commit

Permalink
fix: use prisma generate --no-engine and reinstate prompts script (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl authored Oct 28, 2024
1 parent 2c66e48 commit a157b9a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"doppler:run:stg": "doppler run -c stg --silent",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo lint",
"prompts": "turbo prompts --filter=core",
"prompts:dev": "turbo prompts:dev --filter=core",
"prompts": "turbo prompts",
"prompts:dev": "turbo prompts:dev",
"sort-package-json": "sort-package-json \"package.json\" \"packages/*/package.json\" \"apps/*/package.json\"",
"type-check": "turbo type-check",
"node-version": "node -v",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"process:lessons": "pnpm doppler:run:dev -- ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"} ./src/scripts/processLessons.ts",
"process:lessons:dev": "pnpm doppler:run:dev -- pnpm process:lessons",
"prompts": "ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"} ./src/scripts/setupPrompts.ts",
"prompts:dev": "pnpm doppler:run:dev -- ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"} ./src/scripts/setupPrompts.ts",
"prompts:dev": "dotenv -e ../../.env -- ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"} ./src/scripts/setupPrompts.ts",
"seed": "ts-node --compiler-options {\\\"module\\\":\\\"CommonJS\\\"} ./src/scripts/seedLessons.ts",
"seed:dev": "pnpm doppler:run:dev -- pnpm seed",
"seed:dev": "dotenv -e ../../.env -- pnpm seed",
"seed:prd": "pnpm doppler:run:prd -- pnpm seed",
"seed:stg": "pnpm doppler:run:stg -- pnpm seed",
"type-check": "tsc --noEmit"
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/models/promptVariants.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PrismaClientWithAccelerate } from "@oakai/db";
import { aiLogger } from "@oakai/logger";
import dedent from "ts-dedent";
import { Md5 } from "ts-md5";

import errorHandling from "../prompts/shared/error-handling";
import promptInjection from "../prompts/shared/prompt-injection";
import { OakPromptDefinition, OakPromptVariant } from "../prompts/types";
import { aiLogger } from "@oakai/logger";

const log = aiLogger("prompts")
const log = aiLogger("prompts");

export class PromptVariants {
definition: OakPromptDefinition;
Expand Down
24 changes: 24 additions & 0 deletions packages/core/src/scripts/setupPrompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@ import { PromptVariants } from "../models/promptVariants";
import { lessonPlannerPrompts, quizGeneratorPrompts } from "../prompts";
import { ailaGenerate } from "../prompts/lesson-assistant/variants";

export const apps = [
{
name: "Quiz Generator",
slug: "quiz-generator",
id: "quiz-generator",
},
{
name: "Lesson planner",
slug: "lesson-planner",
id: "lesson-planner",
},
];

const main = async () => {
try {
// Ensure the apps exist in the database
await prisma.$transaction(
apps.map((app) =>
prisma.app.upsert({
where: { id: app.id },
create: app,
update: app,
}),
),
);

console.log("Setting up prompts");
console.log("Aila");
for (const variant of ailaGenerate.variants) {
Expand Down
4 changes: 2 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"db-export": "DB_ENV=dev doppler run --config dev -- bash scripts/import-export/db_export.sh",
"db-export:prd": "DB_ENV=prd doppler run --config prd -- bash scripts/import-export/db_export.sh",
"db-export:stg": "DB_ENV=stg doppler run --config stg -- bash scripts/import-export/db_export.sh",
"db-generate": "pnpm with-env prisma generate",
"db-generate:no-engine": "pnpm with-env prisma generate --no-engine",
"db-generate": "echo 'Running db-generate...' && pnpm with-env prisma generate --schema=./prisma/schema.prisma",
"db-generate:no-engine": "echo 'Running db-generate:no-engine...' && pnpm with-env prisma generate --no-engine --schema=./prisma/schema.prisma",
"db-generate:dev": "pnpm with-env prisma generate",
"db-migrate-deploy": "pnpm with-env prisma migrate deploy",
"db-migrate": "pnpm with-env prisma migrate dev",
Expand Down
20 changes: 19 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"ui": "tui",

"tasks": {
"db-generate:no-engine": {
"inputs": ["prisma/schema.prisma"],
"cache": false
},
"db-generate": {
"inputs": ["prisma/schema.prisma"],
"cache": false
Expand All @@ -21,9 +25,21 @@
"interactive": false,
"cache": false
},
"build:dev": {
"cache": true,
"dependsOn": ["^db-generate", "^prompts:dev"],
"outputs": [
".next/**",
"!.next/cache/**",
"apps/nextjs/.next/**",
"apps/openai/.next/**",
"!apps/nextjs/.next/cache/**",
"!apps/openai/.next/cache/**"
]
},
"build": {
"cache": true,
"dependsOn": ["^build", "^db-generate"],
"dependsOn": ["^db-generate:no-engine", "^prompts"],
"outputs": [
".next/**",
"!.next/cache/**",
Expand All @@ -43,9 +59,11 @@
"cache": false
},
"prompts": {
"dependsOn": ["^db-generate:no-engine"],
"cache": false
},
"prompts:dev": {
"dependsOn": ["^db-generate"],
"cache": false
},
"type-check": {
Expand Down

0 comments on commit a157b9a

Please sign in to comment.