From b0c75cdec816889dd4eaac0fb63c7852a32f4d92 Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Fri, 10 May 2024 17:22:27 -0700 Subject: [PATCH] feat: refactor text-only Gemini prompt --- generative-ai/snippets/gemini-text-input.js | 21 +++---------------- .../snippets/test/gemini-text-input.test.js | 4 ++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/generative-ai/snippets/gemini-text-input.js b/generative-ai/snippets/gemini-text-input.js index bd68384d99..1489b1ab67 100644 --- a/generative-ai/snippets/gemini-text-input.js +++ b/generative-ai/snippets/gemini-text-input.js @@ -25,25 +25,10 @@ async function generate_from_text_input(projectId = 'PROJECT_ID') { model: 'gemini-1.0-pro-002', }); - // Does the returned sentiment score match the reviewer's movie rating? - const textPart = { - text: ` - Give a score from 1 - 10 to suggest if the following movie review is - negative or positive (1 is most negative, 10 is most positive, 5 will be - neutral). Include an explanation. + const prompt = + "What's a good name for a flower shop that specializes in selling bouquets of dried flowers?"; - The movie takes some time to build, but that is part of its beauty. By the - time you are hooked, this tale of friendship and hope is thrilling and - affecting, until the very last scene. You will find yourself rooting for - the hero every step of the way. This is the sharpest, most original - animated film I have seen in years. I would give it 8 out of 10 stars.`, - }; - - const request = { - contents: [{role: 'user', parts: [textPart]}], - }; - - const resp = await generativeModel.generateContent(request); + const resp = await generativeModel.generateContent(prompt); const contentResponse = await resp.response; console.log(JSON.stringify(contentResponse)); } diff --git a/generative-ai/snippets/test/gemini-text-input.test.js b/generative-ai/snippets/test/gemini-text-input.test.js index 142467a380..26b0271d02 100644 --- a/generative-ai/snippets/test/gemini-text-input.test.js +++ b/generative-ai/snippets/test/gemini-text-input.test.js @@ -21,8 +21,8 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const projectId = process.env.CAIP_PROJECT_ID; -describe('Get sentiment score from text input', async () => { - it('should get sentiment score from text input', async () => { +describe('Get store name ideas from text input prompt', async () => { + it('should get store name ideas from text input prompt', async () => { const output = execSync(`node ./gemini-text-input.js ${projectId}`); assert(output.length > 0);