Update types and attributes

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-04-17 23:34:07 -03:00
commit 30ee500c60
14 changed files with 101 additions and 61 deletions

View file

@ -204,16 +204,21 @@ export default function GenericNode({
}, [flowPool[data.id], data.id]);
useEffect(() => {
if (validationStatus?.params) {
if (validationStatus?.logs) {
// if it is not a string turn it into a string
let newValidationString = validationStatus.params;
let newValidationString = "";
if (validationStatus?.logs && Array.isArray(validationStatus.logs)) {
newValidationString = validationStatus.logs
.map((log) => log.message)
.join("\n");
}
if (typeof newValidationString !== "string") {
newValidationString = JSON.stringify(validationStatus.params);
newValidationString = JSON.stringify(validationStatus.logs);
}
setValidationString(newValidationString);
}
}, [validationStatus, validationStatus?.params]);
}, [validationStatus, validationStatus?.logs]);
const [showNode, setShowNode] = useState(data.showNode ?? true);

View file

@ -64,11 +64,11 @@ export default function ChatView({
const chatMessages: ChatMessageType[] = chatOutputResponses
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
//
.filter((output) => output.data.artifacts?.message !== null)
.filter((output) => output.messages && output.messages.length > 0)
.map((output, index) => {
try {
const { sender, message, sender_name, stream_url } = output.data
.artifacts as ChatOutputType;
const { sender, message, sender_name, stream_url } = output
.messages[0] as ChatOutputType;
const is_ai = sender === "Machine" || sender === null;
return {
@ -202,7 +202,9 @@ export default function ChatView({
chatValue={chatValue}
noInput={!inputTypes.includes("ChatInput")}
lockChat={lockChat}
sendMessage={({repeat,files}) => sendMessage({repeat,files})}
sendMessage={({ repeat, files }) =>
sendMessage({ repeat, files })
}
setChatValue={(value) => {
setChatValue(value);
}}

View file

@ -1,4 +1,6 @@
import { Edge, Node, Viewport } from "reactflow";
import { ChatOutputType, chatInputType } from "../chat";
import { Log } from "../components";
import { FlowType } from "../flow";
//kind and class are just representative names to represent the actual structure of the object received by the API
export type APIDataType = { [key: string]: APIKindType };
@ -150,7 +152,8 @@ export type VertexBuildTypeAPI = {
top_level_vertices: Array<string>;
run_id: string;
valid: boolean;
params: string;
logs: Log[];
messages: ChatOutputType[] | chatInputType[];
data: VertexDataTypeAPI;
timestamp: string;
};
@ -160,6 +163,7 @@ export type VertexBuildTypeAPI = {
export type VertexDataTypeAPI = {
results: { [key: string]: { [key: string]: string } };
artifacts: { [key: string]: string };
messages: ChatOutputType[] | chatInputType[];
timedelta?: number;
duration?: string;
};

View file

@ -28,7 +28,8 @@ export type chatInputType = {
export type FlowPoolObjectType = {
timestamp: string;
valid: boolean;
params: any;
// list of chat outputs or list of chat inputs
messages: Array<ChatOutputType | chatInputType> | [];
data: { artifacts: any; results: any | ChatOutputType | chatInputType };
id: string;
};

View file

@ -187,7 +187,13 @@ export type FloatComponentType = {
id?: string;
};
export type FilePreviewType={loading:boolean,file:File,error:boolean,id:string,path?:string}
export type FilePreviewType = {
loading: boolean;
file: File;
error: boolean;
id: string;
path?: string;
};
export type TooltipComponentType = {
children: ReactElement;
@ -475,7 +481,13 @@ export type chatInputType = {
};
lockChat: boolean;
noInput: boolean;
sendMessage: ({repeat,files}:{repeat:number,files?:string[]}) => void;
sendMessage: ({
repeat,
files,
}: {
repeat: number;
files?: string[];
}) => void;
setChatValue: (value: string) => void;
};
@ -673,10 +685,14 @@ export type crashComponentPropsType = {
resetErrorBoundary: (args) => void;
};
export type Log = {
message: string;
};
export type validationStatusType = {
id: string;
data: object | any;
params: string;
logs: Log[];
progress?: number;
valid: boolean;
duration?: string;
@ -716,7 +732,13 @@ export type IOFieldViewProps = {
export type UndrawCardComponentProps = { flow: FlowType };
export type chatViewProps = {
sendMessage: ({repeat,files}:{repeat:number,files?:string[]}) => void;
sendMessage: ({
repeat,
files,
}: {
repeat: number;
files?: string[];
}) => void;
chatValue: string;
setChatValue: (value: string) => void;
lockChat: boolean;

View file

@ -12,7 +12,7 @@ import { FlowState } from "../../tabs";
export type chatInputType = {
result: string;
files?:string[];
files?: string[];
};
export type ChatOutputType = {
@ -20,13 +20,13 @@ export type ChatOutputType = {
sender: string;
sender_name: string;
stream_url?: string;
files?:string[];
files?: string[];
};
export type FlowPoolObjectType = {
timestamp: string;
valid: boolean;
params: any;
messages: Array<ChatOutputType | chatInputType> | [];
data: {
artifacts: any | ChatOutputType | chatInputType;
results: any | ChatOutputType | chatInputType;
@ -44,7 +44,7 @@ export type FlowPoolObjectTypeNew = {
timestamp: string;
valid: boolean;
data: {
logs?:any | ChatOutputType | chatInputType;
logs?: any | ChatOutputType | chatInputType;
results: any | ChatOutputType | chatInputType;
};
duration?: string;
@ -123,7 +123,7 @@ export type FlowStoreType = {
startNodeId?: string;
stopNodeId?: string;
input_value?: string;
files?:string[];
files?: string[];
}) => Promise<void>;
getFlow: () => { nodes: Node[]; edges: Edge[]; viewport: Viewport };
updateVerticesBuild: (