Skip to content

Commit f98cce0

Browse files
committed
chore: add support for disabling sending email
1 parent 5387db7 commit f98cce0

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

api/src/functions/assistant.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ const mailer = require("./mailer");
1111
const {
1212
ASSISTANT_ID,
1313
AZURE_DEPLOYMENT_NAME,
14-
EMAIL_RECEIVER
14+
EMAIL_RECEIVER,
15+
OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL
1516
} = process.env;
1617

1718
// Important: Errors handlings are removed intentionally. If you are using this sample in production
@@ -213,6 +214,11 @@ async function getStockPrice(symbol) {
213214
}
214215

215216
async function writeAndSendEmail(subject, html) {
217+
if (OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL === 'true') {
218+
console.log('Dry mode emabled. Skip sending emails');
219+
return 'Fake email sent!!';
220+
}
221+
216222
const info = await mailer.sendEmail({
217223
to: EMAIL_RECEIVER, subject, html
218224
});

infra/main.bicep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var assistantGpt = {
2727
deploymentCapacity: 10
2828
}
2929

30+
param OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL string = 'true' // Set in main.parameters.json
3031
param openAiLocation string // Set in main.parameters.json
3132
param openAiSkuName string = 'S0'
3233
param openAiUrl string = ''
@@ -77,6 +78,7 @@ module api './core/host/functions.bicep' = {
7778
AZURE_OPENAI_ENDPOINT: finalOpenAiUrl
7879
AZURE_DEPLOYMENT_NAME: assistantGpt.deploymentName
7980
OPENAI_API_VERSION: openAiApiVersion
81+
OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL: OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL
8082
}
8183
}
8284
dependsOn: empty(openAiUrl) ? [] : [openAi]

infra/main.parameters.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
},
3232
"azureDeploymentName": {
3333
"value": "${AZURE_DEPLOYMENT_NAME=gpt-35-turbo}"
34+
},
35+
"OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL": {
36+
"value": "${OPENAI_FUNCTION_CALLING_SKIP_SEND_EMAIL=true}"
3437
}
3538
}
3639
}

0 commit comments

Comments
 (0)