Fix formatting issues in code
This commit is contained in:
parent
5e5a64872c
commit
65ec1ab3a5
21 changed files with 841 additions and 859 deletions
|
|
@ -67,7 +67,9 @@ Human: {input}
|
||||||
class MidJourneyPromptChain(BaseCustomConversationChain):
|
class MidJourneyPromptChain(BaseCustomConversationChain):
|
||||||
"""MidJourneyPromptChain is a chain you can use to generate new MidJourney prompts."""
|
"""MidJourneyPromptChain is a chain you can use to generate new MidJourney prompts."""
|
||||||
|
|
||||||
template: Optional[str] = """I want you to act as a prompt generator for Midjourney's artificial intelligence program.
|
template: Optional[
|
||||||
|
str
|
||||||
|
] = """I want you to act as a prompt generator for Midjourney's artificial intelligence program.
|
||||||
Your job is to provide detailed and creative descriptions that will inspire unique and interesting images from the AI.
|
Your job is to provide detailed and creative descriptions that will inspire unique and interesting images from the AI.
|
||||||
Keep in mind that the AI is capable of understanding a wide range of language and can interpret abstract concepts, so feel free to be as imaginative and descriptive as possible.
|
Keep in mind that the AI is capable of understanding a wide range of language and can interpret abstract concepts, so feel free to be as imaginative and descriptive as possible.
|
||||||
For example, you could describe a scene from a futuristic city, or a surreal landscape filled with strange creatures.
|
For example, you could describe a scene from a futuristic city, or a surreal landscape filled with strange creatures.
|
||||||
|
|
@ -81,7 +83,9 @@ class MidJourneyPromptChain(BaseCustomConversationChain):
|
||||||
|
|
||||||
|
|
||||||
class TimeTravelGuideChain(BaseCustomConversationChain):
|
class TimeTravelGuideChain(BaseCustomConversationChain):
|
||||||
template: Optional[str] = """I want you to act as my time travel guide. You are helpful and creative. I will provide you with the historical period or future time I want to visit and you will suggest the best events, sights, or people to experience. Provide the suggestions and any necessary information.
|
template: Optional[
|
||||||
|
str
|
||||||
|
] = """I want you to act as my time travel guide. You are helpful and creative. I will provide you with the historical period or future time I want to visit and you will suggest the best events, sights, or people to experience. Provide the suggestions and any necessary information.
|
||||||
Current conversation:
|
Current conversation:
|
||||||
{history}
|
{history}
|
||||||
Human: {input}
|
Human: {input}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import useFlowsManagerStore from "./stores/flowsManagerStore";
|
||||||
import { useTypesStore } from "./stores/typesStore";
|
import { useTypesStore } from "./stores/typesStore";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
|
||||||
const errorData = useAlertStore((state) => state.errorData);
|
const errorData = useAlertStore((state) => state.errorData);
|
||||||
const errorOpen = useAlertStore((state) => state.errorOpen);
|
const errorOpen = useAlertStore((state) => state.errorOpen);
|
||||||
const setErrorOpen = useAlertStore((state) => state.setErrorOpen);
|
const setErrorOpen = useAlertStore((state) => state.setErrorOpen);
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ export default function ParameterComponent({
|
||||||
takeSnapshot();
|
takeSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setNode(data.id, (oldNode) => {
|
setNode(data.id, (oldNode) => {
|
||||||
let newNode = cloneDeep(oldNode);
|
let newNode = cloneDeep(oldNode);
|
||||||
|
|
||||||
|
|
@ -273,9 +272,11 @@ export default function ParameterComponent({
|
||||||
<Handle
|
<Handle
|
||||||
type={left ? "target" : "source"}
|
type={left ? "target" : "source"}
|
||||||
position={left ? Position.Left : Position.Right}
|
position={left ? Position.Left : Position.Right}
|
||||||
key={proxy
|
key={
|
||||||
|
proxy
|
||||||
? scapedJSONStringfy({ ...id, proxy })
|
? scapedJSONStringfy({ ...id, proxy })
|
||||||
: scapedJSONStringfy(id)}
|
: scapedJSONStringfy(id)
|
||||||
|
}
|
||||||
id={
|
id={
|
||||||
proxy
|
proxy
|
||||||
? scapedJSONStringfy({ ...id, proxy })
|
? scapedJSONStringfy({ ...id, proxy })
|
||||||
|
|
@ -348,9 +349,11 @@ export default function ParameterComponent({
|
||||||
<Handle
|
<Handle
|
||||||
type={left ? "target" : "source"}
|
type={left ? "target" : "source"}
|
||||||
position={left ? Position.Left : Position.Right}
|
position={left ? Position.Left : Position.Right}
|
||||||
key={proxy
|
key={
|
||||||
|
proxy
|
||||||
? scapedJSONStringfy({ ...id, proxy })
|
? scapedJSONStringfy({ ...id, proxy })
|
||||||
: scapedJSONStringfy(id)}
|
: scapedJSONStringfy(id)
|
||||||
|
}
|
||||||
id={
|
id={
|
||||||
proxy
|
proxy
|
||||||
? scapedJSONStringfy({ ...id, proxy })
|
? scapedJSONStringfy({ ...id, proxy })
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,27 @@
|
||||||
import { ReactNode, useContext, useState } from "react";
|
import { ReactNode, useState } from "react";
|
||||||
import NewChatView from "../newChatView";
|
|
||||||
import { extractTypeFromLongId, removeCountFromString } from "../../utils/utils";
|
|
||||||
import AccordionComponent from "../AccordionComponent";
|
|
||||||
import { Badge } from "../ui/badge";
|
|
||||||
import ShadTooltip from "../ShadTooltipComponent";
|
|
||||||
import IconComponent from "../genericIconComponent";
|
|
||||||
import { Textarea } from "../ui/textarea";
|
|
||||||
import { NodeDataType } from "../../types/flow";
|
|
||||||
import useFlowStore from "../../stores/flowStore";
|
import useFlowStore from "../../stores/flowStore";
|
||||||
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
|
||||||
import useFlowIOStore from "../../stores/flowsIOStore";
|
import useFlowIOStore from "../../stores/flowsIOStore";
|
||||||
|
import { NodeDataType } from "../../types/flow";
|
||||||
|
import { extractTypeFromLongId } from "../../utils/utils";
|
||||||
|
import AccordionComponent from "../AccordionComponent";
|
||||||
|
import IconComponent from "../genericIconComponent";
|
||||||
|
import NewChatView from "../newChatView";
|
||||||
|
import { Badge } from "../ui/badge";
|
||||||
|
import { Textarea } from "../ui/textarea";
|
||||||
|
|
||||||
export default function IOView(): JSX.Element {
|
export default function IOView(): JSX.Element {
|
||||||
const {inputIds, outputIds, updateNodeFlowData } =
|
const { inputIds, outputIds, updateNodeFlowData } = useFlowIOStore();
|
||||||
useFlowIOStore();
|
|
||||||
const { reactFlowInstance } = useFlowStore();
|
const { reactFlowInstance } = useFlowStore();
|
||||||
const options = inputIds.concat(outputIds);
|
const options = inputIds.concat(outputIds);
|
||||||
const [selectedView, setSelectedView] = useState<ReactNode>(handleSelectChange(options[0]));
|
const [selectedView, setSelectedView] = useState<ReactNode>(
|
||||||
|
handleSelectChange(options[0])
|
||||||
|
);
|
||||||
// if (outputTypes.includes("ChatOutput")) {
|
// if (outputTypes.includes("ChatOutput")) {
|
||||||
// return <NewChatView />;
|
// return <NewChatView />;
|
||||||
// }
|
// }
|
||||||
function handleSelectChange(selected: string) {
|
function handleSelectChange(selected: string) {
|
||||||
const type = extractTypeFromLongId(selected);
|
const type = extractTypeFromLongId(selected);
|
||||||
return <NewChatView />
|
return <NewChatView />;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "ChatOutput":
|
case "ChatOutput":
|
||||||
return <NewChatView />;
|
return <NewChatView />;
|
||||||
|
|
@ -31,22 +29,19 @@ export default function IOView(): JSX.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="form-modal-iv-box">
|
<div className="form-modal-iv-box">
|
||||||
<div className="mr-6 flex h-full w-2/6 flex-col justify-start overflow-auto scrollbar-hide">
|
<div className="mr-6 flex h-full w-2/6 flex-col justify-start overflow-auto scrollbar-hide">
|
||||||
<div className="file-component-arrangement">
|
<div className="file-component-arrangement">
|
||||||
<IconComponent
|
<IconComponent name="Variable" className=" file-component-variable" />
|
||||||
name="Variable"
|
<span className="file-component-variables-span text-md">Inputs</span>
|
||||||
className=" file-component-variable"
|
|
||||||
/>
|
|
||||||
<span className="file-component-variables-span text-md">
|
|
||||||
Inputs
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
{
|
{inputIds
|
||||||
inputIds.filter(input=>extractTypeFromLongId(input)!=="ChatInput").map((inputId,index) => {
|
.filter((input) => extractTypeFromLongId(input) !== "ChatInput")
|
||||||
const nodeData:NodeDataType = reactFlowInstance?.getNodes().find(node=>node.id===inputId)?.data;
|
.map((inputId, index) => {
|
||||||
|
const nodeData: NodeDataType = reactFlowInstance
|
||||||
|
?.getNodes()
|
||||||
|
.find((node) => node.id === inputId)?.data;
|
||||||
return (
|
return (
|
||||||
<div className="file-component-accordion-div" key={index}>
|
<div className="file-component-accordion-div" key={index}>
|
||||||
<AccordionComponent
|
<AccordionComponent
|
||||||
|
|
@ -60,8 +55,7 @@ export default function IOView(): JSX.Element {
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
></div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
key={index}
|
key={index}
|
||||||
|
|
@ -69,13 +63,19 @@ export default function IOView(): JSX.Element {
|
||||||
>
|
>
|
||||||
<div className="file-component-tab-column">
|
<div className="file-component-tab-column">
|
||||||
<Textarea
|
<Textarea
|
||||||
value={reactFlowInstance?.getNodes().find(node=>node.id===inputId)?.data?.node?.template?.value.value}
|
value={
|
||||||
|
reactFlowInstance
|
||||||
|
?.getNodes()
|
||||||
|
.find((node) => node.id === inputId)?.data?.node
|
||||||
|
?.template?.value.value
|
||||||
|
}
|
||||||
className="custom-scroll"
|
className="custom-scroll"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
e.target.value;
|
e.target.value;
|
||||||
if(nodeData){
|
if (nodeData) {
|
||||||
nodeData.node!.template["value"].value = e.target.value;
|
nodeData.node!.template["value"].value =
|
||||||
updateNodeFlowData(inputId,nodeData);
|
e.target.value;
|
||||||
|
updateNodeFlowData(inputId, nodeData);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Enter text..."
|
placeholder="Enter text..."
|
||||||
|
|
@ -83,9 +83,8 @@ export default function IOView(): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
</AccordionComponent>
|
</AccordionComponent>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
})
|
})}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
{selectedView}
|
{selectedView}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,15 @@ export default function ChatInput({
|
||||||
}
|
}
|
||||||
}, [lockChat, inputRef]);
|
}, [lockChat, inputRef]);
|
||||||
|
|
||||||
|
function handleChange(value: number) {
|
||||||
function handleChange(value:number){
|
console.log(value);
|
||||||
console.log(value)
|
if (value > 0) {
|
||||||
if(value>0){
|
|
||||||
setRepeate(value);
|
setRepeate(value);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
setRepeate(1);
|
setRepeate(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
inputRef.current.style.height = "inherit"; // Reset the height
|
inputRef.current.style.height = "inherit"; // Reset the height
|
||||||
|
|
@ -38,16 +35,18 @@ export default function ChatInput({
|
||||||
}
|
}
|
||||||
}, [chatValue]);
|
}, [chatValue]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<span className="text-xs">repeate</span>
|
<span className="text-xs">repeate</span>
|
||||||
<input onChange={(e)=>{
|
<input
|
||||||
|
onChange={(e) => {
|
||||||
handleChange(parseInt(e.target.value));
|
handleChange(parseInt(e.target.value));
|
||||||
}} className="bg-background" type="number" min={0}/>
|
}}
|
||||||
|
className="bg-background"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Textarea
|
<Textarea
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
|
|
@ -79,7 +78,6 @@ export default function ChatInput({
|
||||||
? "form-modal-no-input bg-input"
|
? "form-modal-no-input bg-input"
|
||||||
: " form-modal-lock-false bg-background",
|
: " form-modal-lock-false bg-background",
|
||||||
|
|
||||||
|
|
||||||
"form-modal-lockchat"
|
"form-modal-lockchat"
|
||||||
)}
|
)}
|
||||||
placeholder={
|
placeholder={
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,14 @@ import { Props } from "../../../../types/components";
|
||||||
export function CodeBlock({ language, value }: Props): JSX.Element {
|
export function CodeBlock({ language, value }: Props): JSX.Element {
|
||||||
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
const [isCopied, setIsCopied] = useState<Boolean>(false);
|
||||||
|
|
||||||
|
|
||||||
const copyToClipboard = (): void => {
|
const copyToClipboard = (): void => {
|
||||||
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
navigator.clipboard.writeText(value).then(() => {
|
navigator.clipboard.writeText(value).then(() => {
|
||||||
setIsCopied(true);
|
setIsCopied(true);
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsCopied(false);
|
setIsCopied(false);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
@ -29,13 +26,11 @@ export function CodeBlock({ language, value }: Props): JSX.Element {
|
||||||
const suggestedFileName = `${"generated-code"}${fileExtension}`;
|
const suggestedFileName = `${"generated-code"}${fileExtension}`;
|
||||||
const fileName = window.prompt("enter file name", suggestedFileName);
|
const fileName = window.prompt("enter file name", suggestedFileName);
|
||||||
|
|
||||||
|
|
||||||
if (!fileName) {
|
if (!fileName) {
|
||||||
// user pressed cancel on prompt
|
// user pressed cancel on prompt
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const blob = new Blob([value], { type: "text/plain" });
|
const blob = new Blob([value], { type: "text/plain" });
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
|
|
@ -52,7 +47,6 @@ export function CodeBlock({ language, value }: Props): JSX.Element {
|
||||||
<div className="code-block-modal">
|
<div className="code-block-modal">
|
||||||
<span className="code-block-modal-span">{language}</span>
|
<span className="code-block-modal-span">{language}</span>
|
||||||
|
|
||||||
|
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<button className="code-block-modal-button" onClick={copyToClipboard}>
|
<button className="code-block-modal-button" onClick={copyToClipboard}>
|
||||||
{isCopied ? <IconCheck size={18} /> : <IconClipboard size={18} />}
|
{isCopied ? <IconCheck size={18} /> : <IconClipboard size={18} />}
|
||||||
|
|
@ -64,7 +58,6 @@ export function CodeBlock({ language, value }: Props): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<SyntaxHighlighter
|
<SyntaxHighlighter
|
||||||
className="overflow-auto"
|
className="overflow-auto"
|
||||||
language={language}
|
language={language}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import { chatMessagePropsType } from "../../../types/components";
|
||||||
import { classNames } from "../../../utils/utils";
|
import { classNames } from "../../../utils/utils";
|
||||||
import FileCard from "../fileComponent";
|
import FileCard from "../fileComponent";
|
||||||
|
|
||||||
|
|
||||||
export default function ChatMessage({
|
export default function ChatMessage({
|
||||||
chat,
|
chat,
|
||||||
lockChat,
|
lockChat,
|
||||||
|
|
@ -37,7 +36,7 @@ export default function ChatMessage({
|
||||||
alt="robot_image"
|
alt="robot_image"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs truncate">{chat.sender_name}</span>
|
<span className="truncate text-xs">{chat.sender_name}</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="form-modal-chat-image">
|
<div className="form-modal-chat-image">
|
||||||
|
|
@ -48,7 +47,7 @@ export default function ChatMessage({
|
||||||
alt="male_technology"
|
alt="male_technology"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs truncate">{chat.sender_name}</span>
|
<span className="truncate text-xs">{chat.sender_name}</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -110,19 +109,16 @@ export default function ChatMessage({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
children[0] = (children[0] as string).replace(
|
children[0] = (children[0] as string).replace(
|
||||||
"`▍`",
|
"`▍`",
|
||||||
"▍"
|
"▍"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const match = /language-(\w+)/.exec(
|
const match = /language-(\w+)/.exec(
|
||||||
className || ""
|
className || ""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return !inline ? (
|
return !inline ? (
|
||||||
<CodeTabsComponent
|
<CodeTabsComponent
|
||||||
isMessage
|
isMessage
|
||||||
|
|
@ -211,7 +207,6 @@ export default function ChatMessage({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update last index
|
// Update last index
|
||||||
lastIndex = regex.lastIndex;
|
lastIndex = regex.lastIndex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ export default function FileCard({
|
||||||
setIsHovered(false);
|
setIsHovered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fileType === "image") {
|
if (fileType === "image") {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -58,7 +57,6 @@ export default function FileCard({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button onClick={handleDownload} className="file-card-modal-button">
|
<button onClick={handleDownload} className="file-card-modal-button">
|
||||||
<div className="file-card-modal-div">
|
<div className="file-card-modal-div">
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,38 @@
|
||||||
import { useContext, useEffect, useRef, useState } from "react";
|
|
||||||
import { sendAllProps } from "../../types/api";
|
|
||||||
import { ChatMessageType } from "../../types/chat";
|
|
||||||
import { NodeType } from "../../types/flow";
|
|
||||||
import { classNames } from "../../utils/utils";
|
|
||||||
import ChatInput from "./chatInput";
|
|
||||||
import ChatMessage from "./chatMessage";
|
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
import IconComponent from "../../components/genericIconComponent";
|
import IconComponent from "../../components/genericIconComponent";
|
||||||
|
import useAlertStore from "../../stores/alertStore";
|
||||||
|
import useFlowStore from "../../stores/flowStore";
|
||||||
|
import useFlowIOStore from "../../stores/flowsIOStore";
|
||||||
|
import { sendAllProps } from "../../types/api";
|
||||||
import {
|
import {
|
||||||
|
ChatMessageType,
|
||||||
ChatOutputType,
|
ChatOutputType,
|
||||||
FlowPoolObjectType,
|
FlowPoolObjectType,
|
||||||
} from "../../types/chat";
|
} from "../../types/chat";
|
||||||
|
import { NodeType } from "../../types/flow";
|
||||||
import { validateNodes } from "../../utils/reactflowUtils";
|
import { validateNodes } from "../../utils/reactflowUtils";
|
||||||
import useAlertStore from "../../stores/alertStore";
|
import { classNames } from "../../utils/utils";
|
||||||
import useFlowIOStore from "../../stores/flowsIOStore";
|
import ChatInput from "./chatInput";
|
||||||
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
import ChatMessage from "./chatMessage";
|
||||||
import useFlowStore from "../../stores/flowStore";
|
|
||||||
|
|
||||||
|
|
||||||
export default function newChatView(): JSX.Element {
|
export default function newChatView(): JSX.Element {
|
||||||
const [chatValue, setChatValue] = useState("");
|
const [chatValue, setChatValue] = useState("");
|
||||||
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
const [chatHistory, setChatHistory] = useState<ChatMessageType[]>([]);
|
||||||
const { reactFlowInstance } = useFlowStore()
|
const { reactFlowInstance } = useFlowStore();
|
||||||
const {
|
const {
|
||||||
flowPool,
|
flowPool,
|
||||||
outputIds,
|
outputIds,
|
||||||
inputIds, inputTypes,
|
inputIds,
|
||||||
|
inputTypes,
|
||||||
updateNodeFlowData,
|
updateNodeFlowData,
|
||||||
buildFlow,
|
buildFlow,
|
||||||
CleanFlowPool
|
CleanFlowPool,
|
||||||
} = useFlowIOStore();
|
} = useFlowIOStore();
|
||||||
const { setErrorData } = useAlertStore();
|
const { setErrorData } = useAlertStore();
|
||||||
const [lockChat, setLockChat] = useState(false);
|
const [lockChat, setLockChat] = useState(false);
|
||||||
const messagesRef = useRef<HTMLDivElement | null>(null);
|
const messagesRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
|
||||||
//build chat history
|
//build chat history
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const chatOutputResponses: FlowPoolObjectType[] = [];
|
const chatOutputResponses: FlowPoolObjectType[] = [];
|
||||||
|
|
@ -46,9 +44,11 @@ export default function newChatView(): JSX.Element {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const chatMessages: ChatMessageType[] = chatOutputResponses
|
const chatMessages: ChatMessageType[] = chatOutputResponses
|
||||||
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp)).filter((output) => !!output.data.artifacts.message)
|
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
|
||||||
|
.filter((output) => !!output.data.artifacts.message)
|
||||||
.map((output) => {
|
.map((output) => {
|
||||||
const { sender, message, sender_name } = output.data.artifacts as ChatOutputType;
|
const { sender, message, sender_name } = output.data
|
||||||
|
.artifacts as ChatOutputType;
|
||||||
console.log(output.data.artifacts);
|
console.log(output.data.artifacts);
|
||||||
const is_ai = sender === "Machine";
|
const is_ai = sender === "Machine";
|
||||||
return { isSend: !is_ai, message, sender_name };
|
return { isSend: !is_ai, message, sender_name };
|
||||||
|
|
@ -61,23 +61,19 @@ export default function newChatView(): JSX.Element {
|
||||||
}
|
}
|
||||||
}, [chatHistory]);
|
}, [chatHistory]);
|
||||||
|
|
||||||
|
async function sendAll(data: sendAllProps): Promise<void> {}
|
||||||
async function sendAll(data: sendAllProps): Promise<void> { }
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
if (ref.current) ref.current.scrollIntoView({ behavior: "smooth" });
|
||||||
}, [chatHistory]);
|
}, [chatHistory]);
|
||||||
|
|
||||||
|
|
||||||
const ref = useRef<HTMLDivElement | null>(null);
|
const ref = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
ref.current.focus();
|
ref.current.focus();
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
async function sendMessage(count = 1): Promise<void> {
|
async function sendMessage(count = 1): Promise<void> {
|
||||||
let nodeValidationErrors = validateNodes(
|
let nodeValidationErrors = validateNodes(
|
||||||
reactFlowInstance!.getNodes(),
|
reactFlowInstance!.getNodes(),
|
||||||
|
|
@ -106,7 +102,6 @@ export default function newChatView(): JSX.Element {
|
||||||
}
|
}
|
||||||
setLockChat(false);
|
setLockChat(false);
|
||||||
|
|
||||||
|
|
||||||
//set chat message in the flow and run build
|
//set chat message in the flow and run build
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -123,7 +118,6 @@ export default function newChatView(): JSX.Element {
|
||||||
if (lockChat) setLockChat(false);
|
if (lockChat) setLockChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="eraser-column-arrangement">
|
<div className="eraser-column-arrangement">
|
||||||
<div className="eraser-size">
|
<div className="eraser-size">
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ export default function TextInputComponent({
|
||||||
}: {
|
}: {
|
||||||
text: string;
|
text: string;
|
||||||
emissor: string;
|
emissor: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<strong> {emissor}</strong>
|
<strong> {emissor}</strong>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
export default function TextOutputComponent({
|
export default function TextOutputComponent({
|
||||||
text,
|
text,
|
||||||
emissor,
|
emissor,
|
||||||
}: {
|
}: {
|
||||||
text: string;
|
text: string;
|
||||||
emissor: string;
|
emissor: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<strong>{emissor}</strong>
|
<strong>{emissor}</strong>
|
||||||
|
|
|
||||||
|
|
@ -678,5 +678,5 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([
|
||||||
|
|
||||||
export const priorityFields = new Set(["code", "template"]);
|
export const priorityFields = new Set(["code", "template"]);
|
||||||
|
|
||||||
export const INPUT_TYPES = new Set(["ChatInput","TextInput"]);
|
export const INPUT_TYPES = new Set(["ChatInput", "TextInput"]);
|
||||||
export const OUTPUT_TYPES = new Set(["ChatOutput"]);
|
export const OUTPUT_TYPES = new Set(["ChatOutput"]);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import ReactFlow, {
|
||||||
OnMove,
|
OnMove,
|
||||||
OnSelectionChangeParams,
|
OnSelectionChangeParams,
|
||||||
SelectionDragHandler,
|
SelectionDragHandler,
|
||||||
addEdge,
|
|
||||||
updateEdge,
|
updateEdge,
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
import GenericNode from "../../../../CustomNodes/GenericNode";
|
import GenericNode from "../../../../CustomNodes/GenericNode";
|
||||||
|
|
@ -19,13 +18,12 @@ import useFlowStore from "../../../../stores/flowStore";
|
||||||
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../../../stores/flowsManagerStore";
|
||||||
import { useTypesStore } from "../../../../stores/typesStore";
|
import { useTypesStore } from "../../../../stores/typesStore";
|
||||||
import { APIClassType } from "../../../../types/api";
|
import { APIClassType } from "../../../../types/api";
|
||||||
import { FlowType, NodeType, targetHandleType } from "../../../../types/flow";
|
import { FlowType, NodeType } from "../../../../types/flow";
|
||||||
import {
|
import {
|
||||||
generateFlow,
|
generateFlow,
|
||||||
generateNodeFromFlow,
|
generateNodeFromFlow,
|
||||||
getNodeId,
|
getNodeId,
|
||||||
isValidConnection,
|
isValidConnection,
|
||||||
scapeJSONParse,
|
|
||||||
validateSelection,
|
validateSelection,
|
||||||
} from "../../../../utils/reactflowUtils";
|
} from "../../../../utils/reactflowUtils";
|
||||||
import { getRandomName, isWrappedWithClass } from "../../../../utils/utils";
|
import { getRandomName, isWrappedWithClass } from "../../../../utils/utils";
|
||||||
|
|
@ -175,8 +173,8 @@ export default function Page({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
cleanFlow();
|
cleanFlow();
|
||||||
}
|
};
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
const onConnectMod = useCallback(
|
const onConnectMod = useCallback(
|
||||||
(params: Connection) => {
|
(params: Connection) => {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger
|
SelectTrigger,
|
||||||
} from "../../../../../components/ui/select-custom";
|
} from "../../../../../components/ui/select-custom";
|
||||||
import { useDarkStore } from "../../../../../stores/darkStore";
|
import { useDarkStore } from "../../../../../stores/darkStore";
|
||||||
import useFlowsManagerStore from "../../../../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../../../../stores/flowsManagerStore";
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
},
|
},
|
||||||
getFilterEdge: [],
|
getFilterEdge: [],
|
||||||
onConnect: (connection) => {
|
onConnect: (connection) => {
|
||||||
let newEdges: Edge[] = []
|
let newEdges: Edge[] = [];
|
||||||
get().setEdges((oldEdges) => {
|
get().setEdges((oldEdges) => {
|
||||||
newEdges = addEdge(
|
newEdges = addEdge(
|
||||||
{
|
{
|
||||||
|
|
@ -287,8 +287,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
oldEdges
|
oldEdges
|
||||||
);
|
);
|
||||||
return newEdges;
|
return newEdges;
|
||||||
|
});
|
||||||
})
|
|
||||||
useFlowsManagerStore
|
useFlowsManagerStore
|
||||||
.getState()
|
.getState()
|
||||||
.autoSaveCurrentFlow(
|
.autoSaveCurrentFlow(
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ const useFlowIOStore = create<flowIOStoreType>((set, get) => ({
|
||||||
inputTypes: [],
|
inputTypes: [],
|
||||||
inputIds: [],
|
inputIds: [],
|
||||||
outputIds: [],
|
outputIds: [],
|
||||||
|
|
||||||
setFlowPool: (flowPool) => {
|
setFlowPool: (flowPool) => {
|
||||||
set({ flowPool });
|
set({ flowPool });
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -43,5 +43,4 @@ export const useTypesStore = create<TypesStoreType>((set, get) => ({
|
||||||
let newChange = typeof change === "function" ? change(get().data) : change;
|
let newChange = typeof change === "function" ? change(get().data) : change;
|
||||||
set({ data: newChange });
|
set({ data: newChange });
|
||||||
},
|
},
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ export type chatInputType = {
|
||||||
};
|
};
|
||||||
lockChat: boolean;
|
lockChat: boolean;
|
||||||
noInput: boolean;
|
noInput: boolean;
|
||||||
sendMessage: (count?:number) => void;
|
sendMessage: (count?: number) => void;
|
||||||
setChatValue: (value: string) => void;
|
setChatValue: (value: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import { FlowType } from "../types/flow";
|
|
||||||
import { getVerticesOrder, postBuildVertex } from "../controllers/API";
|
import { getVerticesOrder, postBuildVertex } from "../controllers/API";
|
||||||
|
import { FlowType } from "../types/flow";
|
||||||
|
|
||||||
type BuildVerticesParams = {
|
type BuildVerticesParams = {
|
||||||
flow: FlowType; // Assuming FlowType is the type for your flow
|
flow: FlowType; // Assuming FlowType is the type for your flow
|
||||||
|
|
@ -9,16 +9,16 @@ type BuildVerticesParams = {
|
||||||
onBuildUpdate?: (data: any) => void; // Replace any with the actual type of data
|
onBuildUpdate?: (data: any) => void; // Replace any with the actual type of data
|
||||||
onBuildComplete?: (allNodesValid: boolean) => void;
|
onBuildComplete?: (allNodesValid: boolean) => void;
|
||||||
onBuildError?: (title, list) => void;
|
onBuildError?: (title, list) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function buildVertices({
|
export async function buildVertices({
|
||||||
flow,
|
flow,
|
||||||
nodeId = null,
|
nodeId = null,
|
||||||
onProgressUpdate,
|
onProgressUpdate,
|
||||||
onBuildUpdate,
|
onBuildUpdate,
|
||||||
onBuildComplete,
|
onBuildComplete,
|
||||||
onBuildError,
|
onBuildError,
|
||||||
}: BuildVerticesParams) {
|
}: BuildVerticesParams) {
|
||||||
try {
|
try {
|
||||||
// Step 1: Get vertices order
|
// Step 1: Get vertices order
|
||||||
console.log(JSON.parse(JSON.stringify(flow)));
|
console.log(JSON.parse(JSON.stringify(flow)));
|
||||||
|
|
@ -56,11 +56,13 @@ type BuildVerticesParams = {
|
||||||
onBuildUpdate({ data, id: buildData.id });
|
onBuildUpdate({ data, id: buildData.id });
|
||||||
}
|
}
|
||||||
buildResults.push(buildData.valid);
|
buildResults.push(buildData.valid);
|
||||||
} catch (error : any) {
|
} catch (error: any) {
|
||||||
|
|
||||||
if (onBuildError) {
|
if (onBuildError) {
|
||||||
console.log(error)
|
console.log(error);
|
||||||
onBuildError("Error Building Component", [(error as AxiosError<any>).response?.data?.detail??"Unknown Error"]);
|
onBuildError("Error Building Component", [
|
||||||
|
(error as AxiosError<any>).response?.data?.detail ??
|
||||||
|
"Unknown Error",
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,12 +72,14 @@ type BuildVerticesParams = {
|
||||||
const allNodesValid = buildResults.every((result) => result);
|
const allNodesValid = buildResults.every((result) => result);
|
||||||
onBuildComplete(allNodesValid);
|
onBuildComplete(allNodesValid);
|
||||||
}
|
}
|
||||||
} catch (error:any) {
|
} catch (error: any) {
|
||||||
// Callback for handling errors
|
// Callback for handling errors
|
||||||
if (onBuildError) {
|
if (onBuildError) {
|
||||||
if (onBuildError) {
|
if (onBuildError) {
|
||||||
onBuildError("Error Building Component", [(error as AxiosError<any>).response?.data?.detail??"Unknown Error"]);
|
onBuildError("Error Building Component", [
|
||||||
}
|
(error as AxiosError<any>).response?.data?.detail ?? "Unknown Error",
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -477,7 +477,7 @@ export function convertArrayToObj(arrayOfObjects) {
|
||||||
export function hasDuplicateKeys(array) {
|
export function hasDuplicateKeys(array) {
|
||||||
const keys = {};
|
const keys = {};
|
||||||
// Transforms an empty object into an object array without opening the 'editNode' modal to prevent the flow build from breaking.
|
// Transforms an empty object into an object array without opening the 'editNode' modal to prevent the flow build from breaking.
|
||||||
if (!Array.isArray(array)) array = [{"": ""}];
|
if (!Array.isArray(array)) array = [{ "": "" }];
|
||||||
for (const obj of array) {
|
for (const obj of array) {
|
||||||
for (const key in obj) {
|
for (const key in obj) {
|
||||||
if (keys[key]) {
|
if (keys[key]) {
|
||||||
|
|
|
||||||
|
|
@ -593,7 +593,7 @@ export function removeCountFromString(input: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractTypeFromLongId(id: string): string {
|
export function extractTypeFromLongId(id: string): string {
|
||||||
let [newId,_] = id.split("-");
|
let [newId, _] = id.split("-");
|
||||||
return newId;
|
return newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue