Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
571 changes: 295 additions & 276 deletions README.md

Large diffs are not rendered by default.

7,128 changes: 3,564 additions & 3,564 deletions cypress/package-lock.json

Large diffs are not rendered by default.

764 changes: 382 additions & 382 deletions cypress/support/commands.js

Large diffs are not rendered by default.

6,932 changes: 3,466 additions & 3,466 deletions server/package-lock.json

Large diffs are not rendered by default.

1,447 changes: 724 additions & 723 deletions server/src/callbacks.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions server/src/getTreatments.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ function validatePromptString({ filename, promptString }) {
// Parse the prompt string into its sections

// TODO: this replicates client-side code - is there a way to refactor that makes sense?
const sectionRegex = /---\n/g;

// Checking if promptString is empty
if (promptString.trim().length < 1) {
error("Prompt file string is empty");
throw new Error (`Prompt file string is empty. This could be because the returned file has no contents, or because the file fetch failed.`);
}
const [, metaDataString, prompt, responseString] =
promptString.split(sectionRegex);
promptString.split(/^-{3,}$/gm);
const metaData = loadYaml(metaDataString);
const promptType = metaData?.type;
const validPromptTypes = [
Expand Down
21 changes: 17 additions & 4 deletions server/src/preFlight/preFlightChecks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export function checkRequiredEnvironmentVariables() {
const requiredEnvVars = [

const requiredInProd = [
"DAILY_APIKEY",
"QUALTRICS_API_TOKEN",
"QUALTRICS_DATACENTER",
"DELIBERATION_MACHINE_USER_TOKEN",
"DATA_DIR",
"GITHUB_PRIVATE_DATA_OWNER",
"GITHUB_PRIVATE_DATA_REPO",
"GITHUB_PRIVATE_DATA_BRANCH",
Expand All @@ -13,10 +13,23 @@ export function checkRequiredEnvironmentVariables() {
"GITHUB_PUBLIC_DATA_BRANCH",
"ETHERPAD_API_KEY",
"ETHERPAD_BASE_URL",
];
]

// TEST_CONTROLS === "enabled" allows for dev
if (process.env.TEST_CONTROLS !== "enabled") {
for (const envVar of requiredInProd) {
if (!process.env[envVar] || process.env[envVar] === "none") {
throw new Error(`Missing required environment variable ${envVar}`);
}
}
}

const requiredInDevAndProd = [
"DATA_DIR",
]

// eslint-disable-next-line no-restricted-syntax
for (const envVar of requiredEnvVars) {
for (const envVar of requiredInDevAndProd) {
if (!process.env[envVar]) {
throw new Error(`Missing required environment variable ${envVar}`);
}
Expand Down
Loading
Loading