Skip to content

Commit

Permalink
Code cleanup, no need to duplcate rawdata.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatu Päkkilä committed Nov 5, 2023
1 parent 22cdc18 commit b916bd1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!' };
Expand Down
4 changes: 2 additions & 2 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
export const queryOpenAI = async (url: string, prompt: string): Promise<string> => {
try {
const payload = {
"messages": [{
Expand All @@ -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.';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b916bd1

Please sign in to comment.