Skip to content

Commit

Permalink
chore: make ai standups more concise and add context (#10689)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall authored Jan 16, 2025
1 parent 0516f8f commit b67d07c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/client/types/constEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export const enum PollsAriaLabels {
}

export const enum AIExplainer {
STARTER = `AI generated summaries 🤖 are a premium feature. We'll share them with you for a few retros so you can see what they're like.`,
STARTER = `AI generated summaries 🤖 are a premium feature, but we'll share a few summaries with you so you can see what they're like.`,
PREMIUM_MEETING = `Our friendly AI 🤖 is here to save you time by summarizing your meeting`,
PREMIUM_REFLECTIONS = `Our friendly AI 🤖 is here to save you time by summarizing your reflections`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {getTeamPromptResponsesByMeetingId} from '../../../postgres/queries/getTe
import {TeamPromptMeeting} from '../../../postgres/types/Meeting'
import OpenAIServerManager from '../../../utils/OpenAIServerManager'
import {DataLoaderWorker} from '../../graphql'
import isValid from '../../isValid'
import canAccessAI from './canAccessAI'

const generateStandupMeetingSummary = async (
Expand All @@ -14,11 +15,18 @@ const generateStandupMeetingSummary = async (

const responses = await getTeamPromptResponsesByMeetingId(meeting.id)

const contentToSummarize = responses.map((response) => response.plaintextContent)
if (contentToSummarize.length === 0) return
const userIds = responses.map((response) => response.userId)
const users = (await dataLoader.get('users').loadMany(userIds)).filter(isValid)

const contentWithUsers = responses.map((response, idx) => ({
content: response.plaintextContent,
user: users[idx]?.preferredName ?? 'Anonymous'
}))

if (contentWithUsers.length === 0) return

const manager = new OpenAIServerManager()
const summary = await manager.getStandupSummary(contentToSummarize, meeting.meetingPrompt)
const summary = await manager.getStandupSummary(contentWithUsers, meeting.meetingPrompt)
if (!summary) return
return summary
}
Expand Down
24 changes: 13 additions & 11 deletions packages/server/utils/OpenAIServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,34 @@ class OpenAIServerManager {
})
}

async getStandupSummary(plaintextResponses: string[], meetingPrompt: string) {
async getStandupSummary(
responses: Array<{content: string; user: string}>,
meetingPrompt: string
) {
if (!this.openAIApi) return null
// :TODO: (jmtaber129): Include info about who made each response in the prompt, so that the LLM
// can include that in the response, e.g. "James is working on AI Summaries" vs. "Someone is
// working on AI Summaries".
const prompt = `Below is a list of responses submitted by team members to the question "${meetingPrompt}". If there are multiple responses, the responses are delimited by the string "NEW_RESPONSE". Identify up to 5 themes found within the responses. For each theme, provide a 2 to 3 sentence summary. In the summaries, only include information specified in the responses. When referring to people in the output, do not assume their gender and default to using the pronouns "they" and "them".

const prompt = `Below is a list of responses submitted by team members to the question "${meetingPrompt}". Each response includes the team member's name. Identify up to 3 key themes found within the responses. For each theme, provide a single concise sentence that includes who is working on what. Use "they/them" pronouns when referring to people.
Desired format:
- <theme title>: <theme summary>
- <theme title>: <theme summary>
- <theme title>: <theme summary>
- <theme>: <brief summary including names>
- <theme>: <brief summary including names>
- <theme>: <brief summary including names>
Responses: """
${plaintextResponses.join('\nNEW_RESPONSE\n')}
${responses.map(({content, user}) => `${user}: ${content}`).join('\nNEW_RESPONSE\n')}
"""`

try {
const response = await this.openAIApi.chat.completions.create({
model: 'gpt-4o-mini',
model: 'gpt-4o',
messages: [
{
role: 'user',
content: prompt
}
],
temperature: 0.7,
max_tokens: 1000,
max_tokens: 500,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0
Expand Down

0 comments on commit b67d07c

Please sign in to comment.