attempt render deploy
This commit is contained in:
@@ -10,6 +10,10 @@ const config = {
|
|||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: path.join(__dirname, "tsconfig.json"),
|
project: path.join(__dirname, "tsconfig.json"),
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||||
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
parser: "@typescript-eslint/parser",
|
parser: "@typescript-eslint/parser",
|
||||||
@@ -27,8 +31,6 @@ const config = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
|
||||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
||||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
39
Dockerfile
Normal file
39
Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Adapted from https://create.t3.gg/en/deployment/docker#3-create-dockerfile
|
||||||
|
|
||||||
|
FROM node:20.1.0-bullseye as base
|
||||||
|
RUN yarn global add pnpm
|
||||||
|
|
||||||
|
# DEPS
|
||||||
|
FROM base as deps
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY prisma ./
|
||||||
|
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# BUILDER
|
||||||
|
FROM base as builder
|
||||||
|
|
||||||
|
# Include all NEXT_PUBLIC_* env vars here
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
RUN SKIP_ENV_VALIDATION=1 pnpm build
|
||||||
|
|
||||||
|
# RUNNER
|
||||||
|
FROM base as runner
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV production
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|
||||||
|
COPY --from=builder /app/ ./
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
ENV PORT 3000
|
||||||
|
|
||||||
|
# Run the "run-prod.sh" script
|
||||||
|
CMD /app/run-prod.sh
|
||||||
21
render.yaml
Normal file
21
render.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
databases:
|
||||||
|
- name: prompt-lab-prod
|
||||||
|
databaseName: prompt_lab_prod
|
||||||
|
user: prompt_lab
|
||||||
|
plan: starter
|
||||||
|
|
||||||
|
services:
|
||||||
|
- type: web
|
||||||
|
name: prompt-lab-prod-web
|
||||||
|
env: docker
|
||||||
|
dockerfilePath: Dockerfile
|
||||||
|
dockerContext: .
|
||||||
|
plan: standard
|
||||||
|
envVars:
|
||||||
|
- key: NODE_ENV
|
||||||
|
value: production
|
||||||
|
- key: DATABASE_URL
|
||||||
|
fromDatabase:
|
||||||
|
name: prompt-lab-prod
|
||||||
|
property: connectionString
|
||||||
|
- fromGroup: prompt-lab-prod
|
||||||
9
run-prod.sh
Executable file
9
run-prod.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Migrating the database"
|
||||||
|
pnpm prisma migrate deploy
|
||||||
|
|
||||||
|
echo "Starting the server"
|
||||||
|
pnpm start
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema";
|
import { openapiSchemaToJsonSchema } from "@openapi-contrib/openapi-schema-to-json-schema";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
|
import { AcceptibleInputSchema } from "@openapi-contrib/openapi-schema-to-json-schema/dist/mjs/openapi-schema-types";
|
||||||
|
|
||||||
const OPENAPI_URL =
|
const OPENAPI_URL =
|
||||||
"https://raw.githubusercontent.com/openai/openai-openapi/0c432eb66fd0c758fd8b9bd69db41c1096e5f4db/openapi.yaml";
|
"https://raw.githubusercontent.com/openai/openai-openapi/0c432eb66fd0c758fd8b9bd69db41c1096e5f4db/openapi.yaml";
|
||||||
@@ -13,7 +16,7 @@ const convertOpenApiToJsonSchema = async (url: string) => {
|
|||||||
const openApiYaml = await response.text();
|
const openApiYaml = await response.text();
|
||||||
|
|
||||||
// Parse the yaml document
|
// Parse the yaml document
|
||||||
const openApiDocument = YAML.parse(openApiYaml) as unknown;
|
const openApiDocument = YAML.parse(openApiYaml) as AcceptibleInputSchema;
|
||||||
|
|
||||||
// Convert the openapi schema to json schema
|
// Convert the openapi schema to json schema
|
||||||
const jsonSchema = openapiSchemaToJsonSchema(openApiDocument);
|
const jsonSchema = openapiSchemaToJsonSchema(openApiDocument);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export default function OutputCell({
|
|||||||
if (!output.data) return <CellShell>No output</CellShell>;
|
if (!output.data) return <CellShell>No output</CellShell>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// @ts-expect-error TODO proper typing and error checks
|
||||||
<CellShell>{JSON.stringify(output.data.output.choices[0].message.content, null, 2)}</CellShell>
|
<CellShell>{JSON.stringify(output.data.output.choices[0].message.content, null, 2)}</CellShell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import fillTemplate, { VariableMap } from "~/server/utils/fillTemplate";
|
|||||||
import { JSONSerializable } from "~/server/types";
|
import { JSONSerializable } from "~/server/types";
|
||||||
import { getChatCompletion } from "~/server/utils/openai";
|
import { getChatCompletion } from "~/server/utils/openai";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
import type { Prisma } from "@prisma/client";
|
||||||
|
|
||||||
export const modelOutputsRouter = createTRPCRouter({
|
export const modelOutputsRouter = createTRPCRouter({
|
||||||
get: publicProcedure
|
get: publicProcedure
|
||||||
@@ -62,7 +63,7 @@ export const modelOutputsRouter = createTRPCRouter({
|
|||||||
data: {
|
data: {
|
||||||
promptVariantId: input.variantId,
|
promptVariantId: input.variantId,
|
||||||
testScenarioId: input.scenarioId,
|
testScenarioId: input.scenarioId,
|
||||||
output: modelResponse,
|
output: modelResponse as Prisma.InputJsonObject,
|
||||||
inputHash,
|
inputHash,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user