🔧 chore(frontend): format code with prettier
The changes in this commit are purely cosmetic, as the code has been formatted with prettier to improve its readability and consistency. No functional changes have been made.
This commit is contained in:
parent
38cc3af18d
commit
20a438428f
4 changed files with 66 additions and 54 deletions
|
|
@ -11,7 +11,13 @@ import {
|
||||||
ExclamationCircleIcon,
|
ExclamationCircleIcon,
|
||||||
} from "@heroicons/react/24/solid";
|
} from "@heroicons/react/24/solid";
|
||||||
|
|
||||||
import { classNames, nodeColors, nodeIcons, toNormalCase, toTitleCase } from "../../utils";
|
import {
|
||||||
|
classNames,
|
||||||
|
nodeColors,
|
||||||
|
nodeIcons,
|
||||||
|
toNormalCase,
|
||||||
|
toTitleCase,
|
||||||
|
} from "../../utils";
|
||||||
import ParameterComponent from "./components/parameterComponent";
|
import ParameterComponent from "./components/parameterComponent";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
import { useContext, useState, useEffect, useRef, Fragment } from "react";
|
import { useContext, useState, useEffect, useRef, Fragment } from "react";
|
||||||
|
|
@ -106,7 +112,7 @@ export default function GenericNode({
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Tooltip title={data.type} placement="top">
|
<Tooltip title={data.type} placement="top">
|
||||||
<div className="ml-2 truncate">{data.type}</div>
|
<div className="ml-2 truncate">{data.type}</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div>
|
<div>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default function PromptAreaModal({
|
||||||
setValue,
|
setValue,
|
||||||
buttonText,
|
buttonText,
|
||||||
modalTitle,
|
modalTitle,
|
||||||
type
|
type,
|
||||||
}: {
|
}: {
|
||||||
setValue: (value: string) => void;
|
setValue: (value: string) => void;
|
||||||
value: string;
|
value: string;
|
||||||
|
|
@ -121,39 +121,40 @@ export default function PromptAreaModal({
|
||||||
switch (myModalType) {
|
switch (myModalType) {
|
||||||
case 1:
|
case 1:
|
||||||
setModalOpen(false);
|
setModalOpen(false);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
checkPrompt(myValue)
|
checkPrompt(myValue)
|
||||||
.then((apiReturn) => {
|
.then((apiReturn) => {
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
let inputVariables =
|
let inputVariables =
|
||||||
apiReturn.data.input_variables;
|
apiReturn.data.input_variables;
|
||||||
if (inputVariables.length === 0) {
|
if (inputVariables.length === 0) {
|
||||||
|
setErrorData({
|
||||||
|
title:
|
||||||
|
"The template you are attempting to use does not contain any variables for data entry.",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setSuccessData({
|
||||||
|
title: "Prompt is ready",
|
||||||
|
});
|
||||||
|
setModalOpen(false);
|
||||||
|
setValue(myValue);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
setErrorData({
|
setErrorData({
|
||||||
title:
|
title:
|
||||||
"The template you are attempting to use does not contain any variables for data entry.",
|
"Something went wrong, please try again",
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
setSuccessData({
|
|
||||||
title: "Prompt is ready",
|
|
||||||
});
|
|
||||||
setModalOpen(false);
|
|
||||||
setValue(myValue);
|
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
setErrorData({
|
.catch((error) => {
|
||||||
title: "Something went wrong, please try again",
|
return setErrorData({
|
||||||
|
title:
|
||||||
|
"There is something wrong with this prompt, please review it",
|
||||||
|
list: [error.response.data.detail],
|
||||||
});
|
});
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
return setErrorData({
|
|
||||||
title:
|
|
||||||
"There is something wrong with this prompt, please review it",
|
|
||||||
list: [error.response.data.detail],
|
|
||||||
});
|
});
|
||||||
});
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export default function ExtraSidebar() {
|
||||||
{Object.keys(data[d])
|
{Object.keys(data[d])
|
||||||
.sort()
|
.sort()
|
||||||
.map((t: string, k) => (
|
.map((t: string, k) => (
|
||||||
<Tooltip title={t.length > 21 ? t : ''} placement="right">
|
<Tooltip title={t.length > 21 ? t : ""} placement="right">
|
||||||
<div key={k}>
|
<div key={k}>
|
||||||
<div
|
<div
|
||||||
draggable
|
draggable
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export function classNames(...classes: Array<string>) {
|
||||||
|
|
||||||
export enum TypeModal {
|
export enum TypeModal {
|
||||||
TEXT = 1,
|
TEXT = 1,
|
||||||
PROMPT = 2
|
PROMPT = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const textColors = {
|
export const textColors = {
|
||||||
|
|
@ -499,33 +499,38 @@ export const programmingLanguages: languageMap = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function toTitleCase(str: string) {
|
export function toTitleCase(str: string) {
|
||||||
let result = str
|
let result = str
|
||||||
.split("_")
|
.split("_")
|
||||||
.map((word, index) => {
|
.map((word, index) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
|
return checkUpperWords(
|
||||||
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return checkUpperWords(word.toLowerCase());
|
||||||
|
})
|
||||||
|
.join(" ");
|
||||||
|
|
||||||
return checkUpperWords(word[0].toUpperCase() + word.slice(1).toLowerCase());
|
return result
|
||||||
}
|
.split("-")
|
||||||
return checkUpperWords(word.toLowerCase());
|
.map((word, index) => {
|
||||||
})
|
if (index === 0) {
|
||||||
.join(" ");
|
return checkUpperWords(
|
||||||
|
word[0].toUpperCase() + word.slice(1).toLowerCase()
|
||||||
return result
|
);
|
||||||
.split("-")
|
}
|
||||||
.map((word, index) => {
|
return checkUpperWords(word.toLowerCase());
|
||||||
if (index === 0) {
|
})
|
||||||
return checkUpperWords(word[0].toUpperCase() + word.slice(1).toLowerCase());
|
.join(" ");
|
||||||
}
|
|
||||||
return checkUpperWords(word.toLowerCase());
|
|
||||||
})
|
|
||||||
.join(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const upperCaseWords: string[] = ["llm", "uri"];
|
export const upperCaseWords: string[] = ["llm", "uri"];
|
||||||
export function checkUpperWords(str: string) {
|
export function checkUpperWords(str: string) {
|
||||||
const words = str.split(' ').map((word) => {
|
const words = str.split(" ").map((word) => {
|
||||||
return upperCaseWords.includes(word.toLowerCase()) ? word.toUpperCase() : word[0].toUpperCase() + word.slice(1).toLowerCase();
|
return upperCaseWords.includes(word.toLowerCase())
|
||||||
|
? word.toUpperCase()
|
||||||
|
: word[0].toUpperCase() + word.slice(1).toLowerCase();
|
||||||
});
|
});
|
||||||
|
|
||||||
return words.join(' ');
|
return words.join(" ");
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue