From b916bd1ccf4a37e763dce055442060dddc45429f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tatu=20P=C3=A4kkil=C3=A4?= Date: Sun, 5 Nov 2023 13:10:27 +0200 Subject: [PATCH] Code cleanup, no need to duplcate rawdata. --- src/index.ts | 2 +- src/lib.ts | 4 ++-- src/openai.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 61c9af5..c9ad8d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,7 @@ export async function helloLunchChannelInternal() { const prompt = `Kuvaile näitä ruokalajeja lyhyesti mutta hauskasti ja anna suositus mitä syödä. Lisää viestiin ruokalajia kuvaava emoji. ${currentDayDishes} Tähän loppuun hauskasti sanottuna pyyntö reagoida emojilla, jos olet tulossa mukaan syömään!`; - const completion = await queryOpenAI(openAiUrl, prompt, currentDayDishes); + const completion = await queryOpenAI(openAiUrl, prompt); postToSlack(slackUrl, currentDayDishes, completion); return { body: 'Slakkiä spämmätty!' }; diff --git a/src/lib.ts b/src/lib.ts index 16f80c9..c851846 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -35,7 +35,7 @@ export const postToSlack = async (slackUrl: string, headline: string, message: s } }; -export const queryOpenAI = async (url: string, prompt: string, rawData: string): Promise => { +export const queryOpenAI = async (url: string, prompt: string): Promise => { try { const payload = { "messages": [{ @@ -61,7 +61,7 @@ export const queryOpenAI = async (url: string, prompt: string, rawData: string): } catch (error: any) { console.log('Error in OpenAI integration!'); console.log(error.message); - return 'Valitettavasti Azure OpenAI ei vastaa, mutta tässä lounaslista sellaisenaan: ' + rawData; + return 'Valitettavasti Azure OpenAI ei vastaa, mutta tässä lounaslista sellaisenaan.'; } } diff --git a/src/openai.ts b/src/openai.ts index c1da31e..d61589c 100644 --- a/src/openai.ts +++ b/src/openai.ts @@ -3,7 +3,7 @@ import { queryOpenAI } from "./lib"; const url = process.env.OPENAI_API_URL || ''; const prompt = process.argv[2] ?? 'Say this is a test'; -queryOpenAI(url, prompt, 'Test').then((completion) => { +queryOpenAI(url, prompt).then((completion) => { if (completion) { console.log('OpenAI response:'); console.log(completion);