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
|
const chatMessages: ChatMessageType[] = chatOutputResponses
|
||||||
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
|
.sort((a, b) => Date.parse(a.timestamp) - Date.parse(b.timestamp))
|
||||||
//
|
//
|
||||||
.filter(
|
.filter((output) => output.data.message)
|
||||||
(output) => output.data.messages && output.data.messages.length > 0,
|
|
||||||
)
|
|
||||||
.map((output, index) => {
|
.map((output, index) => {
|
||||||
try {
|
try {
|
||||||
const { sender, message, sender_name, stream_url, files } = output
|
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;
|
const is_ai = sender === "Machine" || sender === null;
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,9 @@ import {
|
||||||
targetHandleType,
|
targetHandleType,
|
||||||
} from "../types/flow";
|
} from "../types/flow";
|
||||||
import {
|
import {
|
||||||
ChatOutputType,
|
|
||||||
FlowPoolObjectType,
|
FlowPoolObjectType,
|
||||||
FlowStoreType,
|
FlowStoreType,
|
||||||
VertexLayerElementType,
|
VertexLayerElementType,
|
||||||
chatInputType,
|
|
||||||
} from "../types/zustand/flow";
|
} from "../types/zustand/flow";
|
||||||
import { buildVertices } from "../utils/buildUtils";
|
import { buildVertices } from "../utils/buildUtils";
|
||||||
import {
|
import {
|
||||||
|
|
@ -44,6 +42,7 @@ import { getInputsAndOutputs } from "../utils/storeUtils";
|
||||||
import useAlertStore from "./alertStore";
|
import useAlertStore from "./alertStore";
|
||||||
import { useDarkStore } from "./darkStore";
|
import { useDarkStore } from "./darkStore";
|
||||||
import useFlowsManagerStore from "./flowsManagerStore";
|
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
|
// 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) => ({
|
const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
|
|
@ -79,7 +78,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
updateFlowPool: (
|
updateFlowPool: (
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||||
buildId?: string
|
buildId?: string,
|
||||||
) => {
|
) => {
|
||||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||||
if (!newFlowPool[nodeId]) {
|
if (!newFlowPool[nodeId]) {
|
||||||
|
|
@ -95,7 +94,9 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
}
|
}
|
||||||
//update data results
|
//update data results
|
||||||
else {
|
else {
|
||||||
newFlowPool[nodeId][index].data.messages[0] = (data as ChatOutputType| chatInputType);
|
newFlowPool[nodeId][index].data.message = data as
|
||||||
|
| ChatOutputType
|
||||||
|
| chatInputType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get().setFlowPool(newFlowPool);
|
get().setFlowPool(newFlowPool);
|
||||||
|
|
@ -517,7 +518,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
|
|
||||||
get().addDataToFlowPool(
|
get().addDataToFlowPool(
|
||||||
{ ...vertexBuildData, run_id: runId },
|
{ ...vertexBuildData, run_id: runId },
|
||||||
vertexBuildData.id
|
vertexBuildData.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
useFlowStore.getState().updateBuildStatus([vertexBuildData.id], status);
|
useFlowStore.getState().updateBuildStatus([vertexBuildData.id], status);
|
||||||
|
|
|
||||||
|
|
@ -159,9 +159,10 @@ export type VertexBuildTypeAPI = {
|
||||||
// data is the object received by the API
|
// data is the object received by the API
|
||||||
// it has results, artifacts, timedelta, duration
|
// it has results, artifacts, timedelta, duration
|
||||||
export type VertexDataTypeAPI = {
|
export type VertexDataTypeAPI = {
|
||||||
results: { [key: string]: string };
|
results: { [key: string]: string };
|
||||||
logs:{message:string}[];
|
artifacts?: { [key: string]: string };
|
||||||
messages: ChatOutputType[] | chatInputType[];
|
logs: { message: any; type: string }[];
|
||||||
|
message: ChatOutputType | chatInputType;
|
||||||
inactive?: boolean;
|
inactive?: boolean;
|
||||||
timedelta?: number;
|
timedelta?: number;
|
||||||
duration?: string;
|
duration?: string;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,11 @@ export type ChatOutputType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type chatInputType = {
|
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 = {
|
export type FlowPoolObjectType = {
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,7 @@ import {
|
||||||
import { BuildStatus } from "../../../constants/enums";
|
import { BuildStatus } from "../../../constants/enums";
|
||||||
import { FlowState } from "../../tabs";
|
import { FlowState } from "../../tabs";
|
||||||
import { VertexBuildTypeAPI } from "../../api";
|
import { VertexBuildTypeAPI } from "../../api";
|
||||||
|
import { ChatOutputType, chatInputType } from "../../chat";
|
||||||
export type chatInputType = {
|
|
||||||
result: string;
|
|
||||||
files?: string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ChatOutputType = {
|
|
||||||
message: string;
|
|
||||||
sender: string;
|
|
||||||
sender_name: string;
|
|
||||||
stream_url?: string;
|
|
||||||
files?: string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type FlowPoolObjectType = {
|
export type FlowPoolObjectType = {
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
|
|
@ -159,7 +147,7 @@ export type FlowStoreType = {
|
||||||
updateFlowPool: (
|
updateFlowPool: (
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||||
buildId?: string
|
buildId?: string,
|
||||||
) => void;
|
) => void;
|
||||||
getNodePosition: (nodeId: string) => { x: number; y: number };
|
getNodePosition: (nodeId: string) => { x: number; y: number };
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue