🐛 (chatView/index.tsx): fix chat message filtering to handle nested messages array
♻️ (api/index.ts): rename 'message' to 'messages' in VertexDataTypeAPI for clarity and consistency
This commit is contained in:
parent
1ab17438f9
commit
749469e100
2 changed files with 8 additions and 5 deletions
|
|
@ -62,11 +62,14 @@ 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((output) => output.data.message)
|
.filter(
|
||||||
|
(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.message as ChatOutputType;
|
?.data?.messages[0] as ChatOutputType;
|
||||||
|
|
||||||
const is_ai = sender === "Machine" || sender === null;
|
const is_ai = sender === "Machine" || sender === null;
|
||||||
return {
|
return {
|
||||||
|
|
@ -131,7 +134,7 @@ export default function ChatView({
|
||||||
function updateChat(
|
function updateChat(
|
||||||
chat: ChatMessageType,
|
chat: ChatMessageType,
|
||||||
message: string,
|
message: string,
|
||||||
stream_url?: string
|
stream_url?: string,
|
||||||
) {
|
) {
|
||||||
// if (message === "") return;
|
// if (message === "") return;
|
||||||
chat.message = message;
|
chat.message = message;
|
||||||
|
|
@ -160,7 +163,7 @@ export default function ChatView({
|
||||||
const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop(
|
const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop(
|
||||||
setIsDragging,
|
setIsDragging,
|
||||||
setFiles,
|
setFiles,
|
||||||
currentFlowId
|
currentFlowId,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ export type VertexBuildTypeAPI = {
|
||||||
export type VertexDataTypeAPI = {
|
export type VertexDataTypeAPI = {
|
||||||
results: { [key: string]: string };
|
results: { [key: string]: string };
|
||||||
logs: { message: any; type: string }[];
|
logs: { message: any; type: string }[];
|
||||||
message: ChatOutputType | ChatInputType;
|
messages: ChatOutputType[] | ChatInputType[];
|
||||||
inactive?: boolean;
|
inactive?: boolean;
|
||||||
timedelta?: number;
|
timedelta?: number;
|
||||||
duration?: string;
|
duration?: string;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue