♻️ (chatView, flowStore): refactor message handling for consistency
This commit is contained in:
parent
5a64bb2678
commit
84a87a3c39
3 changed files with 4 additions and 6 deletions
|
|
@ -62,14 +62,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 {
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
}
|
}
|
||||||
//update data results
|
//update data results
|
||||||
else {
|
else {
|
||||||
newFlowPool[nodeId][index].data.messages[0] = data as
|
newFlowPool[nodeId][index].data.message = data as
|
||||||
| ChatOutputType
|
| ChatOutputType
|
||||||
| ChatInputType;
|
| ChatInputType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ export type VertexDataTypeAPI = {
|
||||||
timedelta?: number;
|
timedelta?: number;
|
||||||
duration?: string;
|
duration?: string;
|
||||||
artifacts?: any;
|
artifacts?: any;
|
||||||
|
message: ChatOutputType | ChatInputType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CodeErrorDataTypeAPI = {
|
export type CodeErrorDataTypeAPI = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue