Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions components/Interface-Chatbot/Messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,42 @@ function Message({ message, addMessage, prevTime, isLastMessage }: MessageProps)
const messageContent = useMemo(() => {
const role = message?.role;

// Handle combined message format (new backend format with user and llm_message in same object)
if (message?.user || message?.llm_message) {
return (
<>

{message?.user && (
<UserMessageCard
message={{
...message,
content: message?.user,
role: 'user',
urls: message?.user_urls || [],
image_urls: message?.user_urls || [],
}}
textColor={textColor}
backgroundColor={backgroundColor}
/>
)}
{(message?.llm_message || message?.error) && (
<AssistantMessageCard
message={{
...message,
content: message?.chatbot_message || message?.llm_message || message?.error,
role: 'assistant',
urls: message?.llm_urls || [],
image_urls: message?.llm_urls || [],
}}
textColor={textColor}
backgroundColor={backgroundColor}
/>
)}
</>
);
}

// Handle legacy message format (for backward compatibility)
switch (role) {
case ROLE_USER:
return (
Expand Down
6 changes: 3 additions & 3 deletions config/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export async function getPreviousMessage(

try {
const response = await axios.get(
`${URL}/api/v1/config/gethistory-chatbot/${threadId}/${bridgeName}?sub_thread_id=${subThreadId || threadId
`${URL}/api/history/${threadId}/${bridgeName}?sub_thread_id=${subThreadId || threadId
}&pageNo=${pageNo}&limit=${limit}`,
{ signal: currentController.signal }
);
Expand All @@ -146,8 +146,8 @@ export async function getPreviousMessage(
starterQuestion: response?.data?.starterQuestion || [],
};
} catch (error) {
if (error.name === "AbortError") {
console.warn("Request aborted:", error.message);
if ((error as any).name === "AbortError") {
console.warn("Request aborted:", (error as any).message);
} else {
console.warn("Error fetching previous messages:", error);
}
Expand Down
10 changes: 5 additions & 5 deletions public/chatbot-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
buttonName: ''
};
this.urls = {
chatbotUrl: 'http://localhost:3000/chatbot',
styleSheet: 'http://localhost:3000/chatbot-style.css',
// login: 'http://localhost:7072/api/chatbot/loginuser'
login: 'https://db.gtwy.ai/api/chatbot/loginuser'
chatbotUrl: 'http://localhost:3001/chatbot',
styleSheet: 'http://localhost:3001/chatbot-style.css',
login: 'http://localhost:7072/api/chatbot/loginuser'
// login: 'https://db.gtwy.ai/api/chatbot/loginuser'
};
this.icons = {
white: this.makeImageUrl('b1357e23-2fc6-4dc3-855a-7a213b1fa100'),
Expand Down Expand Up @@ -140,7 +140,7 @@
window.addEventListener('message', (event) => {
// Only process messages from trusted origins
const trustedOrigins = [
'http://localhost:3000',
'http://localhost:3001',
window.location.origin
];

Expand Down
12 changes: 3 additions & 9 deletions utils/dataConvertWrappers/makeGenericDataFormatUtility.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,10 @@ function convertChatHistoryToGenericFormat(history: any, isHello: boolean = fals
return (Array.isArray(history) ? history : []).map((msgObj: any) => {
return {
...msgObj,
id: msgObj?.Id,
content: msgObj?.chatbot_message || msgObj?.content,
role: msgObj?.role,
createdAt: msgObj?.createdAt,
function: msgObj?.function,
tools_call_data: msgObj?.tools_call_data,
id: msgObj?.id,
createdAt: msgObj?.created_at,
created_at: msgObj?.created_at,
error: msgObj?.error,
urls: msgObj?.urls
}
};
});

default:
Expand Down