Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove discussion prompt from summary #9711

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ const RetroTopic = (props: Props) => {
reflections {
...EmailReflectionCard_reflection
}
discussionPromptQuestion
}
discussion {
commentCount
Expand Down Expand Up @@ -121,7 +120,7 @@ const RetroTopic = (props: Props) => {

const {reflectionGroup, discussion, id: stageId} = stage
const {commentCount, discussionSummary} = discussion
const {reflections, title, voteCount, discussionPromptQuestion} = reflectionGroup!
const {reflections, title, voteCount} = reflectionGroup!
const imageSource = isEmail ? 'static' : 'local'
const icon = imageSource === 'local' ? 'thumb_up_18.svg' : '[email protected]'
const src = `${ExternalLinks.EMAIL_CDN}${icon}`
Expand All @@ -143,29 +142,15 @@ const RetroTopic = (props: Props) => {
</AnchorIfEmail>
</td>
</tr>
{(discussionPromptQuestion || discussionSummary) && (
{discussionSummary && (
<tr>
<td align='left' style={{lineHeight: '22px', fontSize: 14}}>
{discussionPromptQuestion && (
<>
<tr>
<td style={topicTitleStyle}>{'🤖 Discussion Question'}</td>
</tr>
<tr>
<td style={textStyle}>{discussionPromptQuestion}</td>
</tr>
</>
)}
{discussionSummary && (
<>
<tr>
<td style={topicTitleStyle}>{'🤖 Discussion Summary'}</td>
</tr>
<tr>
<td style={textStyle}>{discussionSummary}</td>
</tr>
</>
)}
<tr>
<td style={topicTitleStyle}>{'🤖 Discussion Summary'}</td>
</tr>
<tr>
<td style={textStyle}>{discussionSummary}</td>
</tr>
</td>
</tr>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ const WholeMeetingSummary = (props: Props) => {
}
... on RetrospectiveMeeting {
reflectionGroups(sortBy: voteCount) {
summary
}
phases {
phaseType
... on DiscussPhase {
stages {
discussion {
summary
}
}
reflections {
id
}
}
}
Expand All @@ -49,14 +41,11 @@ const WholeMeetingSummary = (props: Props) => {
meetingRef
)
if (meeting.__typename === 'RetrospectiveMeeting') {
const {summary: wholeMeetingSummary, reflectionGroups, phases} = meeting
const discussPhase = phases!.find((phase) => phase.phaseType === 'discuss')
const {stages} = discussPhase ?? {}
const hasTopicSummary = reflectionGroups!.some((group) => group.summary)
const hasDiscussionSummary = !!stages?.some((stage) => stage.discussion?.summary)
const hasOpenAISummary = hasTopicSummary || hasDiscussionSummary
if (!hasOpenAISummary) return null
if (hasOpenAISummary && !wholeMeetingSummary) return <WholeMeetingSummaryLoading />
const {summary: wholeMeetingSummary, reflectionGroups, organization} = meeting
const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length
const hasMoreThanOneReflection = reflections?.length && reflections.length > 1
if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary) return null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's more than one reflection, we'll always create the meeting summary unless noAISummary is true, so we don't need to check if there's a discussion summary or reflection group summary (which is now removed anyway)

if (!wholeMeetingSummary) return <WholeMeetingSummaryLoading />
return <WholeMeetingSummaryResult meetingRef={meeting} />
} else if (meeting.__typename === 'TeamPromptMeeting') {
const {summary: wholeMeetingSummary, responses, organization} = meeting
Expand Down
29 changes: 15 additions & 14 deletions packages/client/mutations/EndRetrospectiveMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ graphql`
autogroupReflectionGroups {
groupTitle
}
organization {
featureFlags {
noAISummary
}
}
reflectionGroups(sortBy: voteCount) {
summary
reflections {
id
}
Expand All @@ -43,13 +47,6 @@ graphql`
}
phases {
phaseType
... on DiscussPhase {
stages {
discussion {
summary
}
}
}
}
}
team {
Expand Down Expand Up @@ -109,7 +106,14 @@ export const endRetrospectiveTeamOnNext: OnNextHandler<
const {isKill, meeting} = payload
const {atmosphere, history} = context
if (!meeting) return
const {id: meetingId, teamId, reflectionGroups, phases, autogroupReflectionGroups} = meeting
const {
id: meetingId,
teamId,
reflectionGroups,
phases,
autogroupReflectionGroups,
organization
} = meeting
if (meetingId === RetroDemo.MEETING_ID) {
if (isKill) {
window.localStorage.removeItem('retroDemo')
Expand All @@ -122,12 +126,9 @@ export const endRetrospectiveTeamOnNext: OnNextHandler<
history.push(`/team/${teamId}`)
popEndMeetingToast(atmosphere, meetingId)
} else {
const discussPhase = phases.find((phase) => phase.phaseType === 'discuss')
const {stages} = discussPhase ?? {}
const hasTopicSummary = reflectionGroups.some((group) => group.summary)
const reflections = reflectionGroups.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length
const hasDiscussionSummary = !!stages?.some((stage) => stage.discussion?.summary)
const hasOpenAISummary = hasTopicSummary || hasDiscussionSummary
const hasMoreThanOneReflection = reflections.length > 1
const hasOpenAISummary = hasMoreThanOneReflection || !organization.featureFlags.noAISummary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 this should be &&, shouldn't it?

const hasTeamHealth = phases.some((phase) => phase.phaseType === 'TEAM_HEALTH')
const pathname = `/new-summary/${meetingId}`
const search = new URLSearchParams()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {AIExplainer} from '../../../../client/types/constEnums'
import {PARABOL_AI_USER_ID} from '../../../../client/utils/constants'
import getRethink from '../../../database/rethinkDriver'
import Comment from '../../../database/types/Comment'
import DiscussStage from '../../../database/types/DiscussStage'
import {convertHtmlToTaskContent} from '../../../utils/draftjs/convertHtmlToTaskContent'
import {DataLoaderWorker} from '../../graphql'
import {getFeatureTier} from '../../types/helpers/getFeatureTier'

export const buildCommentContentBlock = (
title: string,
Expand All @@ -28,33 +26,17 @@ export const createAIComment = (discussionId: string, content: string, order: nu
const addAIGeneratedContentToThreads = async (
stages: DiscussStage[],
meetingId: string,
teamId: string,
dataLoader: DataLoaderWorker
) => {
const [r, groups, team] = await Promise.all([
const [r, groups] = await Promise.all([
getRethink(),
dataLoader.get('retroReflectionGroupsByMeetingId').load(meetingId),
dataLoader.get('teams').loadNonNull(teamId)
dataLoader.get('retroReflectionGroupsByMeetingId').load(meetingId)
])
const commentPromises = stages.map(async ({discussionId, reflectionGroupId}, idx) => {
const commentPromises = stages.map(async ({discussionId, reflectionGroupId}) => {
const group = groups.find((group) => group.id === reflectionGroupId)
if (!group?.summary && !group?.discussionPromptQuestion) return
if (!group?.discussionPromptQuestion) return
const comments: Comment[] = []

if (group.summary) {
const topicSummaryExplainerText =
idx === 0
? getFeatureTier(team) === 'starter'
? AIExplainer.STARTER
: AIExplainer.PREMIUM_REFLECTIONS
: undefined
const topicSummaryComment = createAIComment(
discussionId,
buildCommentContentBlock('🤖 Topic Summary', group.summary, topicSummaryExplainerText),
0
)
comments.push(topicSummaryComment)
}
if (group.discussionPromptQuestion) {
const topicSummaryComment = createAIComment(
discussionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sendToSentry from '../../../utils/sendToSentry'
import {DataLoaderWorker} from '../../graphql'
import canAccessAISummary from './canAccessAISummary'

const generateGroupSummaries = async (
const generateDiscussionPrompt = async (
meetingId: string,
teamId: string,
dataLoader: DataLoaderWorker,
Expand All @@ -30,7 +30,7 @@ const generateGroupSummaries = async (
const pg = getKysely()
const manager = new OpenAIServerManager()
if (!reflectionGroups.length) {
const error = new Error('No reflection groups in generateGroupSummaries')
const error = new Error('No reflection groups in generateDiscussionPrompt')
sendToSentry(error, {userId: facilitator.id, tags: {meetingId}})
return
}
Expand All @@ -40,30 +40,21 @@ const generateGroupSummaries = async (
({reflectionGroupId}) => reflectionGroupId === group.id
)
if (reflectionsByGroupId.length <= 1) return
const reflectionTextByGroupId = reflectionsByGroupId.map(
({plaintextContent}) => plaintextContent
)
const [fullSummary, fullQuestion] = await Promise.all([
manager.getSummary(reflectionTextByGroupId),
const [fullQuestion] = await Promise.all([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 No need to wrap a single call in Promise.all([...])

manager.getDiscussionPromptQuestion(group.title ?? 'Unknown', reflectionsByGroupId)
])
if (!fullSummary && !fullQuestion) return
const summary = fullSummary?.slice(0, 2000)
if (!fullQuestion) return
const discussionPromptQuestion = fullQuestion?.slice(0, 2000)
return Promise.all([
pg
.updateTable('RetroReflectionGroup')
.set({summary, discussionPromptQuestion})
.set({discussionPromptQuestion})
.where('id', '=', group.id)
.execute(),
r
.table('RetroReflectionGroup')
.get(group.id)
.update({summary, discussionPromptQuestion})
.run()
r.table('RetroReflectionGroup').get(group.id).update({discussionPromptQuestion}).run()
])
})
)
}

export default generateGroupSummaries
export default generateDiscussionPrompt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {DataLoaderWorker} from '../../graphql'
import addAIGeneratedContentToThreads from './addAIGeneratedContentToThreads'
import addDiscussionTopics from './addDiscussionTopics'
import addRecallBot from './addRecallBot'
import generateDiscussionPrompt from './generateDiscussionPrompt'
import generateDiscussionSummary from './generateDiscussionSummary'
import generateGroupSummaries from './generateGroupSummaries'
import generateGroups from './generateGroups'
import {publishToEmbedder} from './publishToEmbedder'
import removeEmptyReflections from './removeEmptyReflections'
Expand Down Expand Up @@ -92,7 +92,7 @@ const handleCompletedRetrospectiveStage = async (
.run()
data.meeting = meeting
// dont await for the OpenAI API response
generateGroupSummaries(meeting.id, teamId, dataLoader, facilitatorUserId)
generateDiscussionPrompt(meeting.id, teamId, dataLoader, facilitatorUserId)
}

return {[stage.phaseType]: data}
Expand All @@ -112,7 +112,7 @@ const handleCompletedRetrospectiveStage = async (
}))
await Promise.all([
insertDiscussions(discussions),
addAIGeneratedContentToThreads(discussPhaseStages, meetingId, teamId, dataLoader),
addAIGeneratedContentToThreads(discussPhaseStages, meetingId, dataLoader),
publishToEmbedder({jobType: 'relatedDiscussions:start', data: {meetingId}, priority: 0})
])
if (videoMeetingURL) {
Expand Down
2 changes: 1 addition & 1 deletion packages/server/graphql/types/Discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const Discussion = new GraphQLObjectType<any, GQLContext>({
},
summary: {
type: GraphQLString,
description: `The GPT-3 generated summary of the discussion. Undefined if the user doesnt have access to the feature or the stage isn't completed`
description: `The AI generated summary of the discussion. Undefined if the user doesnt have access to the feature or the stage isn't completed`
}
})
})
Expand Down
4 changes: 0 additions & 4 deletions packages/server/graphql/types/RetroReflectionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ const RetroReflectionGroup: GraphQLObjectType = new GraphQLObjectType<any, GQLCo
type: new GraphQLNonNull(GraphQLFloat),
description: 'The sort order of the reflection group'
},
summary: {
type: GraphQLString,
description: `The AI generated summary of this reflection group`
},
discussionPromptQuestion: {
type: GraphQLString,
description: `The AI generated question to prompt and engage the discussion of this reflection group`
Expand Down
Loading