Skip to content

Commit

Permalink
Merge pull request #2000 from stakwork/feature/unique-question-ai
Browse files Browse the repository at this point in the history
feat: added uniqnues for ai questions
  • Loading branch information
Rassl authored Aug 6, 2024
2 parents 302d9f4 + 3c3685b commit aa42d2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/components/App/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,16 @@ const Content = forwardRef<HTMLDivElement, ContentProp>(({ subViewOpen }, ref) =
</TrendingWrapper>
)}
<Flex>
{Object.keys(aiSummaryAnswers).map((i: string) => (
<AiSummary
key={i}
question={aiSummaryAnswers[i]?.question || ''}
refId={i}
response={aiSummaryAnswers[i]}
/>
))}
{Object.keys(aiSummaryAnswers)
.filter((key) => aiSummaryAnswers[key].shouldRender)
.map((i: string) => (
<AiSummary
key={i}
question={aiSummaryAnswers[i]?.question || ''}
refId={i}
response={aiSummaryAnswers[i]}
/>
))}

{isLoading ? <EpisodeSkeleton /> : !hasAiChats && <LatestView isSearchResult={!!searchTerm || hasAiChats} />}
</Flex>
Expand Down
10 changes: 7 additions & 3 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,15 @@ export const useDataStore = create<DataStore>()(
if (data?.query_data?.ref_id) {
useAiSummaryStore.setState({ aiRefId: data?.query_data?.ref_id })

const { aiSummaryAnswers } = useAiSummaryStore.getState()
const { answer } = aiSummaryAnswers[data?.query_data?.ref_id] || {}

setAiSummaryAnswer(data?.query_data?.ref_id, {
question: AISearchQuery,
answer: '',
answerLoading: true,
sourcesLoading: true,
answer: answer || '',
answerLoading: !answer,
sourcesLoading: !answer,
shouldRender: true,
})
}

Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export type AIEntity = {
questionsLoading?: boolean
hasBeenRendered?: boolean
entities?: ExtractedEntity[]
shouldRender?: boolean
}

export interface ExtractedEntity {
Expand Down

0 comments on commit aa42d2e

Please sign in to comment.