fix api reference of FlowPool
This commit is contained in:
parent
82dead782d
commit
bca88b2d1b
5 changed files with 19 additions and 27 deletions
|
|
@ -60,13 +60,11 @@ export default function ChatView({
|
|||
const chatMessages: ChatMessageType[] = chatOutputResponses
|
||||
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
|
||||
//
|
||||
.filter(
|
||||
(output) => output.data.messages && output.data.messages.length > 0,
|
||||
)
|
||||
.filter((output) => output.data.message)
|
||||
.map((output, index) => {
|
||||
try {
|
||||
const { sender, message, sender_name, stream_url, files } = output
|
||||
.data.messages[0] as ChatOutputType;
|
||||
.data.message as ChatOutputType;
|
||||
|
||||
const is_ai = sender === "Machine" || sender === null;
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ import {
|
|||
targetHandleType,
|
||||
} from "../types/flow";
|
||||
import {
|
||||
ChatOutputType,
|
||||
FlowPoolObjectType,
|
||||
FlowStoreType,
|
||||
VertexLayerElementType,
|
||||
chatInputType,
|
||||
} from "../types/zustand/flow";
|
||||
import { buildVertices } from "../utils/buildUtils";
|
||||
import {
|
||||
|
|
@ -44,6 +42,7 @@ import { getInputsAndOutputs } from "../utils/storeUtils";
|
|||
import useAlertStore from "./alertStore";
|
||||
import { useDarkStore } from "./darkStore";
|
||||
import useFlowsManagerStore from "./flowsManagerStore";
|
||||
import { ChatOutputType, chatInputType } from "../types/chat";
|
||||
|
||||
// this is our useStore hook that we can use in our components to get parts of the store and call actions
|
||||
const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||
|
|
@ -79,7 +78,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
updateFlowPool: (
|
||||
nodeId: string,
|
||||
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||
buildId?: string
|
||||
buildId?: string,
|
||||
) => {
|
||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||
if (!newFlowPool[nodeId]) {
|
||||
|
|
@ -95,7 +94,9 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
}
|
||||
//update data results
|
||||
else {
|
||||
newFlowPool[nodeId][index].data.messages[0] = (data as ChatOutputType| chatInputType);
|
||||
newFlowPool[nodeId][index].data.message = data as
|
||||
| ChatOutputType
|
||||
| chatInputType;
|
||||
}
|
||||
}
|
||||
get().setFlowPool(newFlowPool);
|
||||
|
|
@ -517,7 +518,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
|
||||
get().addDataToFlowPool(
|
||||
{ ...vertexBuildData, run_id: runId },
|
||||
vertexBuildData.id
|
||||
vertexBuildData.id,
|
||||
);
|
||||
|
||||
useFlowStore.getState().updateBuildStatus([vertexBuildData.id], status);
|
||||
|
|
|
|||
|
|
@ -159,9 +159,10 @@ export type VertexBuildTypeAPI = {
|
|||
// data is the object received by the API
|
||||
// it has results, artifacts, timedelta, duration
|
||||
export type VertexDataTypeAPI = {
|
||||
results: { [key: string]: string };
|
||||
logs:{message:string}[];
|
||||
messages: ChatOutputType[] | chatInputType[];
|
||||
results: { [key: string]: string };
|
||||
artifacts?: { [key: string]: string };
|
||||
logs: { message: any; type: string }[];
|
||||
message: ChatOutputType | chatInputType;
|
||||
inactive?: boolean;
|
||||
timedelta?: number;
|
||||
duration?: string;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@ export type ChatOutputType = {
|
|||
};
|
||||
|
||||
export type chatInputType = {
|
||||
result: string;
|
||||
message: string;
|
||||
sender: string;
|
||||
sender_name: string;
|
||||
stream_url?: string;
|
||||
files?: Array<{ path: string; type: string; name: string }>;
|
||||
};
|
||||
|
||||
export type FlowPoolObjectType = {
|
||||
|
|
|
|||
|
|
@ -10,19 +10,7 @@ import {
|
|||
import { BuildStatus } from "../../../constants/enums";
|
||||
import { FlowState } from "../../tabs";
|
||||
import { VertexBuildTypeAPI } from "../../api";
|
||||
|
||||
export type chatInputType = {
|
||||
result: string;
|
||||
files?: string[];
|
||||
};
|
||||
|
||||
export type ChatOutputType = {
|
||||
message: string;
|
||||
sender: string;
|
||||
sender_name: string;
|
||||
stream_url?: string;
|
||||
files?: string[];
|
||||
};
|
||||
import { ChatOutputType, chatInputType } from "../../chat";
|
||||
|
||||
export type FlowPoolObjectType = {
|
||||
timestamp: string;
|
||||
|
|
@ -159,7 +147,7 @@ export type FlowStoreType = {
|
|||
updateFlowPool: (
|
||||
nodeId: string,
|
||||
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||
buildId?: string
|
||||
buildId?: string,
|
||||
) => void;
|
||||
getNodePosition: (nodeId: string) => { x: number; y: number };
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue