mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27:10 +00:00
Handle chat history rendering when agent is deceased
This commit is contained in:
parent
f232c2b059
commit
874776024a
1 changed files with 16 additions and 14 deletions
|
@ -233,18 +233,19 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function constructAgentLink() {
|
function constructAgentLink() {
|
||||||
if (!data || !data.agent || !data.agent.slug) return `/agents`;
|
if (!data || !data.agent || !data.agent?.slug) return `/agents`;
|
||||||
return `/agents?agent=${data.agent.slug}`;
|
return `/agents?agent=${data.agent?.slug}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructAgentName() {
|
function constructAgentName() {
|
||||||
if (!data || !data.agent || !data.agent.name) return `Agent`;
|
if (!data || !data.agent || !data.agent?.name) return `Agent`;
|
||||||
return data.agent.name;
|
return data.agent?.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructAgentPersona() {
|
function constructAgentPersona() {
|
||||||
if (!data || !data.agent || !data.agent.persona) return ``;
|
if (!data || !data.agent || !data.agent?.persona)
|
||||||
return data.agent.persona;
|
return `Your agent is no longer available. You will be reset to the default agent.`;
|
||||||
|
return data.agent?.persona;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!props.conversationId && !props.publicConversationSlug) {
|
if (!props.conversationId && !props.publicConversationSlug) {
|
||||||
|
@ -279,7 +280,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
isMobileWidth={isMobileWidth}
|
isMobileWidth={isMobileWidth}
|
||||||
chatMessage={chatMessage}
|
chatMessage={chatMessage}
|
||||||
customClassName="fullHistory"
|
customClassName="fullHistory"
|
||||||
borderLeftColor={`${data?.agent.color}-500`}
|
borderLeftColor={`${data?.agent?.color}-500`}
|
||||||
isLastMessage={index === data.chat.length - 1}
|
isLastMessage={index === data.chat.length - 1}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
@ -300,13 +301,13 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
uploadedImageData: message.uploadedImageData,
|
uploadedImageData: message.uploadedImageData,
|
||||||
}}
|
}}
|
||||||
customClassName="fullHistory"
|
customClassName="fullHistory"
|
||||||
borderLeftColor={`${data?.agent.color}-500`}
|
borderLeftColor={`${data?.agent?.color}-500`}
|
||||||
/>
|
/>
|
||||||
{message.trainOfThought &&
|
{message.trainOfThought &&
|
||||||
constructTrainOfThought(
|
constructTrainOfThought(
|
||||||
message.trainOfThought,
|
message.trainOfThought,
|
||||||
index === incompleteIncomingMessageIndex,
|
index === incompleteIncomingMessageIndex,
|
||||||
data?.agent.color || "orange",
|
data?.agent?.color || "orange",
|
||||||
`${index}trainOfThought`,
|
`${index}trainOfThought`,
|
||||||
message.completed,
|
message.completed,
|
||||||
)}
|
)}
|
||||||
|
@ -323,7 +324,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
rawQuery: message.rawQuery,
|
rawQuery: message.rawQuery,
|
||||||
}}
|
}}
|
||||||
customClassName="fullHistory"
|
customClassName="fullHistory"
|
||||||
borderLeftColor={`${data?.agent.color}-500`}
|
borderLeftColor={`${data?.agent?.color}-500`}
|
||||||
isLastMessage={true}
|
isLastMessage={true}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
@ -343,7 +344,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
uploadedImageData: props.pendingMessage,
|
uploadedImageData: props.pendingMessage,
|
||||||
}}
|
}}
|
||||||
customClassName="fullHistory"
|
customClassName="fullHistory"
|
||||||
borderLeftColor={`${data?.agent.color}-500`}
|
borderLeftColor={`${data?.agent?.color}-500`}
|
||||||
isLastMessage={true}
|
isLastMessage={true}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -354,9 +355,10 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
||||||
name={constructAgentName()}
|
name={constructAgentName()}
|
||||||
link={constructAgentLink()}
|
link={constructAgentLink()}
|
||||||
avatar={
|
avatar={
|
||||||
getIconFromIconName(data.agent.icon, data.agent.color) || (
|
getIconFromIconName(
|
||||||
<Lightbulb />
|
data.agent?.icon,
|
||||||
)
|
data.agent?.color,
|
||||||
|
) || <Lightbulb />
|
||||||
}
|
}
|
||||||
description={constructAgentPersona()}
|
description={constructAgentPersona()}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue