From f8b5dd88f5744d7adc2fcfd5dc114a036207c91d Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:20:12 +0200 Subject: [PATCH 1/7] added gitignore --- .../agents/marketing-campaign-tailoring-agent/.gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/.gitignore diff --git a/examples/agents/marketing-campaign-tailoring-agent/.gitignore b/examples/agents/marketing-campaign-tailoring-agent/.gitignore new file mode 100644 index 00000000..c256453b --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/.gitignore @@ -0,0 +1,8 @@ +# baseai +**/.baseai/ +node_modules +.env +package-lock.json +pnpm-lock.yaml +# env file +.env From 1ecd061185009bfec87cfa375fccd77e3f953b4d Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:20:22 +0200 Subject: [PATCH 2/7] added env example file --- .../.env.baseai.example | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/.env.baseai.example diff --git a/examples/agents/marketing-campaign-tailoring-agent/.env.baseai.example b/examples/agents/marketing-campaign-tailoring-agent/.env.baseai.example new file mode 100644 index 00000000..8c643651 --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/.env.baseai.example @@ -0,0 +1,21 @@ +# !! SERVER SIDE ONLY !! +# Keep all your API keys secret — use only on the server side. + +# TODO: ADD: Both in your production and local env files. +# Langbase API key for your User or Org account. +# How to get this API key https://langbase.com/docs/api-reference/api-keys +LANGBASE_API_KEY= + +# TODO: ADD: LOCAL ONLY. Add only to local env files. +# Following keys are needed for local pipe runs. For providers you are using. +# For Langbase, please add the key to your LLM keysets. +# Read more: Langbase LLM Keysets https://langbase.com/docs/features/keysets +OPENAI_API_KEY= +ANTHROPIC_API_KEY= +COHERE_API_KEY= +FIREWORKS_API_KEY= +GOOGLE_API_KEY= +GROQ_API_KEY= +MISTRAL_API_KEY= +PERPLEXITY_API_KEY= +TOGETHER_API_KEY= From d1f919033cd27c411d5588d264e983d050624f0a Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:20:59 +0200 Subject: [PATCH 3/7] main for marketing-campaign-tailoring-agent cli --- .../index.ts | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/index.ts diff --git a/examples/agents/marketing-campaign-tailoring-agent/index.ts b/examples/agents/marketing-campaign-tailoring-agent/index.ts new file mode 100644 index 00000000..43e73263 --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/index.ts @@ -0,0 +1,57 @@ +import 'dotenv/config'; +import { Pipe } from '@baseai/core'; +import inquirer from 'inquirer'; +import ora from 'ora'; +import chalk from 'chalk'; +import pipeMarketingCampaignTailoringAgent from './baseai/pipes/marketing-campaign-tailoring-agent'; + + +const pipe = new Pipe(pipeMarketingCampaignTailoringAgent()); + +async function main() { + + const initialSpinner = ora('Connecting to marketing-campaign-tailoring-agent ...').start(); + try { + const { completion: initialMctAgentResponse } = await pipe.run({ + messages: [{ role: 'user', content: 'Hello how can I user your services?' }], + }); + initialSpinner.stop(); + console.log(chalk.cyan('Agent response...')); + console.log(initialMctAgentResponse); + } catch (error) { + initialSpinner.stop(); + console.error(chalk.red('Error processing initial request:'), error); + } + + while (true) { + const { userMsg } = await inquirer.prompt([ + { + type: 'input', + name: 'userMsg', + message: chalk.blue('Enter your query (or type "exit" to quit):'), + }, + ]); + + if (userMsg.toLowerCase() === 'exit') { + console.log(chalk.green('Goodbye!')); + break; + } + + const spinner = ora('Processing your request...').start(); + + try { + const { completion: mctAgentResponse } = await pipe.run({ + messages: [{ role: 'user', content: userMsg }], + }); + + spinner.stop(); + console.log(chalk.cyan('Agent:')); + console.log(mctAgentResponse); + } catch (error) { + spinner.stop(); + console.error(chalk.red('Error processing your request:'), error); + } + } +} + +main(); \ No newline at end of file From fbcf00bb88138f11578eeddd72a457fdeb73e2cc Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:21:10 +0200 Subject: [PATCH 4/7] added packages for marketing-campaign-tailoring-agent cli --- .../package.json | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/package.json diff --git a/examples/agents/marketing-campaign-tailoring-agent/package.json b/examples/agents/marketing-campaign-tailoring-agent/package.json new file mode 100644 index 00000000..7d582341 --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/package.json @@ -0,0 +1,22 @@ +{ + "name": "marketing-campaign-tailoring-agent", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "baseai": "baseai" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "@baseai/core": "^0.9.3", + "dotenv": "^16.4.5", + "inquirer": "^12.0.0", + "ora": "^8.1.0" + }, + "devDependencies": { + "baseai": "^0.9.3" + } +} From 50ac097653b89e7703f4d33bc2a48d110ecd78d8 Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:21:20 +0200 Subject: [PATCH 5/7] added readme for marketing-campaign-tailoring-agent cli --- .../README.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/README.md diff --git a/examples/agents/marketing-campaign-tailoring-agent/README.md b/examples/agents/marketing-campaign-tailoring-agent/README.md new file mode 100644 index 00000000..96395fea --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/README.md @@ -0,0 +1,53 @@ +![Marketing Campaign Tailoring Agent by ⌘ BaseAI][cover] + +![License: MIT][mit] [![Fork on ⌘ Langbase][fork]][pipe] + +## Build a Marketing Campaign Tailoring Agent with BaseAI framework — ⌘ Langbase + +This AI Agent is built using the BaseAI framework. It leverages an agentic pipe that integrates over 30+ LLMs (including OpenAI, Gemini, Mistral, Llama, Gemma, etc.) and can handle any data, with context sizes of up to 10M+ tokens, supported by memory. The framework is compatible with any front-end framework (such as React, Remix, Astro, Next.js), giving you, as a developer, the freedom to tailor your AI application exactly as you envision. + +## Features + +- Marketing Campaign Tailoring Agent — Built with [BaseAI framework and agentic Pipe ⌘ ][qs]. +- Composable Agents — build and compose agents with BaseAI. +- Add and Sync deployed pipe on Langbase locally npx baseai@latest add ([see the Code button][pipe]). + +## Learn more + +1. Check the [Learning path to build an agentic AI pipe with ⌘ BaseAI][learn] +2. Read the [source code on GitHub][gh] for this agent example +3. Go through Documentaion: [Pipe Quick Start][qs] +4. Learn more about [Memory features in ⌘ BaseAI][memory] +5. Learn more about [Tool calls support in ⌘ BaseAI][toolcalls] + + +> NOTE: +> This is a BaseAI project, you can deploy BaseAI pipes, memory and tool calls on Langbase. + +--- + +## Authors + +This project is created by [Langbase][lb] team members, with contributions from: + +- Muhammad-Ali Danish - Software Engineer, [Langbase][lb]
+**_Built by ⌘ [Langbase.com][lb] — Ship hyper-personalized AI assistants with memory!_** + + +[lb]: https://langbase.com +[pipe]: https://langbase.com/examples/marketing-campaign-tailoring-agent +[gh]: https://github.com/LangbaseInc/baseai/tree/main/examples/agents/marketing-campaign-tailoring-agent +[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/baseai/baseai-cover.png +[download]:https://download-directory.github.io/?url=https://github.com/LangbaseInc/baseai/tree/main/examples/agents/marketing-campaign-tailoring-agent +[learn]:https://baseai.dev/learn +[memory]:https://baseai.dev/docs/memory/quickstart +[toolcalls]:https://baseai.dev/docs/tools/quickstart +[deploy]:https://baseai.dev/docs/deployment/authentication +[signup]: https://langbase.fyi/io +[qs]:https://baseai.dev/docs/pipe/quickstart +[docs]:https://baseai.dev/docs +[xaa]:https://x.com/MrAhmadAwais +[xab]:https://x.com/AhmadBilalDev +[local]:http://localhost:9000 +[mit]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=%23000000 +[fork]: https://img.shields.io/badge/FORK%20ON-%E2%8C%98%20Langbase-000000.svg?style=for-the-badge&logo=%E2%8C%98%20Langbase&logoColor=000000 \ No newline at end of file From e484bd66397e21246f7f8a294aacdeebad12b640 Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:21:49 +0200 Subject: [PATCH 6/7] logging switched off for marketing-campaign-tailoring-agent cli --- .../baseai/baseai.config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/baseai/baseai.config.ts diff --git a/examples/agents/marketing-campaign-tailoring-agent/baseai/baseai.config.ts b/examples/agents/marketing-campaign-tailoring-agent/baseai/baseai.config.ts new file mode 100644 index 00000000..3c0328bc --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/baseai/baseai.config.ts @@ -0,0 +1,18 @@ +import type { BaseAIConfig } from 'baseai'; + +export const config: BaseAIConfig = { + log: { + isEnabled: false, + logSensitiveData: false, + pipe: true, + 'pipe.completion': true, + 'pipe.request': true, + 'pipe.response': true, + tool: true, + memory: true + }, + memory: { + useLocalEmbeddings: false + }, + envFilePath: '.env' +}; From f131973f9e1ed4d31d4ce011b3732276ae0da447 Mon Sep 17 00:00:00 2001 From: ali Date: Sat, 19 Oct 2024 04:22:04 +0200 Subject: [PATCH 7/7] baseai pipe config for marketing-campaign-tailoring-agent cli --- .../marketing-campaign-tailoring-agent.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/agents/marketing-campaign-tailoring-agent/baseai/pipes/marketing-campaign-tailoring-agent.ts diff --git a/examples/agents/marketing-campaign-tailoring-agent/baseai/pipes/marketing-campaign-tailoring-agent.ts b/examples/agents/marketing-campaign-tailoring-agent/baseai/pipes/marketing-campaign-tailoring-agent.ts new file mode 100644 index 00000000..f4b12e59 --- /dev/null +++ b/examples/agents/marketing-campaign-tailoring-agent/baseai/pipes/marketing-campaign-tailoring-agent.ts @@ -0,0 +1,42 @@ +import { PipeI } from '@baseai/core'; + +const pipeMarketingCampaignTailoringAgent = (): PipeI => ({ + // Replace with your API key https://langbase.com/docs/api-reference/api-keys + apiKey: process.env.LANGBASE_API_KEY!, + name: `marketing-campaign-tailoring-agent`, + description: `MCT Agent, helps you tailor your marketing campaign on popular social media platform, with CTAs to track to campaign strategy.`, + status: `private`, + model: `openai:gpt-4o-mini`, + stream: true, + json: false, + store: true, + moderate: true, + top_p: 1, + max_tokens: 1000, + temperature: 0.7, + presence_penalty: 0, + frequency_penalty: 0, + stop: [], + tool_choice: 'auto', + parallel_tool_calls: true, + messages: [ + { + role: 'system', + content: + 'You are an AI assistant specializing in creating tailored marketing campaigns for various popular platforms like X (formerly Twitter), Facebook, TikTok, LinkedIn, and WhatsApp. Your role is to help users create and adapt marketing messages, product descriptions, or content specifically designed for different audiences and platforms. Follow the guidelines below to generate platform-appropriate campaigns:\n\n## Guidelines:\n\n1. **Understand the Product**: Analyze the product description or content provided by the user. The user may describe the product, attach details, or specify a narrative they want to convey. Ask clarifying questions if needed to get a clearer understanding of the product specifics.\n\n2. **Audience Segmentation**: Help the user define or refine different audience categories they want to target (e.g., professionals on LinkedIn, Gen Z on TikTok, casual users on Facebook, etc.). Understand the needs, behaviors, and preferences of each audience segment.\n\n3. **Platform Customization**: Tailor the core message or content to match the unique tone, style, and format of each platform. Use platform-specific best practices:\n - **X (Twitter)**: Short, concise messaging with hashtags and mentions for maximum engagement.\n - **Facebook**: Friendly, engaging narratives, and visual-heavy content, leveraging groups or ads.\n - **TikTok**: Highly visual, trend-based, and engaging short-form video content that is informal and fun.\n - **LinkedIn**: Professional, informative, and solution-focused content, often geared towards B2B interactions.\n - **WhatsApp**: Personalized, direct, and conversational messaging for one-on-one or group interactions.\n\n4. **Message Tailoring**: Adapt the product’s narrative to resonate with each audience segment. Consider the following factors:\n - **Tone**: Adjust the tone to suit the platform (e.g., casual on TikTok, professional on LinkedIn).\n - **Content Length**: Short-form content for platforms like X and TikTok; longer, detailed posts for LinkedIn.\n - **Visuals and Media**: Ensure the right type of media (images, videos, GIFs) is suggested or included, optimized for each platform.\n\n5. **Call to Action (CTA)**: Help the user create compelling CTAs for each platform. Adapt the CTA based on the audience and platform (e.g., "Swipe up to learn more" on TikTok, "Download our whitepaper" on LinkedIn).\n\n6. **Multi-Channel Consistency**: Ensure that while the messaging is tailored for each platform, the core theme of the campaign remains consistent across channels.\n\n7. **Provide Recommendations**: Offer suggestions on message style, platform-specific keywords, hashtags, or even content schedules based on platform norms and audience behaviors.\n\n8. **Menu for Platform Selection**: Ask the user if they would like to focus on specific platforms (e.g., X, Facebook, LinkedIn) or if they want to tailor the message for all platforms. Provide a list of options for easy selection:\n - Option 1: X (formerly Twitter)\n - Option 2: Facebook\n - Option 3: TikTok\n - Option 4: LinkedIn\n - Option 5: WhatsApp\n - Option 6: All of the above\n\n9. **Feedback Loop**: Ask the user for feedback on the tailored messages and refine them if necessary. Adjust tone, content, or format based on user inputs.\n\n## When the user provides a message or product description, respond with:\n\n1. **Platform-Specific Campaign Suggestions**: Provide tailored versions of the user\'s message/content for each specified platform (X, Facebook, TikTok, LinkedIn, WhatsApp).\n2. **Audience-Specific Targeting Tips**: Suggest audience segmentation and best practices for each platform (e.g., appealing to Gen Z on TikTok, professionals on LinkedIn).\n3. **Media Recommendations**: Offer suggestions on visual or media formats for each platform (e.g., vertical video for TikTok, infographics for LinkedIn).\n4. **Call to Action**: Provide customized calls to action that best fit each platform and audience segment.\n\n5. **Menu for Platform Focus**: Offer a selection of platforms based on user preference to target one or multiple channels.\n\n**Example Input**: "We want to launch a new eco-friendly water bottle. Our key message is its sustainable design and durability. We want to target young professionals on LinkedIn, eco-conscious consumers on Facebook, and Gen Z on TikTok."\n\n**Example Output**:\n\n- **LinkedIn**: "Introducing our new eco-friendly water bottle – designed for the professional on the go. Durable, sleek, and sustainable. Join the movement towards a greener workplace. #Sustainability #EcoFriendlyWorkplace"\n- **Facebook**: "Our new water bottle isn\'t just another bottle – it\'s a commitment to sustainability. Durable, eco-friendly, and built to last, it’s perfect for those who care about the planet. Learn more and make a difference today!"\n- **TikTok**: [30-second video suggestion]: A quick demonstration of the bottle’s features with popular music. "Why settle for ordinary when you can go green? 🌍♻️ Check out our eco-friendly water bottle that\'s as tough as it is sustainable. #EcoVibes #Sustainability #ForThePlanet"\n\n---\n\n**Is there a specific platform you\'d like to focus on, or should I provide tailored suggestions for all of them?** \nPlease choose one of the following options:\n1. X (formerly Twitter)\n2. Facebook\n3. TikTok\n4. LinkedIn\n5. WhatsApp\n6. All of the above\n' + }, + { name: 'json', role: 'system', content: '' }, + { name: 'safety', role: 'system', content: '' }, + { + name: 'opening', + role: 'system', + content: 'Welcome to Langbase. Prompt away!' + }, + { name: 'rag', role: 'system', content: '' } + ], + variables: [], + tools: [], + memory: [] +}); + +export default pipeMarketingCampaignTailoringAgent;