lots of changes on making new experiments work

This commit is contained in:
Kyle Corbitt
2023-06-26 18:03:26 -07:00
parent dbc61b8672
commit 0646fc0ba3
17 changed files with 544 additions and 188 deletions

View File

@@ -15,6 +15,8 @@ model Experiment {
id String @id @default(uuid()) @db.Uuid
label String
sortIndex Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
TemplateVariable TemplateVariable[]
@@ -33,7 +35,7 @@ model PromptVariant {
sortIndex Int @default(0)
experimentId String @db.Uuid
experiment Experiment @relation(fields: [experimentId], references: [id])
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -52,7 +54,7 @@ model TestScenario {
sortIndex Int @default(0)
experimentId String @db.Uuid
experiment Experiment @relation(fields: [experimentId], references: [id])
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -65,7 +67,7 @@ model TemplateVariable {
label String
experimentId String @db.Uuid
experiment Experiment @relation(fields: [experimentId], references: [id])
experiment Experiment @relation(fields: [experimentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -78,10 +80,10 @@ model ModelOutput {
output Json
promptVariantId String @db.Uuid
promptVariant PromptVariant @relation(fields: [promptVariantId], references: [id])
promptVariant PromptVariant @relation(fields: [promptVariantId], references: [id], onDelete: Cascade)
testScenarioId String @db.Uuid
testScenario TestScenario @relation(fields: [testScenarioId], references: [id])
testScenario TestScenario @relation(fields: [testScenarioId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

View File

@@ -1,14 +1,18 @@
import { prisma } from "~/server/db";
const experimentId = "11111111-1111-1111-1111-111111111111";
const experiment = await prisma.experiment.upsert({
// Delete the existing experiment
await prisma.experiment.delete({
where: {
id: experimentId,
},
update: {},
create: {
});
const experiment = await prisma.experiment.create({
data: {
id: experimentId,
label: "Quick Start",
label: "Country Capitals Example",
},
});
@@ -34,7 +38,7 @@ const resp = await prisma.promptVariant.createMany({
sortIndex: 0,
config: {
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "What is the capitol of {{state}}?" }],
messages: [{ role: "user", content: "What is the capital of {{country}}?" }],
temperature: 0,
},
},
@@ -44,7 +48,12 @@ const resp = await prisma.promptVariant.createMany({
sortIndex: 1,
config: {
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: "What is the capitol of the US state {{state}}?" }],
messages: [
{
role: "user",
content: "What is the capital of {{country}}? Only return the city name.",
},
],
temperature: 0,
},
},
@@ -61,7 +70,7 @@ await prisma.templateVariable.createMany({
data: [
{
experimentId,
label: "state",
label: "country",
},
],
});
@@ -78,21 +87,21 @@ await prisma.testScenario.createMany({
experimentId,
sortIndex: 0,
variableValues: {
state: "Washington",
country: "USA",
},
},
{
experimentId,
sortIndex: 1,
variableValues: {
state: "California",
country: "Spain",
},
},
{
experimentId,
sortIndex: 2,
variableValues: {
state: "Utah",
country: "Chile",
},
},
],