From 25e1066c1cd39de4b9e010ed310141235376167d Mon Sep 17 00:00:00 2001 From: Mitch Lombardi Date: Fri, 6 Dec 2024 15:13:14 -0500 Subject: [PATCH] chore(common): CPX-1217 Update Gemini model Co-authored-by: Kevin Carr --- README.md | 13 +++++++------ src/server/google-ai/index.ts | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3782937..0312ba3 100644 --- a/README.md +++ b/README.md @@ -24,21 +24,22 @@ To run the app locally, follow these instructions: - Load Callback URL: `https://{ngrok_id}.ngrok.app/api/app/load` - Uninstall Callback URL: `https://{ngrok_id}.ngrok.app/api/app/uninstall` - Configure the following OAuth scopes as directed in [Setup:](https://developer.bigcommerce.com/app-extensions/guide#setup) + - App Extensions: Manage + - Products: Manage 3. Copy `.env.example` to `.env`. 4. [Replace `CLIENT_ID` and `CLIENT_SECRET` in `.env`](https://devtools.bigcommerce.com/my/apps) (from `View Client ID` in the dev portal). -5. Update `AUTH_REDIRECT` in `.env` with the ngrok `install` callback URL. -6. Enter a JWT secret in `.env`. +5. Enter a JWT secret in `.env`. - JWT key should be at least 32 random characters (256 bits) for HS256 -7. [Replace FIRE_API_KEY, FIRE_DOMAIN and FIRE_PROJECT_ID in .env](<[https://console.firebase.google.com](https://developer.bigcommerce.com/api-docs/apps/tutorials/build-a-nextjs-sample-app/step-3-integrate#set-up-firebase-database)>) -8. Replace GOOGLE_SERVICE_ACCOUNT_JSON_BASE64 in .env +6. [Replace FIRE_API_KEY, FIRE_DOMAIN and FIRE_PROJECT_ID in .env](https://developer.bigcommerce.com/api-docs/apps/tutorials/build-a-nextjs-sample-app/step-3-integrate#set-up-firebase-database) +7. Replace GOOGLE_SERVICE_ACCOUNT_JSON_BASE64 in .env - [Create a service account](https://cloud.google.com/iam/docs/service-accounts-create) - [Create a service account key](https://cloud.google.com/iam/docs/keys-create-delete) - Download the result json file, base64 encode it and replace GOOGLE_SERVICE_ACCOUNT_JSON_BASE64 in .env with the result string -9. Start your dev environment in a **separate** terminal from `ngrok`. If +8. Start your dev environment in a **separate** terminal from `ngrok`. If `ngrok` restarts, update callbacks in steps 2 and 5 with the new ngrok_id. - `npm run dev` -10. [Install the app and launch.](https://developer.bigcommerce.com/docs/3ef776e175eda-big-commerce-apps-quick-start#install-the-app) +9. [Install the app and launch.](https://developer.bigcommerce.com/docs/3ef776e175eda-big-commerce-apps-quick-start#install-the-app) ## Deploy with Vercel diff --git a/src/server/google-ai/index.ts b/src/server/google-ai/index.ts index bd34f5e..de1aee2 100644 --- a/src/server/google-ai/index.ts +++ b/src/server/google-ai/index.ts @@ -5,7 +5,7 @@ import { type aiSchema } from '~/app/api/generateDescription/schema'; import { VertexAI } from '@google-cloud/vertexai'; import { type JWTInput } from 'google-auth-library'; -const MODEL_NAME = 'gemini-1.5-pro-001'; +const MODEL_NAME = 'gemini-1.5-pro-002'; export default async function generateDescription( attributes: z.infer @@ -13,7 +13,7 @@ export default async function generateDescription( const input = prepareInput(attributes); const productAttributes = prepareProductAttributes(attributes); - const prompt = `Act as an e - commerce merchandising expert who writes product descriptions. + const prompt = `Act as an e-commerce merchandising expert who writes product descriptions. Task: Based on provided input parameters, write a product description styled in HTML. Response format: HTML. Input: ${input}.