From 309bf58c5abcf6743d8a4fae712c2afe832ef808 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 29 Aug 2024 08:46:11 -0700 Subject: [PATCH] Add tweetify script for generating social media posts (#673) * Add tweetify script for generating social media posts and its npm script entry * update trace info * updated --- package.json | 3 +- packages/cli/src/run.ts | 2 +- packages/sample/genaisrc/tweetify.genai.mts | 38 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 packages/sample/genaisrc/tweetify.genai.mts diff --git a/package.json b/package.json index f2eff70ff5..b149a9002b 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "genai:blog-post": "node packages/cli/built/genaiscript.cjs run blog-generator", "genai:readme": "node packages/cli/built/genaiscript.cjs run readme-updater", "genai:blogify": "node packages/cli/built/genaiscript.cjs run blogify-sample --no-cache", + "genai:tweetify": "node packages/cli/built/genaiscript.cjs run tweetify --no-cache", "gcm": "node packages/cli/built/genaiscript.cjs run gcm" }, "release-it": { @@ -79,4 +80,4 @@ "glob": "^11.0.0", "zx": "^8.1.4" } -} +} \ No newline at end of file diff --git a/packages/cli/src/run.ts b/packages/cli/src/run.ts index 4731f01a1d..759d6f17da 100644 --- a/packages/cli/src/run.ts +++ b/packages/cli/src/run.ts @@ -66,7 +66,7 @@ import { resolveTokenEncoder } from "../../core/src/encoders" import { writeFile } from "fs/promises" async function setupTraceWriting(trace: MarkdownTrace, filename: string) { - logVerbose(`writing trace to ${filename}`) + logVerbose(`trace: ${filename}`) await ensureDir(dirname(filename)) await writeFile(filename, "", { encoding: "utf-8" }) trace.addEventListener( diff --git a/packages/sample/genaisrc/tweetify.genai.mts b/packages/sample/genaisrc/tweetify.genai.mts new file mode 100644 index 0000000000..5893a61cb2 --- /dev/null +++ b/packages/sample/genaisrc/tweetify.genai.mts @@ -0,0 +1,38 @@ +script({ + model: "openai:gpt-4", + title: "tweetify", + tools: ["fs", "md"], + description: "Generates a tweet about a documentation page", +}) + +def("DOC", env.files) + +$` +## Persona + +You are an expert at the GenAIScript project and also a social media expert. + +## Task + +Generate social media announcements for the documentation page or blog post in DOC. + +- generate a Twitter/X post +- generate a LinkedIn post + +## Instructions + +- make sure to adjust the tone for each social platform +- add link to the documentation page +- use emojis +- add hashtags, all lowercase +- don't be excited +- don't announce blog posts, mention content + +## Information + +- the documentation is in markdown and has frontmatter: docs/src/content/docs/**/*.md* +- the documentation routing is docs/src/content/docs/**/.md* becomes https://microsoft.github.io/genaiscript/. +- the genaiscript type definition: genaiscript/genaiscript.d.ts. Assume that all globals are ambient. Do not import or require genaiscript module. +- the genaiscript samples: packages/sample/src/*.genai.* + +` \ No newline at end of file