-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1965ebe
commit ec55e0d
Showing
7 changed files
with
324 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# dependencies | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
# Festive-Greeting | ||
# Festive-Greeting | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: Vishalk91-4/Festive-Greeting | ||
with: | ||
prompt: 'Vishal is a dear friend of mine, Diwali' | ||
api-key: ${{ secrets.AI_API_KEY }} | ||
endpoint: ${{ secrets.AI_ENDPOINT }} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: 'Festive Greetings' | ||
description: 'Generate Festival greetings with OpenAI' | ||
inputs: | ||
prompt: # id of input | ||
description: 'Let the AI know who the message is for and provide context about the person.' | ||
required: true | ||
default: 'Vishal is a friend of mine' | ||
api-key: | ||
description: 'The API key for the OpenAI API' | ||
required: true | ||
default: '0123456789' | ||
endpoint: | ||
description: 'Your endpoint for the Azure OpenAI API' | ||
required: true | ||
default: '' | ||
outputs: | ||
seasons-greeting: # id of output | ||
description: 'The AI generated Festival greeting' | ||
runs: | ||
using: 'node20' | ||
main: 'index.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const httpm = require('@actions/http-client'); | ||
|
||
async function makePostRequest() { | ||
const prompt = core.getInput('prompt'); | ||
const apikey = core.getInput('api-key'); | ||
const endpoint = core.getInput('endpoint'); | ||
|
||
let http = new httpm.HttpClient('http-client'); | ||
let data = { | ||
messages: [ | ||
{ role: 'system', content: 'You generate short Festival greeting. The message should be 160 characters or less to fit into an SMS. The user will tell you who the message is for and will provide more context if needed. You will only answer with the text for the sms, nothing else.' }, | ||
{ role: 'user', content: 'Mother, haven\'t seen her for a long time, Birthday' }, | ||
{ role: 'assistant', content: 'Merry Birthday Mum! I miss you! 🎂 ' }, | ||
{ role: 'user', content: 'Laura, is a colleague of mine, Christmas' }, | ||
{ role: 'assistant', content: 'Have a great Holiday Season Laura! Thanks for the great partnership this year. 🎁✨' }, | ||
{ role: 'user', content: prompt } | ||
], | ||
max_tokens: 800, | ||
temperature: 0.7, | ||
frequency_penalty: 0, | ||
presence_penalty: 0, | ||
top_p: 0.95, | ||
stop: null | ||
}; | ||
let headers = { | ||
'Content-Type': 'application/json', | ||
'api-key': apikey | ||
}; | ||
|
||
let res = await http.postJson(endpoint, data, headers); | ||
return res.result; | ||
} | ||
|
||
try { | ||
makePostRequest().then(response => { | ||
let message = response.choices[0].message.content; | ||
console.log(message); | ||
core.setOutput("seasons-greeting", message); | ||
}).catch(error => { | ||
core.setFailed(error.message); | ||
}); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "festive-greeting", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@actions/core": "^1.10.1", | ||
"@actions/github": "^6.0.0", | ||
"@actions/http-client": "^2.2.0" | ||
} | ||
} |