Skip to content

Commit

Permalink
chore: remove discussion prompt from summary (#9711)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall authored May 8, 2024
1 parent 2123159 commit a02c935
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 79 deletions.
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
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
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
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,22 @@ const generateGroupSummaries = async (
({reflectionGroupId}) => reflectionGroupId === group.id
)
if (reflectionsByGroupId.length <= 1) return
const reflectionTextByGroupId = reflectionsByGroupId.map(
({plaintextContent}) => plaintextContent
const fullQuestion = await manager.getDiscussionPromptQuestion(
group.title ?? 'Unknown',
reflectionsByGroupId
)
const [fullSummary, fullQuestion] = await Promise.all([
manager.getSummary(reflectionTextByGroupId),
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 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

0 comments on commit a02c935

Please sign in to comment.