Skip to content

Commit

Permalink
fix: summarizer formatting #231
Browse files Browse the repository at this point in the history
- Replaced generated summary with last working static due to unexpected breaking change
  - vercel/ai#1316

Link #231
  • Loading branch information
srizvi committed Apr 14, 2024
1 parent be3f62c commit cbc3a26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
20 changes: 5 additions & 15 deletions apps/web/src/content/warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interface Review {
serviceOutcomes: string[];
}

export function calculateNPSAndCounts(reviews: Review[]): {
export function calculateNPSAndCounts(): {
nps: number;
promoters: number;
passives: number;
Expand All @@ -83,20 +83,10 @@ export function calculateNPSAndCounts(reviews: Review[]): {
relativeNPS: number;
benchmarkNPS: number;
} {
const totalRespondents = reviews.length;
let promoters = 0;
let passives = 0;
let detractors = 0;

reviews.forEach((review) => {
if (review.nps >= 9) {
promoters++;
} else if (review.nps > 6 && review.nps < 9) {
passives++;
} else if (review.nps <= 6) {
detractors++;
}
});
const promoters = 58;
const passives = 0;
const detractors = 1;
const totalRespondents = promoters + passives + detractors;

const nps = ((promoters - detractors) / totalRespondents) * 100;
const benchmarkNPS = 76; // According to retently https://rizv.io/1iKd8T
Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/ui/ai/ai-review-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface Props {
summary: string;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default function AIReviewSummary({ summary }: Props) {
const {
nps,
Expand All @@ -73,7 +74,7 @@ export default function AIReviewSummary({ summary }: Props) {
<CardHeader className="mt-4 items-center gap-4 space-y-0 p-0">
<div className="grid gap-1 text-center">
<CardTitle className="flex flex-col font-mono text-2xl font-semibold tracking-tighter">
Mock Net Promoter Score
Mock NPS Analysis
</CardTitle>
<CardDescription className="flex flex-col items-center gap-2">
<span className="flex justify-center text-xs">
Expand All @@ -87,8 +88,12 @@ export default function AIReviewSummary({ summary }: Props) {
</CardHeader>
<CardContent className="grid gap-4 p-0">
<div className="mt-2 text-pretty text-sm leading-loose text-secondary-foreground">
{summary} Yo! CXO&apos;s NPS of {nps} is {relativeNPS} points above
the relative{' '}
{/* summary TODO: https://github.com/vercel/ai/issues/1316 */}Clients
of Yo! CXO say that their growth strategies are alright. They only
found a large untapped market segment and doubled the customer base.
But now the clients have to upgrade their CRM and customer service
platforms to accommodate the surge in users too. Yo! CXO&apos;s NPS of{' '}
{nps} is {relativeNPS} points above the relative{' '}
<a
className="hover:text-primary hover:underline hover:decoration-2 hover:underline-offset-4"
href="https://www.retently.com/blog/good-net-promoter-score/"
Expand Down

0 comments on commit cbc3a26

Please sign in to comment.