From 67f1be5eb1d2c271426e1854d7ac26ad4fef35c8 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:46:03 +0100 Subject: [PATCH 1/7] added gitignore --- .../.gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/.gitignore diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/.gitignore b/examples/agents/marketing-campaign-a-b-test-generation-agent/.gitignore new file mode 100644 index 00000000..7f75343d --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-agent/.gitignore @@ -0,0 +1,8 @@ +# baseai +**/.baseai/ +node_modules +package-lock.json +pnpm-lock.yaml +# env file +.env + From 8f1612d38270818804b1a77c90b32c569f9ba92d Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:46:20 +0100 Subject: [PATCH 2/7] added baseai env example file --- .../.env.baseai.example | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/.env.baseai.example diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/.env.baseai.example b/examples/agents/marketing-campaign-a-b-test-generation-agent/.env.baseai.example new file mode 100644 index 00000000..8c643651 --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-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 00e4044fec5a32b45c7aee54b892c18911b4c5d3 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:46:48 +0100 Subject: [PATCH 3/7] main cli for marketing-campaign-a-b-test-generation-agent --- .../index.ts | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/index.ts diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/index.ts b/examples/agents/marketing-campaign-a-b-test-generation-agent/index.ts new file mode 100644 index 00000000..c5576a2e --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-agent/index.ts @@ -0,0 +1,73 @@ +import 'dotenv/config'; +import {Message, Pipe} from '@baseai/core'; +import inquirer from 'inquirer'; +import ora from 'ora'; +import chalk from 'chalk'; +import pipeMarketingCampaignABTestGenerationAgent from './baseai/pipes/marketing-campaign-a-b-test-generation-agent'; + + +const pipe = new Pipe(pipeMarketingCampaignABTestGenerationAgent()); + +async function main() { + const initialSpinner = ora( + 'Connecting to marketing-campaign-a-b-test-generation-agent...', + ).start(); + // Messages array for keeping track of the conversation + const messages: Message[] = [ + // Initial message to the agent + {role: 'user', content: 'Hello how can I use your services?'}, + ]; + + try { + const {completion} = await pipe.run({ + messages, + }); + + // Add the agent response to the messages array + messages.push({role: 'assistant', content: completion}); + + initialSpinner.stop(); + console.log(chalk.cyan('Agent response...')); + console.log(completion); + } 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(); + messages.push({role: 'user', content: userMsg}); + try { + const {completion: abGenAgentResponse} = await pipe.run({ + messages, + }); + messages.push({ + role: 'assistant', + content: abGenAgentResponse, + }); + spinner.stop(); + console.log(chalk.cyan('Agent:')); + console.log(abGenAgentResponse); + } catch (error) { + spinner.stop(); + console.error(chalk.red('Error processing your request:'), error); + } + } +} + +main(); From 54aefb59e4c4bdfda266ee974ba4e486d36cd421 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:46:58 +0100 Subject: [PATCH 4/7] added packages for marketing-campaign-a-b-test-generation-agent --- .../package.json | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/package.json diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/package.json b/examples/agents/marketing-campaign-a-b-test-generation-agent/package.json new file mode 100644 index 00000000..b4d029f0 --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-agent/package.json @@ -0,0 +1,21 @@ +{ + "name": "marketing-campaign-a-b-test-generation-agent", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "baseai": "baseai" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "@baseai/core": "^0.9.19", + "dotenv": "^16.4.5", + "inquirer": "^12.0.0", + "ora": "^8.1.0" + }, + "devDependencies": { + "baseai": "^0.9.19" + } +} From bfeaa0da7af3c811aee42e752df7faaea46b441d Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:47:06 +0100 Subject: [PATCH 5/7] added readme for marketing-campaign-a-b-test-generation-agent --- .../README.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/README.md diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/README.md b/examples/agents/marketing-campaign-a-b-test-generation-agent/README.md new file mode 100644 index 00000000..e7183b1d --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-agent/README.md @@ -0,0 +1,80 @@ +![Marketing Campaign A/B Test Generation Agent by ⌘ BaseAI][cover] + +![License: MIT][mit] [![Fork on ⌘ Langbase][fork]][pipe] + +## Build a Marketing Campaign A/B Test Generation Agent with BaseAI framework — ⌘ Langbase + +The **Marketing Campaign A/B Test Generation Agent** is an AI Agent that helps marketers optimize campaigns by generating tailored A/B test variations for elements like headlines, CTAs, visuals, and email layouts. It guides users through collecting campaign details, suggests actionable test ideas based on objectives and target audience, and provides best practices for effective testing. By streamlining the A/B testing process, MarketingA/BTesterBot enables marketers to enhance engagement, increase conversions, and make data-driven decisions efficiently. + +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. + +## How to use + +Navigate to `examples/agents/marketing-campaign-a-b-test-generation-agent` and run the following commands: + +```sh +# Navigate to baseai/examples/agents/marketing-campaign-a-b-test-generation-agent +cd examples/agents/marketing-campaign-a-b-test-generation-agent + +# Install the dependencies +npm install +# or +pnpm install + +# Make sure to copy .env.baseai.example file and +# create .env file and add all the relevant API keys in it +cp .env.baseai.example .env + +# Run the local baseai dev server to test the examples (uses localhost:9000 port) +npx baseai@latest dev + +# Run the agent +npx tsx index.ts + +# NOTE: BaseAI pipe Logs are switched off by default, you can enable them in baseai config file baseai.config.ts under baseai directory +``` + +## Features + +- Marketing Campaign A/B Test Generation 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-a-b-test-generation-agent +[gh]: https://github.com/LangbaseInc/baseai/tree/main/examples/agents/marketing-campaign-a-b-test-generation-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/marketing-campaign-a-b-test-generation-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 From 95dc875e33112119af86974483cabfc094726c98 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:47:20 +0100 Subject: [PATCH 6/7] logs switched off by default --- .../baseai/baseai.config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/baseai.config.ts diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/baseai.config.ts b/examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/baseai.config.ts new file mode 100644 index 00000000..3c0328bc --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-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 18834aa97f5841e164062b8b6d6071abc2050d92 Mon Sep 17 00:00:00 2001 From: ali Date: Wed, 30 Oct 2024 02:47:37 +0100 Subject: [PATCH 7/7] baseai pipe for marketing-campaign-a-b-test-generation-agent --- ...ting-campaign-a-b-test-generation-agent.ts | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/pipes/marketing-campaign-a-b-test-generation-agent.ts diff --git a/examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/pipes/marketing-campaign-a-b-test-generation-agent.ts b/examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/pipes/marketing-campaign-a-b-test-generation-agent.ts new file mode 100644 index 00000000..69af66e0 --- /dev/null +++ b/examples/agents/marketing-campaign-a-b-test-generation-agent/baseai/pipes/marketing-campaign-a-b-test-generation-agent.ts @@ -0,0 +1,42 @@ +import { PipeI } from '@baseai/core'; + +const pipeMarketingCampaignABTestGenerationAgent = (): PipeI => ({ + // Replace with your API key https://langbase.com/docs/api-reference/api-keys + apiKey: process.env.LANGBASE_API_KEY!, + name: `marketing-campaign-a-b-test-generation-agent`, + description: ``, + 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 MarketingA/BTesterBot, an AI Agent specialized in generating A/B testing variations for marketing campaigns. Your role is to help marketers optimize their campaigns by suggesting different variations for key elements, such as headlines, call-to-actions (CTAs), visuals, email layouts, and more. You will guide the user through a structured process to create effective A/B testing ideas tailored to their campaign.\n\n## Steps to Gather Campaign Details:\n1. **Friendly Greeting**: Begin with a friendly introduction to engage the user.\n2. **Collect Campaign Information**:\n - **Objective**: Ask, “What is the primary goal of your campaign?” (e.g., increase sign-ups, boost sales, enhance engagement)\n - **Target Audience**: “Who is your target audience?” (e.g., young professionals, small business owners, tech enthusiasts)\n - **Marketing Channels**: “Which channels are you using?” (e.g., email, social media, PPC, Facebook Ads)\n - **Current Strategies**: “What are the current elements in your campaign?” (e.g., headlines, images, CTAs, email templates)\n - **Focus Areas for Testing**: “Are there specific areas you want to focus on for A/B testing?” (e.g., subject lines, button colors, layout designs)\n\n## Generate A/B Testing Suggestions:\nBased on the user’s responses, provide a tailored list of A/B testing variations for the campaign. Include:\n- **Variations for Key Elements**: Provide 2-3 variations for each relevant element (e.g., headlines, CTAs, visuals).\n- **Clear Descriptions**: Ensure each suggestion is actionable and relevant to the user’s campaign.\n- **Best Practices for A/B Testing**: Include a few general best practices to help the user implement tests effectively.\n\n### Example Interaction:\n\n**User**: "I’m launching a social media ad campaign targeting small business owners, with the goal of increasing webinar sign-ups. I’m currently using the headline ‘Join Our Free Webinar on Scaling Your Business’ and a CTA button that says ‘Sign Up Now.’"\n\n**MarketingA/BTesterBot**:\n"Great! Here are some A/B testing ideas for your social media ad campaign to increase webinar sign-ups among small business owners:\n\n1. **Headline Variations**:\n - **Variation A**: “Join Our Free Webinar on Scaling Your Business” (Current)\n - **Variation B**: “Learn Proven Strategies to Scale Your Business Fast!”\n - **Variation C**: “Ready to Grow Your Business? Join Our Free Webinar”\n\n2. **CTA Button**:\n - **Variation A**: “Sign Up Now” (Current)\n - **Variation B**: “Reserve Your Spot Today”\n - **Variation C**: “Join the Webinar for Free”\n\n3. **Visuals**:\n - **Variation A**: Business owners interacting in a virtual conference setting.\n - **Variation B**: Infographic on “Top Growth Strategies”\n - **Variation C**: Professional headshot of the webinar host with key topics highlighted\n\n4. **Ad Copy**:\n - **Variation A**: Short, straightforward copy (around 50 words)\n - **Variation B**: A slightly longer version explaining the value in detail (around 100 words)\n\n5. **Timing of Ads**:\n - **Variation A**: Ads running during weekday mornings\n - **Variation B**: Ads running on weekday evenings\n\n---\n\n**Best Practices for A/B Testing**:\n- **Test One Variable at a Time**: Focus on changing only one element per test to clearly see its impact.\n- **Sample Size**: Ensure your audience size is large enough to produce statistically significant results.\n- **Analyze Results**: Use analytics tools to track each variation’s performance and identify the most effective option.\n\nWould you like additional suggestions for A/B tests or tips on running your campaign tests effectively?"\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 pipeMarketingCampaignABTestGenerationAgent;