DEV Community

Cover image for Gain a Competitive Edge with Lyzr's Analyze Competitor Content App
Prajjwal Sule
Prajjwal Sule

Posted on

Gain a Competitive Edge with Lyzr's Analyze Competitor Content App

In today’s dynamic digital landscape, understanding your competitors and devising a robust content strategy are paramount to success. Enter the Analyze Competitor Content app by Lyzr, an innovative tool that harnesses the power of AI to provide actionable insights into competitors’ content strategies. In this article, we’ll explore how this cutting-edge tool revolutionizes content strategy and empowers brands to differentiate themselves in the market.

Lyzr offers an agent-centric approach to rapidly developing LLM (Large Language Model) applications with minimal code and time investment. Even if you’re unfamiliar with the GenAI stack, Lyzr empowers you to build your AI applications effortlessly. It is the go-to solution for constructing GenAI apps without requiring an in-depth understanding of Generative AI.


Welcome to Lyzr! | Lyzr Documentation

Explore the limitless possibilities of Generative AI with Lyzr, an enterprise alternative to popular Generative AI SaaS products. Lyzr offers a robust and secure solution for building and launching your own enterprise-grade Generative AI applications with speed and confidence.

favicon docs.lyzr.ai

Setting up the Project

To get started with Lyzr's Analyze Competitor Content app, follow these steps:

Clone the App: Clone the Analyze Competitor Content app repository from GitHub.

   git clone https://github.com/PrajjwalLyzr/Analyze-Competitor-Content
Enter fullscreen mode Exit fullscreen mode

Create a Virtual Environment: Set up a virtual environment and activate it.

   python3 -m venv venv
   source venv/bin/activate
Enter fullscreen mode Exit fullscreen mode

Set Environment Variables: Create a .env file and add your OpenAI API key.

   OPENAI_API_KEY = "Paste your openai api key here"
Enter fullscreen mode Exit fullscreen mode

Install Dependencies: Install the required dependencies.

   pip install lyzr-automata streamlit python-dotenv
Enter fullscreen mode Exit fullscreen mode

Structure

Analyze-Competitor-Content


├── app.py

├── README.md

├── .gitignore

└── requirements.txt

Enter fullscreen mode Exit fullscreen mode

Core Components of the Analyze Competitor Content App

Let's explore the key components of Lyzr's Analyze Competitor Content app:

import os
import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent, Task, Logger
from lyzr_automata.tasks.task_literals import InputType, OutputType
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv('OPENAI_API_KEY')

open_ai_model_text = OpenAIModel(
    api_key=API_KEY,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.5,
        "max_tokens": 1500,
    },
)

def analyze_competitor_content(content_title, target_audience):
    content_strategy_analyst = Agent(
        prompt_persona="""You are a Content Strategy Analyst expert who analyzes a list of competitor content titles and devises a comprehensive strategy to differentiate our brand. Your task is to meticulously examine the competitor landscape, identify gaps, and propose 10 unique content topics that showcase our brand's expertise and distinct value proposition. Leveraging your expertise in content analysis, market research, and strategic planning, you'll develop innovative ideas that resonate with our target audience and set us apart from the competition.""",
        role="Content Strategy Analyst",
    )

    contnet_generator =  Task(
        name="Campaign Generator",
        agent=content_strategy_analyst,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=open_ai_model_text,
        instructions=f"Use the description provided, given a list of competitor content titles, analyze and suggest 10 unique content topics that would differentiate our brand, and the Target Audience: {target_audience}. [IMPORTANT!] Setup the events in a detailed manner",
        log_output=True,
        enhance_prompt=False,
        default_input=content_title
    )

    logger = Logger()

    main_output = LinearSyncPipeline(
        logger=logger,
        name="Analyze Competitor Content",
        completion_message="App Generated all things!",
        tasks=[
            contnet_generator,
        ],
    ).run()

    return main_output
Enter fullscreen mode Exit fullscreen mode

Executing the Application

To run Lyzr's Analyze Competitor Content app:

if __name__ == "__main__":
    titles = st.text_area("Write down list of competitor content titles")
    audience = st.text_area('Targeted Audience')

    button=st.button('Submit')
    if (button==True):
        generated_output = analyze_competitor_content(content_title=titles, target_audience=audience)
        title_output = generated_output[0]['task_output']
        st.write(title_output)
        st.markdown('---')
Enter fullscreen mode Exit fullscreen mode

Upon clicking the “Submit” button, the app triggers the analyze_competitor_content function, passing the entered titles and audience description as arguments. The generated output includes ten unique content topics suggested by the Lyzr Automata Agent.

Conclusion

With Lyzr's Analyze Competitor Content app, content strategists can gain invaluable insights into competitors’ content strategies and devise compelling strategies to differentiate their brand. Embrace the power of AI to stay ahead of the competition and captivate your target audience.

References

Top comments (0)