diff --git a/src/components/GenerateEmailButton.tsx b/src/components/GenerateEmailButton.tsx index 1db6cab..75584da 100644 --- a/src/components/GenerateEmailButton.tsx +++ b/src/components/GenerateEmailButton.tsx @@ -3,7 +3,7 @@ import { EnvelopeIcon, HeartIcon } from '@heroicons/react/24/solid'; import { useState } from 'react'; import { type Review } from 'types'; -import { type AnalyzeEmailOutputOptions } from '~/server/google-ai/generate-email'; +import { type GenerateEmailOutputOptions } from '~/server/google-ai/generate-email'; interface GenerateEmailButtonProps { variant: 'thank-you' | 'follow-up'; @@ -28,7 +28,7 @@ export const GenerateEmailButton = ({ emailType: isThankYou ? 'thank-you' : 'follow-up', }), }) - .then((res) => res.json() as Promise) + .then((res) => res.json() as Promise) .then((res) => { const { body, subject } = res; diff --git a/src/components/ReviewDetail.tsx b/src/components/ReviewDetail.tsx index ff4c6ab..c037079 100644 --- a/src/components/ReviewDetail.tsx +++ b/src/components/ReviewDetail.tsx @@ -1,8 +1,6 @@ 'use client'; -import { Box, Button } from '@bigcommerce/big-design'; -import { CloseIcon } from '@bigcommerce/big-design-icons'; -import { CheckIcon } from '@heroicons/react/24/solid'; +import { Box } from '@bigcommerce/big-design'; import clsx from 'clsx'; import { useState } from 'react'; import GaugeComponent from 'react-gauge-component'; diff --git a/src/server/google-ai/generate-email.ts b/src/server/google-ai/generate-email.ts index acc87b0..f423719 100644 --- a/src/server/google-ai/generate-email.ts +++ b/src/server/google-ai/generate-email.ts @@ -6,7 +6,7 @@ import { env } from '~/env.mjs'; const MODEL_NAME = 'models/text-bison-001'; const API_KEY = env.GOOGLE_API_KEY; -const analyzeReviewInputSchema = z.object({ +const generateEmailInputSchema = z.object({ rating: z.number(), title: z.string(), text: z.string(), @@ -14,40 +14,40 @@ const analyzeReviewInputSchema = z.object({ emailType: z.string(), }); -type AnalyzeReviewInputOptions = z.infer; +type GenerateEmailInputOptions = z.infer; -const analyzeEmailOutputSchema = z.object({ +const generateEmailOutputSchema = z.object({ subject: z.string(), body: z.string(), }); -export type AnalyzeEmailOutputOptions = z.infer< - typeof analyzeEmailOutputSchema +export type GenerateEmailOutputOptions = z.infer< + typeof generateEmailOutputSchema >; export async function generateAISuggestedEmail( - options: AnalyzeReviewInputOptions + options: GenerateEmailInputOptions ) { const promptEmailBody = `Role: E-commerce customer care expert analyzing product reviews and outputting a result as a string. - - Task: Based on the input provided, generate a suggested email body response to the customer. - Input Format: +Task: Based on the input provided, generate a suggested email body response to the customer. Only provide information based on data you are provided with, don't invent or assume any facts, and don't include any placeholders. The email signature should be "Sincerely, the ildecimo team". - - "Title": The review title. - - "Body": The review body text. - - "Rating": The review rating, out of 5. - - "Customer": The customer's name. - - "Email Type": The type of email to send to the customer. This can be one of the following: "Thank you email" or "Follow-up email". +Input Format: - Output Format: string +- "Review title": The review title. +- "Review description": The review body text. +- "Review Rating": The review rating, out of 5. +- "Customer Name": The customer's name. +- "Email Type": The type of email to send to the customer. This can be one of the following: "Thank you email" or "Follow-up email". - Input Data: - - "Review Title:" ${options.title}, - - "Review Description": ${options.text}, - - "Review Rating": ${options.rating}, - - "Customer Name": ${options.customer}, - - "Email Type": ${options.emailType} +Output Format: string + +Input Data: +- "Review Title:" ${options.title}, +- "Review Description": ${options.text}, +- "Review Rating": ${options.rating}, +- "Customer Name": ${options.customer}, +- "Email Type": ${options.emailType} `; const promptEmailSubject = ( @@ -92,17 +92,17 @@ export async function generateAISuggestedEmail( if (env.NODE_ENV === 'development') { console.log( - '*** [Vertex Review Analysis Output Subject] ::', + '*** [Vertex Generate Email Output Subject] ::', outputEmailSubject ); console.log( - '*** [Vertex Review Analysis Output Body] ::', + '*** [Vertex Generate Email Output Body] ::', outputEmailBody ); } if (outputEmailBody) { - const parsedOutput = analyzeEmailOutputSchema.safeParse({ + const parsedOutput = generateEmailOutputSchema.safeParse({ subject: outputEmailSubject, body: outputEmailBody, });