add descriptions to flow

This commit is contained in:
anovazzi1 2023-03-24 15:34:03 -03:00
commit 2224d219be
4 changed files with 8 additions and 1 deletions

View file

@ -97,7 +97,7 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) {
setChatValue("");
addChatHistory(message, true);
sendAll({ ...reactFlowInstance.toObject(), message, chatHistory})
sendAll({ ...reactFlowInstance.toObject(), message, chatHistory,name:flow.name,description:flow.description})
.then((r) => {
addChatHistory(r.data.result, false, r.data.thought);
setLockChat(false);

View file

@ -128,9 +128,11 @@ export function TabsProvider({ children }: { children: ReactNode }) {
function addFlow(flow?: FlowType) {
// Get data from the flow or set it to null if there's no flow provided.
const data = flow?.data ? flow.data : null;
const description = flow?.description?flow.description:""
// Create a new flow with a default name if no flow is provided.
let newFlow: FlowType = {
description,
name: "New Flow",
id: id.toString(),
data,
@ -158,6 +160,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
const newFlows = [...prevState];
const index = newFlows.findIndex((flow) => flow.id === newFlow.id);
if (index !== -1) {
newFlows[index].description = newFlow.description??""
newFlows[index].data = newFlow.data;
newFlows[index].name = newFlow.name;
newFlows[index].chat = newFlow.chat;

View file

@ -9,7 +9,10 @@ export type TemplateVariableType = {type:string,required:boolean,placeholder?:st
export type sendAllProps={
nodes: Node[];
edges: Edge[];
name:string,
description:string;
viewport: Viewport;
message:string;
chatHistory:{message:string,isSend:boolean}[],
};

View file

@ -7,6 +7,7 @@ export type FlowType = {
id: string;
data: ReactFlowJsonObject;
chat: Array<ChatMessageType>;
description:string;
};
export type NodeType = {id:string,type:string,position:XYPosition,data:NodeDataType}
export type NodeDataType = {type:string,node?:APIClassType,id:string,value:any}