Skip to content

Commit

Permalink
Adding new command: describe
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Apr 6, 2023
1 parent e08b081 commit 6561f6e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sam-patterns-cli",
"version": "0.0.41",
"version": "0.0.42",
"description": "Command line interface for quickly using patterns from https://github.com/aws-samples/serverless-patterns/",
"main": "index.js",
"scripts": {
Expand Down
19 changes: 18 additions & 1 deletion src/commands/describe/describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,29 @@ async function run(cmd) {
apiKey,
});
const openai = new OpenAIApi(configuration);
let easterEggPrompt = "";
if (cmd["🥚"]) {
const funWaysOfDescribingSOmethingBoring = [
"as a romantic poem",
"as a joke",
"in the melody of God Save the Queen",
"in the style of Ivor Cutler",
"in the style of a 1980s computer game",
"in the style of an angry teenager",
"making heavy references to the Easter Bunny",
]
easterEggPrompt = funWaysOfDescribingSOmethingBoring[Math.floor(Math.random() * funWaysOfDescribingSOmethingBoring.length)];

console.log("Alright, I'll do this " + easterEggPrompt);

easterEggPrompt = " Do it " + easterEggPrompt;
}
const openAiRequest = {
model: cmd.model,
messages: [
{
role: "user",
content: `In three sections, describe what the template does, if there are any security issues and how it can be improved: ${template}`,
content: `In three sections, describe what the template does, if there are any security issues and how it can be improved: ${template}.${easterEggPrompt}`,
}
],
temperature: 0.5,
Expand Down
1 change: 1 addition & 0 deletions src/commands/describe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ program
.option("-t, --template [template]", "SAM template file", "template.yaml")
.option("-r, --repository-path [repository]", "Github repository path, i.e \"aws-samples/serverless-patterns/apigw-sfn\"")
.option("-m, --model [model]", "OpenAI model to use. Valid values are 'gpt-3.5-turbo' and 'gpt-4'. Note that gpt-3.5-turbo is fine for most use cases and that gpt-4 is slower and more expensive", "gpt-3.5-turbo")
.option("--🥚", "Easter egg")
.description("Describes a SAM template using ChatGPT")
.action(async (cmd) => {
await describe.run(cmd);
Expand Down

0 comments on commit 6561f6e

Please sign in to comment.