This commit is contained in:
pablodanswer 2025-01-23 11:44:42 -08:00 committed by Evan Lohn
parent eb6dbf49a1
commit dd494d2daa
3 changed files with 89 additions and 12 deletions

View File

@ -287,6 +287,16 @@ export function ChatPage({
SEARCH_PARAM_NAMES.TEMPERATURE
);
const defaultTemperature = search_param_temperature
? parseFloat(search_param_temperature)
: selectedAssistant?.tools.some(
(tool) =>
tool.in_code_tool_id === SEARCH_TOOL_ID ||
tool.in_code_tool_id === INTERNET_SEARCH_TOOL_ID
)
? 0
: 0.7;
const setSelectedAssistantFromId = (assistantId: number) => {
// NOTE: also intentionally look through available assistants here, so that
// even if the user has hidden an assistant they can still go back to it
@ -2569,6 +2579,10 @@ export function ChatPage({
if (parentMessage?.type == "assistant") {
return <></>;
}
const secondLevelMessage =
messageHistory[i + 1]?.type === "assistant"
? messageHistory[i + 1]
: undefined;
const secondLevelAssistantMessage =
messageHistory[i + 1]?.type === "assistant"
@ -2631,6 +2645,21 @@ export function ChatPage({
agenticDocs={
message.agentic_docs || agenticDocs
}
toggleDocDisplay={(
agentic: boolean
) => {
if (agentic) {
setSelectedMessageForDocDisplay(
message.messageId
);
} else {
setSelectedMessageForDocDisplay(
secondLevelMessage
? secondLevelMessage.messageId
: null
);
}
}}
docs={
message?.documents &&
message?.documents.length > 0
@ -2738,6 +2767,39 @@ export function ChatPage({
message.messageId as number,
])
}
handleSearchQueryEdit={
i === messageHistory.length - 1 &&
currentSessionChatState == "input"
? (newQuery) => {
if (!previousMessage) {
setPopup({
type: "error",
message:
"Cannot edit query of first message - please refresh the page and try again.",
});
return;
}
if (
previousMessage.messageId ===
null
) {
setPopup({
type: "error",
message:
"Cannot edit query of a pending message - please wait a few seconds and try again.",
});
return;
}
onSubmit({
messageIdToResend:
previousMessage.messageId,
queryOverride: newQuery,
alternativeAssistantOverride:
currentAlternativeAssistant,
});
}
: undefined
}
handleShowRetrieved={(
messageNumber
) => {

View File

@ -118,6 +118,7 @@ export const AgenticMessage = ({
secondLevelSubquestions,
setStreamingAllowed,
streamingAllowed,
toggleDocDisplay,
}: {
secondLevelSubquestions?: SubQuestionDetail[] | null;
agenticDocs?: OnyxDocument[] | null;
@ -156,6 +157,7 @@ export const AgenticMessage = ({
setPresentingDocument?: (document: OnyxDocument) => void;
setStreamingAllowed?: (allowed: boolean) => void;
streamingAllowed?: boolean;
toggleDocDisplay?: (agentic: boolean) => void;
}) => {
const [streamedContent, setStreamedContent] = useState(content as string);
@ -292,8 +294,8 @@ export const AgenticMessage = ({
? docs
: agenticDocs
: agenticDocs && agenticDocs.length > 0
? agenticDocs
: docs
? agenticDocs
: docs
}
subQuestions={
isViewingInitialAnswer
@ -378,12 +380,12 @@ export const AgenticMessage = ({
? StreamingPhase.COMPLETE
: StreamingPhase.ANSWER
: secondLevelSubquestions[0].context_docs
? StreamingPhase.CONTEXT_DOCS
: secondLevelSubquestions[0].sub_queries
? StreamingPhase.SUB_QUERIES
: secondLevelSubquestions[0].question
? StreamingPhase.WAITING
: StreamingPhase.WAITING
? StreamingPhase.CONTEXT_DOCS
: secondLevelSubquestions[0].sub_queries
? StreamingPhase.SUB_QUERIES
: secondLevelSubquestions[0].question
? StreamingPhase.WAITING
: StreamingPhase.WAITING
: StreamingPhase.WAITING;
const message = useOrderedPhases(currentState);
@ -542,6 +544,8 @@ export const AgenticMessage = ({
const viewInitialAnswer =
!isViewingInitialAnswer;
setIsViewingInitialAnswer(viewInitialAnswer);
toggleDocDisplay &&
toggleDocDisplay(isViewingInitialAnswer);
if (viewInitialAnswer) {
setIsViewingInitialAnswer(true);
}

View File

@ -308,8 +308,8 @@ const SubQuestionDisplay: React.FC<{
status === ToggleState.Todo
? "!border-4 border border-background-900 bg-background"
: false
? "bg-background border-3 border border-background-900 rotating-border"
: "bg-background-900 flex items-center justify-center"
? "bg-background border-3 border border-background-900 rotating-border"
: "bg-background-900 flex items-center justify-center"
}
`}
>
@ -637,7 +637,15 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
!finishedGenerating ? ToggleState.Todo : ToggleState.Done
}
documents={documents}
isLast={false}
isLast={
!showSummarizing &&
memoizedSubQuestions.length > index + 1 &&
!(
showSecondLevel &&
memoizedSecondLevelQuestions &&
memoizedSecondLevelQuestions?.length > 0
)
}
isFirst={index === 0}
setPresentingDocument={setPresentingDocument}
unToggle={
@ -679,7 +687,10 @@ const SubQuestionsDisplay: React.FC<SubQuestionsDisplayProps> = ({
key={index}
subQuestion={subQuestion}
documents={documents}
isLast={false}
isLast={
!showSummarizing &&
memoizedSecondLevelQuestions.length > index + 1
}
isFirst={false}
setPresentingDocument={setPresentingDocument}
unToggle={