Merge branch 'dev' of https://github.com/logspace-ai/langflow into dev
This commit is contained in:
commit
921fac3c95
4 changed files with 52 additions and 27 deletions
|
|
@ -5,6 +5,7 @@ import CodeAreaModal from "../../modals/codeAreaModal";
|
||||||
import TextAreaModal from "../../modals/textAreaModal";
|
import TextAreaModal from "../../modals/textAreaModal";
|
||||||
import { TextAreaComponentType } from "../../types/components";
|
import { TextAreaComponentType } from "../../types/components";
|
||||||
import GenericModal from "../../modals/genericModal";
|
import GenericModal from "../../modals/genericModal";
|
||||||
|
import { TypeModal } from "../../utils";
|
||||||
|
|
||||||
export default function PromptAreaComponent({
|
export default function PromptAreaComponent({
|
||||||
value,
|
value,
|
||||||
|
|
@ -30,6 +31,7 @@ export default function PromptAreaComponent({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<GenericModal
|
<GenericModal
|
||||||
|
type={TypeModal.PROMPT}
|
||||||
value={myValue}
|
value={myValue}
|
||||||
buttonText="Check & Save"
|
buttonText="Check & Save"
|
||||||
modalTitle="Edit Prompt"
|
modalTitle="Edit Prompt"
|
||||||
|
|
@ -51,6 +53,7 @@ export default function PromptAreaComponent({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<GenericModal
|
<GenericModal
|
||||||
|
type={TypeModal.PROMPT}
|
||||||
value={myValue}
|
value={myValue}
|
||||||
buttonText="Check & Save"
|
buttonText="Check & Save"
|
||||||
modalTitle="Edit Prompt"
|
modalTitle="Edit Prompt"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { useContext, useEffect, useState } from "react";
|
||||||
import { PopUpContext } from "../../contexts/popUpContext";
|
import { PopUpContext } from "../../contexts/popUpContext";
|
||||||
import { TextAreaComponentType } from "../../types/components";
|
import { TextAreaComponentType } from "../../types/components";
|
||||||
import GenericModal from "../../modals/genericModal";
|
import GenericModal from "../../modals/genericModal";
|
||||||
|
import { TypeModal } from "../../utils";
|
||||||
|
|
||||||
export default function TextAreaComponent({
|
export default function TextAreaComponent({
|
||||||
value,
|
value,
|
||||||
|
|
@ -24,6 +25,7 @@ export default function TextAreaComponent({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<GenericModal
|
<GenericModal
|
||||||
|
type={TypeModal.TEXT}
|
||||||
buttonText="Finishing Editing"
|
buttonText="Finishing Editing"
|
||||||
modalTitle="Edit Text"
|
modalTitle="Edit Text"
|
||||||
value={myValue}
|
value={myValue}
|
||||||
|
|
@ -45,6 +47,7 @@ export default function TextAreaComponent({
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openPopUp(
|
openPopUp(
|
||||||
<GenericModal
|
<GenericModal
|
||||||
|
type={TypeModal.TEXT}
|
||||||
buttonText="Finishing Editing"
|
buttonText="Finishing Editing"
|
||||||
modalTitle="Edit Text"
|
modalTitle="Edit Text"
|
||||||
value={myValue}
|
value={myValue}
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,23 @@ import { PopUpContext } from "../../contexts/popUpContext";
|
||||||
import { darkContext } from "../../contexts/darkContext";
|
import { darkContext } from "../../contexts/darkContext";
|
||||||
import { checkPrompt } from "../../controllers/API";
|
import { checkPrompt } from "../../controllers/API";
|
||||||
import { alertContext } from "../../contexts/alertContext";
|
import { alertContext } from "../../contexts/alertContext";
|
||||||
|
import { TypeModal } from "../../utils";
|
||||||
export default function PromptAreaModal({
|
export default function PromptAreaModal({
|
||||||
value,
|
value,
|
||||||
setValue,
|
setValue,
|
||||||
buttonText,
|
buttonText,
|
||||||
modalTitle,
|
modalTitle,
|
||||||
|
type
|
||||||
}: {
|
}: {
|
||||||
setValue: (value: string) => void;
|
setValue: (value: string) => void;
|
||||||
value: string;
|
value: string;
|
||||||
buttonText: string;
|
buttonText: string;
|
||||||
modalTitle: string;
|
modalTitle: string;
|
||||||
|
type: number;
|
||||||
}) {
|
}) {
|
||||||
const [myButtonText, setmyButtonText] = useState(buttonText);
|
const [myButtonText] = useState(buttonText);
|
||||||
const [myModalTitle, setMyModalTitle] = useState(modalTitle);
|
const [myModalTitle] = useState(modalTitle);
|
||||||
|
const [myModalType] = useState(type);
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
const [myValue, setMyValue] = useState(value);
|
const [myValue, setMyValue] = useState(value);
|
||||||
const { dark } = useContext(darkContext);
|
const { dark } = useContext(darkContext);
|
||||||
|
|
@ -114,36 +118,46 @@ export default function PromptAreaModal({
|
||||||
type="button"
|
type="button"
|
||||||
className="inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:ml-3 sm:w-auto sm:text-sm"
|
className="inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:ml-3 sm:w-auto sm:text-sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
checkPrompt(myValue)
|
switch (myModalType) {
|
||||||
.then((apiReturn) => {
|
case 1:
|
||||||
if (apiReturn.data) {
|
setModalOpen(false);
|
||||||
let inputVariables =
|
break;
|
||||||
apiReturn.data.input_variables;
|
case 2:
|
||||||
if (inputVariables.length === 0) {
|
checkPrompt(myValue)
|
||||||
setErrorData({
|
.then((apiReturn) => {
|
||||||
title:
|
if (apiReturn.data) {
|
||||||
"The template you are attempting to use does not contain any variables for data entry.",
|
let inputVariables =
|
||||||
});
|
apiReturn.data.input_variables;
|
||||||
|
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 {
|
} else {
|
||||||
setSuccessData({
|
setErrorData({
|
||||||
title: "Prompt is ready",
|
title: "Something went wrong, please try again",
|
||||||
});
|
});
|
||||||
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;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{myButtonText}
|
{myButtonText}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ export function classNames(...classes: Array<string>) {
|
||||||
return classes.filter(Boolean).join(" ");
|
return classes.filter(Boolean).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum TypeModal {
|
||||||
|
TEXT = 1,
|
||||||
|
PROMPT = 2
|
||||||
|
}
|
||||||
|
|
||||||
export const textColors = {
|
export const textColors = {
|
||||||
white: "text-white",
|
white: "text-white",
|
||||||
red: "text-red-700",
|
red: "text-red-700",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue