Remove unused fields, refine model translation (#62)
* Remove unused ScenarioVariantCell fields * Refine deriveNewConstructFn * Fix prettier
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `completionTokens` on the `ScenarioVariantCell` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `inputHash` on the `ScenarioVariantCell` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `output` on the `ScenarioVariantCell` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `promptTokens` on the `ScenarioVariantCell` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `timeToComplete` on the `ScenarioVariantCell` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "ScenarioVariantCell" DROP COLUMN "completionTokens",
|
||||
DROP COLUMN "inputHash",
|
||||
DROP COLUMN "output",
|
||||
DROP COLUMN "promptTokens",
|
||||
DROP COLUMN "timeToComplete";
|
||||
@@ -88,17 +88,12 @@ enum CellRetrievalStatus {
|
||||
model ScenarioVariantCell {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
|
||||
inputHash String? // TODO: Remove once migration is complete
|
||||
output Json? // TODO: Remove once migration is complete
|
||||
statusCode Int?
|
||||
errorMessage String?
|
||||
timeToComplete Int? @default(0) // TODO: Remove once migration is complete
|
||||
retryTime DateTime?
|
||||
streamingChannel String?
|
||||
retrievalStatus CellRetrievalStatus @default(COMPLETE)
|
||||
|
||||
promptTokens Int? // TODO: Remove once migration is complete
|
||||
completionTokens Int? // TODO: Remove once migration is complete
|
||||
modelOutput ModelOutput?
|
||||
|
||||
promptVariantId String @db.Uuid
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import { type Prisma } from "@prisma/client";
|
||||
import { prisma } from "../db";
|
||||
|
||||
async function migrateScenarioVariantOutputData() {
|
||||
// Get all ScenarioVariantCells
|
||||
const cells = await prisma.scenarioVariantCell.findMany({ include: { modelOutput: true } });
|
||||
console.log(`Found ${cells.length} records`);
|
||||
|
||||
let updatedCount = 0;
|
||||
|
||||
// Loop through all scenarioVariants
|
||||
for (const cell of cells) {
|
||||
// Create a new ModelOutput for each ScenarioVariant with an existing output
|
||||
if (cell.output && !cell.modelOutput) {
|
||||
updatedCount++;
|
||||
await prisma.modelOutput.create({
|
||||
data: {
|
||||
scenarioVariantCellId: cell.id,
|
||||
inputHash: cell.inputHash || "",
|
||||
output: cell.output as Prisma.InputJsonValue,
|
||||
timeToComplete: cell.timeToComplete ?? undefined,
|
||||
promptTokens: cell.promptTokens,
|
||||
completionTokens: cell.completionTokens,
|
||||
createdAt: cell.createdAt,
|
||||
updatedAt: cell.updatedAt,
|
||||
},
|
||||
});
|
||||
} else if (cell.errorMessage && cell.retrievalStatus === "COMPLETE") {
|
||||
updatedCount++;
|
||||
await prisma.scenarioVariantCell.update({
|
||||
where: { id: cell.id },
|
||||
data: {
|
||||
retrievalStatus: "ERROR",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Data migration completed");
|
||||
console.log(`Updated ${updatedCount} records`);
|
||||
}
|
||||
|
||||
// Execute the function
|
||||
migrateScenarioVariantOutputData().catch((error) => {
|
||||
console.error("An error occurred while migrating data: ", error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -49,12 +49,16 @@ const getPromptFunctionForNewModel = async (
|
||||
getApiShapeForModel(originalModel),
|
||||
null,
|
||||
2,
|
||||
)}\n\nThe prompt variable has already been declared.}`,
|
||||
)}`,
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: `Return the prompt constructor function for ${newModel} given the following prompt constructor function for ${originalModel}:\n---\n${originalVariant.constructFn}`,
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: "The prompt variable has already been declared, so do not declare it again.",
|
||||
},
|
||||
],
|
||||
functions: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user