<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: harshit-lyzr</title>
    <description>The latest articles on Forem by harshit-lyzr (@harshitlyzr).</description>
    <link>https://forem.com/harshitlyzr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1351586%2Fdde7f6ac-459d-46f0-a842-060e09560a30.png</url>
      <title>Forem: harshit-lyzr</title>
      <link>https://forem.com/harshitlyzr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/harshitlyzr"/>
    <language>en</language>
    <item>
      <title>Step-by-Step Guide to Building Your Own AI Newsletter Automation Platform</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Wed, 21 Aug 2024 10:55:24 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/step-by-step-guide-to-building-your-own-ai-newsletter-automation-platform-2l04</link>
      <guid>https://forem.com/harshitlyzr/step-by-step-guide-to-building-your-own-ai-newsletter-automation-platform-2l04</guid>
      <description>&lt;p&gt;In this blog, we’ll take a dive into the code that makes it all happen, discuss how you can build your own, and explore why this setup is a game-changer for content creators, marketers, and businesses alike. Spoiler alert: This guide is packed with actionable insights and code snippets to help you create newsletters that get noticed!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Walkthrough&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Environment Setup&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from lyzr_agent import LyzrAgent
import streamlit as st
from dotenv import load_dotenv
from PIL import Image

# Load environment variables
load_dotenv()
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
LYZR_API_KEY = os.getenv("LYZR_API_KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Imports: The code imports necessary libraries, including os for environment variable management, lyzr_agent for interacting with the Lyzr Agent API, streamlit for creating the web app, dotenv for loading environment variables, and PIL for image handling.&lt;br&gt;
Environment Variables: The load_dotenv() function loads the API keys from a .env file, which are essential for authentication with the Lyzr and OpenAI APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. LyzrAgent Initialization&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent = LyzrAgent(api_key=LYZR_API_KEY, llm_api_key=OPENAI_API_KEY)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agent Initialization: An instance of LyzrAgent is created, using the loaded API keys to authenticate with the Lyzr service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Defining the System Prompt&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prompt = """
    Act like an experienced newsletter writer skilled in crafting engaging and informative content. 
    Use a perplexity search to find the most relevant and current information on Given Topic. 
    Your goal is to summarize the key insights and trends into a concise, well-structured newsletter that keeps readers informed and interested. 
    Include engaging headlines, clear sections, and a call to action.

    Take a deep breath and work on this problem step-by-step.
    """
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;System Prompt: This prompt guides the agent’s behavior, instructing it to act as a newsletter writer and use the perplexity search tool to gather relevant information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Creating the Agent&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@st.cache_resource(show_spinner=True)
def create_agent():
    env_id = Agent.create_environment(
        name="Newsletter Environment",
        features=[{
            "type": "TOOL_CALLING",
            "config": {"max_tries": 3},
            "priority": 0
        },
        {
            "type": "SHORT_TERM_MEMORY",
            "config": {},
            "priority": 0
        }],
        tools=["perplexity_search"]
    )

   agent_id = Agent.create_agent(
        env_id=env_id['env_id'],
        system_prompt=prompt,
        name="Newsletter Agent"
    )

    return agent_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code defines a create_agent() function that builds an agent environment for a "Newsletter Environment" using two modules and a registered external tool. Let's break down the code based on the provided environment structure:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features/Modules&lt;/strong&gt;&lt;br&gt;
The environment in this code uses two sync modules:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. TOOL_CALLING (Sync Module):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Type: Sync&lt;br&gt;
Functionality: This module allows the agent to call external APIs that are registered using OpenAPI schemas. In this code, it is configured with "max_tries": 3 meaning the agent will attempt up to three retries when calling the specified tool.&lt;br&gt;
Execution: It runs in series during the message processing pipeline, has read/write access, and can mutate the message stream.&lt;br&gt;
&lt;strong&gt;b. SHORT_TERM_MEMORY (Sync Module):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Type: Sync&lt;br&gt;
Functionality: This module gives the agent short-term contextual memory by retaining information for a configurable number of recent messages. This allows the agent to manage small-scale, context-dependent tasks effectively.&lt;br&gt;
Execution: Like other sync modules, it runs in series, has read/write access, and can impact the message stream during processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;br&gt;
The code registers the perplexity_search tool for this environment:&lt;/p&gt;

&lt;p&gt;Tools are external APIs used by the agent. In this case, the agent will access the Perplexity search tool, likely to assist in information retrieval for newsletter content.&lt;br&gt;
Note: Since the TOOL_CALLING module is enabled, the tool is accessible to the agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environment ID (env_id)&lt;/strong&gt;&lt;br&gt;
The env_id variable stores the unique identifier of the created environment. This ID can be used for further agent configuration or interactions within the broader system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent Creation&lt;/strong&gt;&lt;br&gt;
The code is creating a new agent using the Agent.create_agent method, which takes in the environment ID, system prompt, and agent name as arguments. The agent_id returned represents the unique ID of the newly created agent.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Session State Management&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if "agent_id" not in st.session_state:
    st.session_state.agent_id = create_agent()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Session Management: The agent ID is stored in the Streamlit session state to maintain the agent’s context across user interactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. User Input and Newsletter Generation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query = st.text_area("Enter Topic and description", height=150)

if st.button("Generate NewsLetter"):
    if query.strip():
        with st.spinner("Generating NewsLetter..."):
            response = Agent.send_message(
                agent_id=st.session_state.agent_id['agent_id'],
                user_id="default_user",
                session_id="new_session",
                message=query
            )
            st.markdown(f"**Generated NewsLetter:**\n\n{response['response']}")
    else:
        st.warning("Please provide Topic")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Input Area: Users can enter a topic and description in a text area.&lt;br&gt;
Generate Button: When clicked, it checks if the input is not empty. If valid, it sends a message to the agent using Agent.send_message(), which triggers the generation of the newsletter. The generated content is then displayed.&lt;br&gt;
Join Discord: &lt;a href="https://discord.gg/dxKFHS6t" rel="noopener noreferrer"&gt;https://discord.gg/dxKFHS6t&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Project Link: &lt;a href="https://github.com/harshit-lyzr/Newsletter_automation" rel="noopener noreferrer"&gt;https://github.com/harshit-lyzr/Newsletter_automation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try it out: &lt;a href="https://lyzr-newsletter.streamlit.app/" rel="noopener noreferrer"&gt;https://lyzr-newsletter.streamlit.app/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>newsletter</category>
      <category>linux</category>
      <category>machinelearning</category>
      <category>github</category>
    </item>
    <item>
      <title>Automating Order Status Emails Using Shopify API and Lyzr</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Tue, 06 Aug 2024 07:20:47 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/automating-order-status-emails-using-shopify-api-and-lyzr-3l2c</link>
      <guid>https://forem.com/harshitlyzr/automating-order-status-emails-using-shopify-api-and-lyzr-3l2c</guid>
      <description>&lt;p&gt;In this article, I’ll explain in detail how I constructed a Python-based order status email generator using ShopifyAPI and LYZR. E-commerce businesses often need to update customers about their order status. Automating this process can save significant time and enhance customer communication. With the help of ShopifyAPI for order details and LYZR to generate the email content, this automation becomes seamless and efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shopify API Integration:&lt;/strong&gt; Seamlessly interacts with the Shopify platform to retrieve order details, providing accurate and up-to-date information.&lt;br&gt;
&lt;strong&gt;Lyzr Integration:&lt;/strong&gt; Leverages advanced text generation capabilities to create personalized and engaging email content tailored to each order status.&lt;br&gt;
&lt;strong&gt;Customizable Email Templates:&lt;/strong&gt; While not explicitly shown in the provided code, the script can be extended to incorporate predefined email templates for different order statuses, ensuring consistency and efficiency.&lt;br&gt;
&lt;strong&gt;Dynamic Content Generation:&lt;/strong&gt; The script dynamically generates email content based on the specific order information, making each email relevant and informative.&lt;br&gt;
&lt;strong&gt;Potential for Automation:&lt;/strong&gt; With further development, the script can be integrated into a larger automation system to send order status updates automatically, saving time and resources.&lt;br&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; The script can be adapted to different e-commerce platforms by replacing the Shopify API with the appropriate integration.&lt;br&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; The code can be scaled to handle a large volume of orders by optimizing the API calls and text generation process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Lyzr Generator?&lt;/strong&gt;&lt;br&gt;
Introducing Lyzr Generator Agent, a cutting-edge writing assistant designed to transform your ideas into compelling content effortlessly. Whether you’re crafting detailed articles, engaging blog posts, or catchy tweets, Lyzr Generator Agent is your go-to tool for all your writing needs.&lt;/p&gt;

&lt;p&gt;This powerful tool adapts to any writing style, ensuring your message resonates with your intended audience. Whether you’re writing for a professional business audience, casual readers, or social media followers, Lyzr Generator Agent tailors its output to suit your specific requirements. It harnesses advanced algorithms and extensive language models to generate high-quality content that captures attention and drives engagement.&lt;/p&gt;

&lt;p&gt;One of the standout features of Lyzr Generator Agent is its versatility. It can create long-form content with in-depth analysis and insights or generate short, punchy social media posts that captivate and inspire. This flexibility makes it an invaluable tool for marketers, content creators, bloggers, and anyone looking to enhance their online presence.&lt;/p&gt;

&lt;p&gt;With Lyzr Generator Agent, content creation becomes a breeze. It simplifies the writing process, saving you time and effort while ensuring your content remains top-notch. Whether you need to draft a detailed report, a persuasive email, or an engaging social media update, Lyzr Generator Agent has you covered. Bring your ideas to life with ease and efficiency using this innovative writing aid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, I installed the necessary Python libraries, ShopifyAPI, lyzr, and aenum. The ShopifyAPI library allows us to interact with Shopify’s API to manage store data, while lyzr provides advanced text generation capabilities.&lt;/p&gt;

&lt;p&gt;Follow this link to create your demo shopify store with dummy data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Library Installation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install --upgrade ShopifyAPI lyzr aenum
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We begin by installing the required libraries: ShopifyAPI, lyzr, and aenum. These libraries provide functionalities for interacting with the Shopify API, text generation, and enumeration (used internally by some libraries).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Shopify API Session&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import shopify
token = "&amp;lt;your shopify token&amp;gt;"
merchant = "&amp;lt;your shopify url&amp;gt;"
api_session = shopify.Session(merchant,"2021-10",token)
shopify.ShopifyResource.activate_session(api_session)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We import the shopify library and define the following variables:&lt;br&gt;
token: This holds your Shopify API access token.&lt;br&gt;
merchant: The URL of your Shopify store.&lt;br&gt;
api_session: This creates a session object using the shopify.Session class, providing access to the Shopify API with your credentials.&lt;br&gt;
We then activate the session using shopify.ShopifyResource.activate_session.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Order Details Retrieval&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;shopify.Order.find(6207936823386).attributes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We import the Order class from the shopify library.&lt;br&gt;
We define a variable my_order that likely holds the order ID you want to retrieve information for.&lt;br&gt;
The script then retrieves the order attributes using shopify.Order.find(my_order).attributes. This fetches details about the specific order you wish to use for the email.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text Generation with lyzr&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from lyzr import Generator

generator = Generator(api_key="&amp;lt;Your OPENAI_API_KEY&amp;gt;")
text = f"write a Email for order status for this order: {my_order}"
instructions = "Email for Order Status" 
persona = "Email Generator for Updating status for placed order"

elaborated_content = generator.generate(text, persona=persona, instructions=instructions)
print(elaborated_content)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We import the Generator class from the lyzr library.&lt;br&gt;
We create a generator object by initializing it with your lyzr API key.&lt;br&gt;
We construct the text prompt using an f-string, referencing the my_order variable to personalize the email content. The prompt instructs the generator to "write an Email for order status for this order."&lt;br&gt;
We define additional variables:&lt;br&gt;
instructions: This specifies the type of creative text format you want lyzr to generate (in this case, an "Email for Order Status").&lt;br&gt;
persona: This tailors the content to a specific audience (here, "Email Generator for Updating status for placed order").&lt;br&gt;
Finally, we call the generate method on the generator object, passing the text prompt, persona, and instructions. This generates the creative text content for the email based on the provided information.&lt;br&gt;
The script concludes by printing the generated email content stored in the elaborated_content variable.&lt;/p&gt;

</description>
      <category>shopify</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Lyzr English Self Learning App: Empowering Autonomous Language Learning</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Wed, 17 Jul 2024 08:43:04 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/lyzr-english-self-learning-app-empowering-autonomous-language-learning-547d</link>
      <guid>https://forem.com/harshitlyzr/lyzr-english-self-learning-app-empowering-autonomous-language-learning-547d</guid>
      <description>&lt;p&gt;In today’s interconnected world, mastering English language skills is crucial for personal and professional growth. The Lyzr English Self Learning app leverages advanced AI technology to facilitate autonomous learning, specifically designed to enhance English proficiency through interactive and personalized exercises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;br&gt;
Traditional methods of language learning often lack personalized feedback and structured learning activities, hindering effective skill development. Learners struggle to find resources that adapt to their individual pace and learning styles, making sustained progress challenging.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
The Lyzr English Self Learning app addresses these challenges by integrating cutting-edge AI technology, specifically Lyzr Automata, to create a dynamic and personalized learning experience. Here’s how it works:&lt;/p&gt;

&lt;p&gt;Personalized Learning Activities: Users input an article link, and the app generates tailored learning activities based on the content. These activities include vocabulary breakdowns, grammar explanations, comprehension questions, and practice exercises.&lt;br&gt;
Advanced AI Model Integration: Powered by OpenAI’s GPT-4 Turbo, the app analyzes complex articles, identifies language patterns, and provides in-depth explanations to enhance comprehension and language acquisition.&lt;br&gt;
Interactive Learning Journey: Learners engage with an AI-driven English tutor persona, receiving guidance and feedback akin to a one-on-one tutoring session. This interaction fosters deeper understanding and retention of language nuances.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;br&gt;
Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;/p&gt;

&lt;p&gt;openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;english_learning function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def english_learning(article):
    english_agent = Agent(
        prompt_persona=f"You are an Expert in English.",
        role="English Tutor",
    )

    english_task = Task(
        name="English learning",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=english_agent,
        log_output=True,
        instructions=f"""
        You are an advanced English language tutor. Your task is to help me improve my English by analyzing difficult articles I provide. Follow these steps for each article I submit:
        Perform an initial analysis of the text.
        Provide a vocabulary breakdown:
        List unfamiliar or advanced words
        For each word, give its definition, etymology, example sentences, synonyms, antonyms, and common collocations
        Analyze phrases and sentences:
        Identify idiomatic expressions, phrasal verbs, and complex sentence structures
        Explain their meanings, usage in different contexts, and provide simpler alternatives or paraphrases
        Offer grammar explanations for complex structures
        Explain any cultural, historical, or subject-specific references in the text.
        Provide 3-5 reading comprehension questions about the main ideas and key points.
        Highlight recurring language patterns, writing styles, or genre-specific vocabulary.
        Create practice exercises based on the text:
        Fill-in-the-blank sentences
        Matching exercises
        Sentence transformation tasks
        A short writing prompt using new vocabulary
        Suggest 2-3 long-term learning strategies to help retain and review the new language.
        Recommend 1-2 similar texts or articles for further reading and reinforcement.
        Always be prepared to engage in follow-up discussions, answer questions about the text, and adapt your explanations based on my needs and progress. Your goal is to systematically expand my vocabulary and improve my comprehension of complex English articles over time.

        Article Link: {article}
        """,
    )

    output = LinearSyncPipeline(
        name="Learn English",
        completion_message="Test Generated!",
        tasks=[
            english_task
        ],
        ).run()
    return output[0]['task_output']

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines a function called english_learning that takes an article link as input.&lt;br&gt;
Creates an Agent object with a persona prompt and assigns the role of "English Tutor".&lt;br&gt;
Creates a Task object named "English learning" specifying the output and input types, model to be used (from openai_model), assigned agent, logging output, and detailed instructions for the model to act as an English tutor when processing articles.&lt;br&gt;
Creates a LinearSyncPipeline object named "Learn English" with a completion message and a list containing the created english_task.&lt;br&gt;
Runs the pipeline and retrieves the task output (presumably the analysis of the article).&lt;br&gt;
Returns the retrieved task output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Input and Button:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;article = st.text_input("Enter Article Link")
if st.button("Generate"):
    solution = english_learning(article)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;article = st.text_input(): Creates a text input field for users to enter an article link.&lt;br&gt;
if st.button(): Creates a button labeled "Generate". When clicked, it triggers the following code block.&lt;br&gt;
Calls the english_learning function with the entered article link.&lt;br&gt;
Stores the returned output (analysis of the article) in the solution variable.&lt;br&gt;
Uses st.markdown() to display the solution as formatted text on the Streamlit app.&lt;br&gt;
try it now: &lt;a href="https://lyzr-english-learning.streamlit.app/" rel="noopener noreferrer"&gt;https://lyzr-english-learning.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;code: &lt;a href="https://github.com/harshit-lyzr/English_self_learning" rel="noopener noreferrer"&gt;https://github.com/harshit-lyzr/English_self_learning&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/" rel="noopener noreferrer"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata" rel="noopener noreferrer"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI-Powered Privacy: Lyzr Automata’s Impact on Policy Formulation</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Tue, 16 Jul 2024 08:13:56 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/ai-powered-privacy-lyzr-automatas-impact-on-policy-formulation-13og</link>
      <guid>https://forem.com/harshitlyzr/ai-powered-privacy-lyzr-automatas-impact-on-policy-formulation-13og</guid>
      <description>&lt;p&gt;In today’s digital landscape, crafting a comprehensive Privacy Policy is crucial for businesses to ensure legal compliance and customer trust. However, the task can be daunting, requiring expertise in legal nuances and regulatory requirements. To address this challenge, a Privacy Policy Generator powered by Lyzr Automata offers a sophisticated solution.&lt;/p&gt;

&lt;p&gt;Many businesses struggle to create tailored Privacy Policies that meet legal standards and effectively communicate their data handling practices to customers. This often leads to ambiguity and potential legal risks, as generic templates may not suffice in complex regulatory environments.&lt;/p&gt;

&lt;p&gt;The Privacy Policy Generator leverages Lyzr Automata, a versatile AI agent and multi-agent framework designed for complex cognitive tasks. By integrating OpenAI’s powerful language model, it automates the creation of Privacy Policies tailored to specific business contexts. Users input company details such as name, type, operations, and website, prompting the AI to draft a detailed policy that meets legal requirements and reflects current best practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Lyzr Automata?&lt;/strong&gt;&lt;br&gt;
Lyzr Automata represents a cutting-edge advancement in AI-driven automation, specifically tailored for cognitive tasks requiring deep domain knowledge and nuanced decision-making. It functions as a multi-agent framework, capable of orchestrating interactions between various AI agents to tackle complex problems collaboratively.&lt;/p&gt;

&lt;p&gt;At its core, Lyzr Automata harnesses the power of OpenAI’s language models, such as GPT-4 Turbo, to interpret and generate human-like text based on input instructions. This capability enables it to simulate expertise in diverse domains, including legal and policy crafting, by embodying specialized personas like a Privacy Policy Expert.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits and Impact&lt;/strong&gt;&lt;br&gt;
The integration of Lyzr Automata in the Privacy Policy Generator offers several key benefits:&lt;/p&gt;

&lt;p&gt;Accuracy and Compliance: Ensures policies are accurate and compliant with relevant regulations.&lt;br&gt;
Efficiency: Reduces time and resources required for manual policy drafting.&lt;br&gt;
Customization: Tailors policies to specific business contexts, enhancing relevance and clarity.&lt;br&gt;
Trust and Transparency: Builds trust with customers by transparently outlining data handling practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;br&gt;
Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;/p&gt;

&lt;p&gt;openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy Policy Generation Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def privacy_policy_generator(name, company_type, operation, website):
    policy_agent = Agent(
        prompt_persona=f"You are an Expert in Privacy policy crafting.",
        role="Privacy Policy Expert",
    )

    policy_task = Task(
        name="Privacy Policy",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=policy_agent,
        log_output=True,
        instructions=f"""
        Draft a privacy policy for a {company_type} company called {name} that operates in the state of {operation}. 
        The company website is {website} .
        """,
    )

    output = LinearSyncPipeline(
        name="Privacy Policy Generation",
        completion_message="Privacy Policy Generated!",
        tasks=[
            policy_task
        ],
        ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The privacy_policy_generator function takes name, company_type, operation, and website as inputs for generating the policy.&lt;br&gt;
An Agent object (policy_agent) is created, defining the prompt persona and role for interacting with the model.&lt;br&gt;
A Task object (policy_task) is created, specifying the task name, desired output format (text), input format (text), the OpenAIModel to use, the policy_agent, enabling logging, and providing detailed instructions for the model. These instructions include company details, website, and state of operation.&lt;br&gt;
A LinearSyncPipeline object (output) is created, naming the pipeline, setting a completion message, and defining the list of tasks (in this case, only the policy_task). This pipeline executes the task and retrieves the output.&lt;br&gt;
The function returns the generated policy text (task_output).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;company_name = st.text_input("Enter Company Name")
company_type = st.text_input("Enter Company Type")
state_of_operation = st.text_input("Enter Company's State of Operation")
website = st.text_input("Enter Company Website")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Text input fields are displayed using st.text_input to capture company name, type, state, and website.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Generate"):
    solution = privacy_policy_generator(company_name,company_type,state_of_operation,website)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clicking the “Generate” button triggers the code within the button’s if statement.&lt;br&gt;
The privacy_policy_generator function is called with the user-provided information.&lt;br&gt;
The returned generated policy (solution) is displayed as markdown using st.markdown.&lt;br&gt;
Running the App&lt;br&gt;
Finally, run the app using the following command in your terminal:&lt;/p&gt;

&lt;p&gt;streamlit run app.py&lt;br&gt;
try it now: &lt;a href="https://lyzr-privacy-policy.streamlit.app/" rel="noopener noreferrer"&gt;https://lyzr-privacy-policy.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code: &lt;a href="https://github.com/harshit-lyzr/privacy_policy_generator/" rel="noopener noreferrer"&gt;https://github.com/harshit-lyzr/privacy_policy_generator/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/" rel="noopener noreferrer"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata" rel="noopener noreferrer"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AI Agents for Effortless Mindmap Generation</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Thu, 11 Jul 2024 11:53:43 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/ai-agents-for-effortless-mindmap-generation-3gcj</link>
      <guid>https://forem.com/harshitlyzr/ai-agents-for-effortless-mindmap-generation-3gcj</guid>
      <description>&lt;p&gt;Creating detailed and organized mindmaps can be a tedious and time-consuming task, especially when done manually. For educators, project managers, or anyone in need of a clear visualization of their ideas and plans, the need for an efficient and automated solution is evident. How can we leverage advanced AI technologies to streamline this process and generate mindmaps quickly and effectively?&lt;/p&gt;

&lt;p&gt;Mindmap Generator, a Streamlit application that harnesses the power of Lyzr Automata and OpenAI’s GPT-4 to automate mindmap creation. By simply entering a topic, users can generate a comprehensive mindmap that outlines key areas and subtopics, saving valuable time and effort. This solution leverages AI agents to ensure the generated content is accurate, relevant, and well-structured.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Lyzr?&lt;/strong&gt;&lt;br&gt;
Lyzr Automata is an advanced AI-driven automation platform that enables users to create intelligent agents and pipelines to automate a wide range of tasks. It integrates with popular AI models, such as OpenAI’s GPT-4, to provide powerful natural language processing and generation capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features of the Mindmap Generator&lt;/strong&gt;&lt;br&gt;
Intuitive User Interface: The Mindmap Generator app features a clean and user-friendly interface, making it easy for you to input your desired topic and generate a mindmap.&lt;br&gt;
Seamless OpenAI Integration: The app seamlessly integrates with OpenAI’s API, allowing you to leverage the power of advanced language models like GPT-4 to generate high-quality mindmaps.&lt;br&gt;
Customizable Mindmap Structure: The app provides a predefined mindmap format that you can use as a starting point, but you can also customize the structure to fit your specific needs.&lt;br&gt;
Visually Appealing Mindmaps: The generated mindmaps are visually appealing and easy to understand, helping you organize your thoughts and ideas in a more effective manner.&lt;br&gt;
Streamlined Workflow: By automating the mindmap generation process, the app saves you time and effort, allowing you to focus on the content and structure of your mindmap rather than the manual creation process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;br&gt;
Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;/p&gt;

&lt;p&gt;openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;mindmap_generator function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def mindmap_generator(topic):
    mindmap_agent = Agent(
        prompt_persona=f"You are an Expert in system design.",
        role="System Designer",
    )

    mindmap_task = Task(
        name="content writer",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=mindmap_agent,
        log_output=True,
        instructions=f"""
        Generate a Mindmap in given format for {topic}.
        mindmap in top is compulsory.
        format:
        "
        mindmap
          school_management
            administration
                staff_management
                    recruitment
                    training
                    scheduling
                student_management
                    enrollment
                    attendance
                    discipline
                facilities_management
                    maintenance
                    safety
                    supplies
            academics
                curriculum_development
                    syllabus_planning
                    material_selection
        "

        ONLY GENERATE MINDMAP CODE NOTHING ELSE APART FROM IT
        """,
    )

    output = LinearSyncPipeline(
        name="Mindmap Generation",
        completion_message="Mindmap Generated!",
        tasks=[
            mindmap_task
        ],
        ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function defines the core logic for generating mindmaps.&lt;/p&gt;

&lt;p&gt;An Agent object is created using Agent with a prompt persona describing the role and expertise ("You are an Expert in system design."/"System Designer").&lt;br&gt;
A Task object is created using Task specifying various attributes:&lt;br&gt;
name: "content writer" (descriptive name for the task).&lt;br&gt;
output_type: OutputType.TEXT (specifies the task's output format).&lt;br&gt;
input_type: InputType.TEXT (specifies the task's expected input format).&lt;br&gt;
model: The openai_model object created earlier (defines the AI model to be used).&lt;br&gt;
agent: The mindmap_agent object (defines the persona for task execution).&lt;br&gt;
log_output: True (enables logging of the task's output).&lt;br&gt;
instructions: This is a multi-line string containing detailed instructions for the AI model. It specifies the task as generating a mindmap in a specific format for a given topic. It emphasizes that only mindmap code should be generated and excludes other information.&lt;br&gt;
A LinearSyncPipeline object is created using LinearSyncPipeline with:&lt;br&gt;
name: "Mindmap Generation" (descriptive name for the pipeline).&lt;br&gt;
completion_message: "Mindmap Generated!" (message displayed upon task completion).&lt;br&gt;
tasks: A list containing the single mindmap_task defined earlier.&lt;br&gt;
The run method of the pipeline is called, executing the defined task and returning the output.&lt;br&gt;
The function returns the first element’s (task_output) from the pipeline output, which is the generated mindmap text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Input and Button:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;topic = st.text_input("Enter Topic")

if st.button("Generate"):
    solution = mindmap_generator(topic)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;topic = st.text_input("Enter Topic"): Creates a text input field for the user to enter the presentation topic.&lt;br&gt;
if st.button("Generate"): Creates a button labeled "Generate". When clicked, this block executes:&lt;br&gt;
solution = presentation_maker(topic): Calls the presentation_maker function with the entered topic.&lt;br&gt;
st.markdown(solution): Displays the generated Python code as markdown, allowing for proper formatting and code highlighting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visualizing the Mind Map via Mermaid&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to Mermaid Live Editor: Access the Mermaid Live Editor online.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://mermaid.live/edit" rel="noopener noreferrer"&gt;Mermaid Live Editor&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Insert the Notation: Enter the mindmap notation generated by ChatGPT into the editor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Render the SVG: Click on the render function. Once visualized, you can opt to save the graphic in SVG format.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoelgv9yktquod4zfl2k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoelgv9yktquod4zfl2k.png" alt="Mindmap generated by OpenAI" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;try it now: &lt;a href="https://github.com/harshit-lyzr/mindmap_generator" rel="noopener noreferrer"&gt;https://github.com/harshit-lyzr/mindmap_generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/" rel="noopener noreferrer"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata" rel="noopener noreferrer"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>powerfuldevs</category>
      <category>mindmap</category>
      <category>openai</category>
    </item>
    <item>
      <title>Generate PowerPoint Presentation with OpenAI- The Future of Slide Decks</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 12:12:22 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/generate-powerpoint-presentation-with-openai-the-future-of-slide-decks-1a8d</link>
      <guid>https://forem.com/harshitlyzr/generate-powerpoint-presentation-with-openai-the-future-of-slide-decks-1a8d</guid>
      <description>&lt;p&gt;Presentations are pivotal in various corporate settings, from pitching ideas to stakeholders and conducting training sessions to reporting quarterly results. They serve as visual aids that enhance the understanding and retention of information. A good presentation can significantly influence decisions, motivate teams, and drive projects forward. Given their impact, ensuring presentations are engaging, informative, and professional is crucial.&lt;/p&gt;

&lt;p&gt;However, the challenge lies in the time and effort required to create such presentations. Crafting a presentation involves several steps, including content generation, design, formatting, and revision. This process can be particularly daunting for those who lack design skills or are pressed for time. This is where the "Presentation Maker" app comes into play.&lt;/p&gt;

&lt;p&gt;Creating presentations can be a time-consuming task, especially when it comes to generating content and ensuring that it's both engaging and informative. This is where the power of automation comes into play. By leveraging Lyzr Automata and OpenAI, we've developed a streamlined application that automates the creation of presentation slides, allowing users to focus on refining and delivering their content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lyzr Automata and OpenAI&lt;/strong&gt;&lt;br&gt;
Lyzr Automata is a powerful tool designed for automating various tasks, and when combined with OpenAI's capabilities, it becomes a formidable solution for generating presentation content. Our application utilizes these technologies to create a seamless experience for users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;br&gt;
User-Friendly Interface: The application is built using Streamlit, providing a clean and intuitive interface. Users can easily input their OpenAI API key and topic of interest.&lt;br&gt;
Automated Content Generation: By defining specific tasks for content creation and Python code generation, the application automates the process of drafting slide content and generating the corresponding Python-pptx code.&lt;br&gt;
Customizable and Extendable: Users can tweak the OpenAI parameters and the task instructions to fit their specific needs, making the solution highly customizable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Process&lt;/strong&gt;&lt;br&gt;
Input OpenAI API Key: Users input their OpenAI API key through a secure sidebar text input. This ensures that the application can access OpenAI's models to generate content.&lt;br&gt;
Enter Topic: Users provide the topic for their presentation. This topic serves as the basis for generating slide content.&lt;br&gt;
Generate Presentation: Upon clicking the "Generate" button, the application initiates a series of tasks:&lt;/p&gt;

&lt;p&gt;Content Writing: The first task generates a slide header and bullet points based on the provided topic.&lt;br&gt;
Python Code Generation: The second task takes the generated content and produces Python-pptx code to create a slide.&lt;br&gt;
Display the Output: The final Python code is displayed on the interface, ready for users to run and create their presentation slides.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;br&gt;
Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;br&gt;
openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;presentation_maker Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def presentation_maker(topics):
    content_agent = Agent(
        prompt_persona=f"You are a Content writer.",
        role="Content writer",
    )

    content_task = Task(
        name="content writer",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=content_agent,
        log_output=True,
        instructions=f"""
        write a Header and 4 bullet points for given {topics}.
        Bullet point is not more then 10 words.
        """,
    )

    python_agent = Agent(
        prompt_persona=f"You are a Python Developer.",
        role="Python Developer",
    )

    python_task = Task(
        name="content writer",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=python_agent,
        input_tasks=[content_task],
        log_output=True,
        instructions=f"""
            We have provided with header and 4 bullet points.
            please generate python-pptx code for a single slide with this header &amp;amp; bullet points.
            Separate the bullet points into separate texts.
            Do not set font size.
            Only generate code nothing else.
            """,
    )

    output = LinearSyncPipeline(
        name="Presentation Generation",
        completion_message="Presentation Generated!",
        tasks=[
            content_task,
            python_task
        ],
        ).run()
    return output[1]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines the core logic for generating Python code for a presentation slide:&lt;br&gt;
content_agent: Creates an Agent object representing a content writer persona.&lt;br&gt;
content_task: Creates a Task object with the following properties:&lt;br&gt;
name: "content writer"&lt;br&gt;
output_type: OutputType.TEXT (textual output)&lt;br&gt;
input_type: InputType.TEXT (textual input)&lt;br&gt;
model: openai_model (the OpenAI model object)&lt;br&gt;
agent: content_agent (the content writer agent)&lt;br&gt;
log_output: True (logs task output for debugging)&lt;br&gt;
instructions: Prompts the model to create a header and 4 bullet points for the given topic, with each bullet point not exceeding 10 words.&lt;br&gt;
python_agent: Creates an Agent object representing a Python developer persona.&lt;br&gt;
python_task: Creates a Task object with the following properties:&lt;br&gt;
name: "content writer" (same name as before, likely due to a typo)&lt;br&gt;
output_type: OutputType.TEXT (Python code as text)&lt;br&gt;
input_type: InputType.TEXT (text input from the content_task)&lt;br&gt;
model: openai_model&lt;br&gt;
agent: python_agent&lt;br&gt;
input_tasks: List containing the content_task&lt;br&gt;
LinearSyncPipeline:&lt;br&gt;
Creates a LinearSyncPipeline object named output.&lt;br&gt;
Sets the completion_message to be displayed when the pipeline finishes execution.&lt;br&gt;
Defines a list of tasks to be run in sequence:&lt;br&gt;
content_task: Creates the header and bullet points.&lt;br&gt;
python_task: Generates the Python code based on the task output.&lt;br&gt;
.run(): Executes the LinearSyncPipeline with the defined tasks.&lt;br&gt;
return output[1]['task_output']: Returns the output (Python code) generated by the second task (python_task).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Input and Button:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;topic = st.text_input("Enter Topic")

if st.button("Generate"):
    solution = presentation_maker(topic)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;topic = st.text_input("Enter Topic"): Creates a text input field for the user to enter the presentation topic.&lt;br&gt;
if st.button("Generate"): Creates a button labeled "Generate". When clicked, this block executes:&lt;br&gt;
solution = presentation_maker(topic): Calls the presentation_maker function with the entered topic.&lt;br&gt;
st.markdown(solution): Displays the generated Python code as markdown, allowing for proper formatting and code highlighting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt2bilic27m3i6hfelnj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt2bilic27m3i6hfelnj.png" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enhancing Productivity&lt;/strong&gt;&lt;br&gt;
This automated approach to presentation creation significantly enhances productivity. Instead of manually researching and drafting content, users can quickly generate a structured outline and corresponding slide code. This leaves more time for refining the presentation's delivery and design aspects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Future Possibilities&lt;/strong&gt;&lt;br&gt;
The current implementation focuses on generating content and code for a single slide. However, the framework can be extended to create multi-slide presentations, incorporate different content types, and even include design elements such as themes and layouts. With ongoing advancements in AI and automation tools, the possibilities for enhancing presentation creation are vast.&lt;/p&gt;

&lt;p&gt;try it now: &lt;a href="https://github.com/harshit-lyzr/presentation_maker"&gt;https://github.com/harshit-lyzr/presentation_maker&lt;/a&gt;&lt;br&gt;
For more information explore the website: Lyzr&lt;br&gt;
Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building an HTML to ReactJS Converter with Streamlit and Lyzr Automata</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 06:28:48 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/building-an-html-to-reactjs-converter-with-streamlit-and-lyzr-automata-134e</link>
      <guid>https://forem.com/harshitlyzr/building-an-html-to-reactjs-converter-with-streamlit-and-lyzr-automata-134e</guid>
      <description>&lt;p&gt;ReactJS has revolutionized front-end development with its component-based architecture and efficient state management. However, converting existing HTML, CSS, and JavaScript code into React components can be a daunting task. This blog post will guide you through building an HTML to ReactJS converter using Streamlit and Lyzr Automata. By leveraging the power of generative AI models, this application streamlines the conversion process, making it more efficient and user-friendly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Developers often face the challenge of migrating legacy web projects from HTML, CSS, and JavaScript to a modern ReactJS framework. This manual conversion process involves breaking down the HTML structure into reusable React components, managing state effectively, and ensuring the overall maintainability and performance of the codebase. The complexity of this task can lead to increased development time, potential for bugs, and a steep learning curve for developers not proficient in ReactJS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objective:&lt;/strong&gt;&lt;br&gt;
To address this challenge, we propose developing an AI-powered HTML to ReactJS converter application. This tool will leverage the capabilities of generative AI models to automate the conversion process, providing developers with a quick, efficient, and accurate way to transform their HTML, CSS, and JavaScript code into ReactJS components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scope:&lt;/strong&gt;&lt;br&gt;
The application will be built using Streamlit for the user interface and Lyzr Automata for integrating AI models. Users will input their HTML, CSS, and JavaScript code, and the application will output well-structured, maintainable ReactJS code. The tool will ensure the following:&lt;/p&gt;

&lt;p&gt;Component Structure: The HTML design will be broken down into reusable React components with a clear hierarchy.&lt;br&gt;
State Management: Identify components that require state management and implement appropriate solutions using React’s built-in hooks or external libraries.&lt;br&gt;
Props and Data Flow: Clearly define data flow between components, specifying the necessary props and their types.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;/p&gt;

&lt;p&gt;openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;reactjs_conversion Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def reactjs_conversion(html, css, javascript):
    react_agent = Agent(
        prompt_persona=f"You are a Frontend Engineer with over 10 years of experience.",
        role="Frontend Engineer",
    )

    react_task = Task(
        name="Dataset generation",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=react_agent,
        log_output=True,
        instructions=f"""
        We need to convert an existing HTML design with css and js into a ReactJS application. 
        The conversion should result in a well-structured, maintainable, and performant React codebase. 
        Follow Below Instructions:

        **Component Structure**:
        Break down the HTML design into reusable React components.
        Define a clear component hierarchy, ensuring components are logically organized and nested.

        **State Management**:
        Identify which components will need to manage state.
        Decide whether to use React's built-in state management (useState, useReducer) or an external library (Redux, MobX).

        **Props and Data Flow**:
        Determine how data will flow between components.
        Clearly define the props each component will require and their types.

        Only give ReactJS Code nothing apart from it.

        HTML: {html}
        CSS: {css}
        JAVASCRIPT: {javascript}


        """,
        )

    output = LinearSyncPipeline(
        name="Dataset Generation",
        completion_message="Dataset Generated!",
        tasks=[
            react_task
        ],
    ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines a function reactjs_conversion that takes HTML, CSS, and JavaScript code as input and returns the converted ReactJS code.&lt;br&gt;
Creates a react_agent object defining the prompt persona as a Frontend Engineer for better task understanding.&lt;br&gt;
Creates a react_task object specifying:&lt;br&gt;
Task name: “Dataset generation”&lt;br&gt;
Output type: Text (the generated ReactJS code)&lt;br&gt;
Input type: Text (the provided HTML, CSS, and JS code)&lt;br&gt;
Model: The openai_model object&lt;br&gt;
Agent: The react_agent object&lt;br&gt;
Instructions: A detailed prompt explaining the conversion task, emphasizing component structure, state management, props &amp;amp; data flow, and requesting only ReactJS code as output.&lt;br&gt;
Creates a LinearSyncPipeline object to execute the task in a linear sequence.&lt;br&gt;
Runs the pipeline and retrieves the task output, which is the generated ReactJS code.&lt;br&gt;
Returns the retrieved output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;col1, col2, col3 = st.columns(3)
with col1:
    html5 = st.text_area("Enter HTML code", height=300)

with col2:
    css3 = st.text_area("Enter CSS Code", height=300)

with col3:
    js = st.text_area("Enter JS code", height=300)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates three columns using st.columns() for HTML, CSS, and JavaScript code input with text areas using st.text_area().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Convert"):
    solution = reactjs_conversion(html5, css3, js)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates a button labeled “Convert” using st.button().&lt;br&gt;
On clicking the button:&lt;br&gt;
Calls the reactjs_conversion function with the entered HTML, CSS, and JS code.&lt;br&gt;
Displays the converted ReactJS code using st.markdown().&lt;br&gt;
&lt;strong&gt;Running the App&lt;/strong&gt;&lt;br&gt;
Finally, run the app using the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://github.com/harshit-lyzr/reactjs_convertor"&gt;https://github.com/harshit-lyzr/reactjs_convertor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Generative AI Dataset Generator App with Streamlit and Lyzr</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 06:26:24 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/generative-ai-dataset-generator-app-with-streamlit-and-lyzr-6no</link>
      <guid>https://forem.com/harshitlyzr/generative-ai-dataset-generator-app-with-streamlit-and-lyzr-6no</guid>
      <description>&lt;p&gt;In today’s data-driven world, generating realistic datasets is essential for testing, training machine learning models, and conducting meaningful analysis. To streamline this process, we present a Streamlit app that leverages the power of Lyzr Automata, a framework that simplifies building and managing AI-driven workflows. This blog will guide you through creating a Dataset Generator app using Lyzr Automata, OpenAI’s GPT models, and Streamlit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;br&gt;
Creating datasets manually can be time-consuming and prone to errors, especially when the data needs to be diverse and realistic. Automating dataset generation ensures consistency, saves time, and allows data engineers to focus on more complex tasks. This app aims to solve the problem of manual dataset creation by providing an easy-to-use interface where users can specify the format, fields, and number of entries for the dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
Our Streamlit-based Dataset Generator app leverages Lyzr Automata to automate the creation of datasets. Users can input their dataset format (CSV or Table), define the fields they need, and specify the number of entries. The app then generates a dataset that meets these criteria using an AI model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Lyzr Automata?&lt;/strong&gt;&lt;br&gt;
Lyzr Automata is used for its advanced capabilities in creating and managing AI agents and workflows, particularly in the context of Generative AI. Here are some key reasons why Lyzr Automata is beneficial:&lt;/p&gt;

&lt;p&gt;Ease of Integration: Lyzr Automata can be easily integrated into existing systems and workflows, making it convenient to implement AI-driven solutions without a complete overhaul of current processes.&lt;br&gt;
Automation: It helps automate repetitive tasks, reducing the manual effort required and increasing efficiency. This is particularly useful in tasks such as data preprocessing, content generation, and workflow management.&lt;br&gt;
Customization: Lyzr Automata offers a high degree of customization, allowing users to tailor AI agents to specific needs and requirements. This flexibility ensures that the solutions are aligned with business goals and objectives.&lt;br&gt;
Scalability: The platform is designed to scale seamlessly, accommodating increasing workloads and expanding as the business grows. This makes it suitable for both small-scale projects and large enterprise applications.&lt;br&gt;
Performance Optimization: Lyzr Automata includes tools for monitoring and optimizing the performance of AI agents, ensuring they operate efficiently and effectively.&lt;br&gt;
Support for Generative AI: It is particularly strong in supporting generative AI applications, such as creating text, images, and other content types, making it a valuable tool for businesses looking to leverage generative AI capabilities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the App Works&lt;/strong&gt;&lt;br&gt;
User Interface: The app uses Streamlit for its user-friendly interface. Users can enter their OpenAI API key, specify the format (CSV or Table), define the fields, and set the number of entries for the dataset.&lt;br&gt;
Lyzr Automata Workflow: The app defines a workflow using Lyzr Automata, where an agent powered by OpenAI’s GPT-4 generates the dataset based on user inputs.&lt;br&gt;
Dataset Generation: The specified format, fields, and number of entries are used to create a realistic and diverse dataset. The generated dataset is displayed within the app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if api:: Checks if an API key is entered.&lt;/p&gt;

&lt;p&gt;openai_model = OpenAIModel(): If a key is entered, creates an OpenAIModel object with the provided API key, model parameters (gpt-4-turbo-preview, temperature, max_tokens).&lt;br&gt;
else: If no key is entered, displays an error message in the sidebar.&lt;br&gt;
&lt;strong&gt;api_documentation Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def dataset_generation(format, fields, entries):
    dataset_agent = Agent(
        prompt_persona=f"You are a Data Engineer with over 10 years of experience.you cares about data integrity and believes in the importance of realistic datasets for meaningful analysis.",
        role="Data Engineer",
    )

    dataset = Task(
    name="Dataset generation",
    output_type=OutputType.TEXT,
    input_type=InputType.TEXT,
    model=openai_model,
    agent=dataset_agent,
    log_output=True,
    instructions=f"""
    Please generate a dataset in {format} format with the following fields:
    {fields}

    The dataset should contain {entries} entries.Each entry should be unique and provide a diverse representation across all fields.
    Ensure the entries are realistic and diverse.

    Accuracy is important, so ensure that {fields} are plausible and realistic. If using fictional data, maintain consistency and coherence within the dataset.
    Please provide the generated Dataset or output in the specified format.

    [!Important]Only generate Dataset nothing apart from it.
    """,
    )

    output = LinearSyncPipeline(
        name="Dataset Generation",
        completion_message="Dataset Generated!",
        tasks=[
            dataset
        ],
    ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;def dataset_generation(format, fields, entries):: Defines a function named dataset_generation that takes three arguments: format (CSV or Table), fields (comma-separated list of dataset fields), and entries (number of entries to generate).&lt;br&gt;
dataset_agent = Agent(): Creates an Agent object defining the prompt persona and role ("Data Engineer").&lt;br&gt;
dataset = Task(): Creates a Task object specifying details about the dataset generation task.&lt;br&gt;
name: Sets the task name to “Dataset generation”.&lt;br&gt;
output_type: Sets the expected output type as text.&lt;br&gt;
input_type: Sets the input type for the task as text.&lt;br&gt;
model: Assigns the openai_model object (if API key is provided).&lt;br&gt;
agent: Assigns the dataset_agent object.&lt;br&gt;
log_output: Sets logging for the task output to True.&lt;br&gt;
instructions: Defines a multi-line string containing instructions for the AI model. The instructions specify the desired format, fields, number of entries, data characteristics (unique, diverse, realistic), and output format.&lt;br&gt;
output = LinearSyncPipeline(): Creates a LinearSyncPipeline object named "Dataset Generation" with a completion message and assigns the dataset task to it.&lt;br&gt;
return output[0][‘task_output’]: Runs the pipeline, retrieves the task output from the first element (index 0) of the results, and returns it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;specify_format = st.selectbox("Enter format", ["CSV","Table"],placeholder="CSV")
specify_fields = st.text_area("Enter Fields", placeholder="Name: Customer Name, Age: Customer Age",height=300)
no_entries = st.number_input("Enter number of entries", placeholder="10")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;specify_format = st.selectbox(): Creates a dropdown menu named “Enter format” with options “CSV” and “Table” for users to select the desired dataset format.&lt;/p&gt;

&lt;p&gt;specify_fields = st.text_area(): Creates a multi-line text area named “Enter Fields” where users can input a comma-separated list of dataset fields (e.g., Name: Customer Name, Age: Customer Age).&lt;/p&gt;

&lt;p&gt;no_entries = st.number_input(): Creates a number input field named “Enter number of entries” where users can specify the desired number of entries for the generated dataset.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Generate"):
    solution = dataset_generation(specify_format, specify_fields, no_entries)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if st.button(“Generate”):: Creates a button labeled “Generate”. If the button is clicked, the following code block executes.&lt;br&gt;
solution = dataset_generation(): Calls the dataset_generation function with the user-selected format, entered fields, and number of entries.&lt;br&gt;
st.markdown(solution): Displays the generated dataset output as markdown formatted text on the app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running the App&lt;/strong&gt;&lt;br&gt;
Finally, run the app using the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://github.com/harshit-lyzr/dataset_generator"&gt;https://github.com/harshit-lyzr/dataset_generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contibute to Our Project: &lt;a href="https://github.com/LyzrCore/lyzr-automata"&gt;https://github.com/LyzrCore/lyzr-automata&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Streamline Your Code Documentation with Lyzr Code Comment Generator</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 06:23:59 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/streamline-your-code-documentation-with-lyzr-code-comment-generator-2cbk</link>
      <guid>https://forem.com/harshitlyzr/streamline-your-code-documentation-with-lyzr-code-comment-generator-2cbk</guid>
      <description>&lt;p&gt;In the world of software development, clear and concise code documentation is crucial. It helps in maintaining code, onboarding new team members, and ensuring that codebases remain understandable over time. Introducing the Lyzr Code Comment Generator, an innovative application designed to leverage the power of Lyzr Automata and Streamlit to automatically generate informative comments for your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Lyzr Code Comment Generator?&lt;/strong&gt;&lt;br&gt;
The Lyzr Code Comment Generator is an advanced tool that uses AI to analyze your code and generate detailed comments. This app is perfect for developers who want to improve their code readability and maintainability without spending hours on documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;br&gt;
Automated Code Commenting: Automatically generate clear, concise, and informative comments for your code.&lt;br&gt;
Insightful Explanations: Provides insights into the functionality and purpose of each section of code.&lt;br&gt;
Best Practices: Promotes good coding practices by highlighting important features and techniques used in the code.&lt;br&gt;
User-Friendly Interface: Built using Streamlit, the app offers an intuitive interface for easy use.&lt;br&gt;
How It Works&lt;br&gt;
Secure API Integration: Enter your OpenAI API key in the sidebar to access the GPT-4 Turbo model.&lt;br&gt;
Input Code: Paste your code snippet into the provided text area.&lt;br&gt;
Generate Comments: Click the ‘Convert’ button to generate comments for your code using Lyzr Automa.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
We create a sidebar for user inputs, including an API key input for accessing the OpenAI GPT-4 model. This ensures that the API key remains secure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;api_documentation Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def code_commenter(code_snippet):
    code_comment_agent = Agent(
        prompt_persona="you are a seasoned software engineer with a wealth of experience in writing, reviewing, and improving code",
        role="Software Engineer",
    )

    code_comment_task = Task(
        name="Code Commenting Task",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=code_comment_agent,
        log_output=True,
        instructions=f"""You are tasked with generating comments for a given piece of code. 
        Your comments should be clear, concise, and informative, providing insight into the functionality and purpose of each section of code. 
        You should strive to explain the logic behind the code, highlight any important features or techniques used, and offer suggestions for improvement if applicable. 
        Your goal is to help readers understand the code more easily and to promote good coding practices through your comments.

        Code: {code_snippet}
        """,
    )

    output = LinearSyncPipeline(
        name="Generate Comment",
        completion_message="Comment Generated!",
        tasks=[
            code_comment_task
        ],
    ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;def code_commenter(code_snippet):: Defines a function named code_commenter that takes user-provided code as input.&lt;br&gt;
code_comment_agent = Agent(...): Creates an Agent object defining the prompt persona and role for the AI model. Here, the persona is a "seasoned software engineer" with expertise in code review and improvement.&lt;br&gt;
code_comment_task = Task(...): Creates a Task object specifying the code commenting task. This includes details like:&lt;br&gt;
Task name: “Code Commenting Task”&lt;br&gt;
Output and Input types (text)&lt;br&gt;
The AI model to be used (openai_model)&lt;br&gt;
The defined code_comment_agent&lt;br&gt;
Instructions for the model:&lt;br&gt;
Generate clear, concise, and informative comments for the code.&lt;br&gt;
Explain the logic, highlight important features, and suggest improvements.&lt;br&gt;
Promote good coding practices through comments.&lt;br&gt;
The instructions also specify that the code will be provided as input (Code: {code_snippet}).&lt;br&gt;
output = LinearSyncPipeline(...): Creates a LinearSyncPipeline object specifying:&lt;br&gt;
Pipeline name: “Generate Comment”&lt;br&gt;
Completion message: “Comment Generated!”&lt;br&gt;
List of tasks to be executed: only the code_comment_task in this case.&lt;br&gt;
output.run(): Executes the pipeline, triggering the code commenting task using the defined model and instructions.&lt;br&gt;
return output[0]['task_output']: Retrieves the output of the first task (the code commenting task) from the output list and returns it. This likely contains the generated code comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;code = st.text_area("Enter Code", height=300)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;code = st.text_area creates a text area for users to enter their code snippet. It sets the height to 300 pixels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Convert"):
    solution = code_commenter(code)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines a button labeled “Convert”. Clicking the button calls the code_commenter function with the user-provided code and displays the returned comments using markdown formatting.&lt;br&gt;
&lt;strong&gt;Running the App&lt;/strong&gt;&lt;br&gt;
Finally, run the app using the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://lyzr-code-comment-generator.streamlit.app/"&gt;https://lyzr-code-comment-generator.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Enhance Your Review Management with AI Review Aggregator and Summarizer</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 06:21:55 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/enhance-your-review-management-with-ai-review-aggregator-and-summarizer-bo9</link>
      <guid>https://forem.com/harshitlyzr/enhance-your-review-management-with-ai-review-aggregator-and-summarizer-bo9</guid>
      <description>&lt;p&gt;In today’s digital marketplace, customer reviews play a pivotal role in shaping consumer decisions and brand reputation. Managing and summarizing these reviews effectively can provide invaluable insights for businesses. Introducing the AI Review Aggregator and Summarizer, an innovative application designed to harness the power of Lyzr Automata and Streamlit, making review analysis and summarization more efficient and insightful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is AI Review Aggregator and Summarizer?&lt;/strong&gt;&lt;br&gt;
The AI Review Aggregator and Summarizer is a cutting-edge app that uses advanced AI models to perform sentiment analysis, aggregate reviews, and provide comprehensive summaries. This tool is essential for businesses seeking to streamline their review management process and gain actionable insights from customer feedback.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;br&gt;
Accurate Sentiment Analysis: Classify reviews into positive, negative, or neutral categories to understand customer sentiment.&lt;br&gt;
Thematic Aggregation: Identify common themes and key points from multiple reviews to provide a consolidated overview.&lt;br&gt;
Coherent Summaries: Generate concise summaries that capture the essence of individual feedback using both extractive and abstractive text summarization techniques.&lt;br&gt;
User-Friendly Display: Present reviews in an easy-to-read format, including key insights, pros and cons, star ratings, sentiment graphs, and keyword clouds.&lt;br&gt;
How It Works&lt;br&gt;
Simple Setup: Enter your OpenAI API key in the sidebar for secure access to the GPT-4 Turbo model.&lt;br&gt;
Input Reviews: Paste your reviews into the provided text area.&lt;br&gt;
Analyze and Summarize: Click the ‘Convert’ button to perform analysis and generate summaries.&lt;br&gt;
&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
We create a sidebar for user inputs, including an API key input for accessing the OpenAI GPT-4 model. This ensures that the API key remains secure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;api_documentation Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def review_analyst(reviews):
    review_agent = Agent(
        prompt_persona="You are an Expert Review Aggregator and Summarizer",
        role="Review Aggregator and Summarizer",
    )

    review_analysis_task = Task(
        name="Review Analysis Task",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=review_agent,
        log_output=True,
        instructions=f"""Perform sentiment analysis to classify reviews into positive, negative, or neutral categories.
        Aggregate reviews based on common themes, sentiments, and key points.Summarize multiple reviews into a single coherent review that captures the essence of individual feedback.
        Use techniques like text summarization (extractive and abstractive) to create concise summaries.
        Display consolidated reviews in a user-friendly format, highlighting key insights, pros and cons, and overall sentiment. 
        Provide visual aids like star ratings, sentiment graphs, and keyword clouds to enhance readability.

        Reviews: {reviews}

        ##Output Requirements:
        ##Movie Name:
        ##Overview:
        ##Summarized Reviews:
        ##Key Insights:
            ###Pros:
            ###Cons:
        ##Overall Sentiment:
            ###Star Ratings: ⭐(use this emoji for rating️) 
            ###Sentiment Graph:
            ###Keyword Cloud:

        """,
    )

    output = LinearSyncPipeline(
        name="review Analysis",
        completion_message="Review Analysis Done!",
        tasks=[
            review_analysis_task
        ],
    ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;def review_analyst(reviews):: Defines a function named review_analyst that takes user-provided reviews as input.&lt;br&gt;
review_agent = Agent(...): Creates an Agent object defining the prompt persona and role for the AI model. Here, the persona is an "Expert Review Aggregator and Summarizer".&lt;br&gt;
review_analysis_task = Task(...): Creates a Task object specifying the review analysis task. This includes details like:&lt;br&gt;
Task name: “Review Analysis Task”&lt;br&gt;
Output and Input types (text)&lt;br&gt;
The AI model to be used (openai_model)&lt;br&gt;
The defined review_agent&lt;br&gt;
Instructions for the model:&lt;br&gt;
Perform sentiment analysis (positive, negative, neutral)&lt;br&gt;
Aggregate reviews based on themes, sentiments, and key points.&lt;br&gt;
Summarize reviews into a single coherent summary capturing individual feedback.&lt;br&gt;
Use summarization techniques (extractive and abstractive) for concise summaries.&lt;br&gt;
Display consolidated reviews in a user-friendly format with key insights, pros, cons, and overall sentiment.&lt;br&gt;
Include visual aids like star ratings, sentiment graphs, and keyword clouds.&lt;br&gt;
The instructions also specify the desired output format with sections for movie name, overview, summarized reviews, key insights (pros and cons), overall sentiment (including star ratings, sentiment graph, and keyword cloud).&lt;br&gt;
output = LinearSyncPipeline(...): Creates a LinearSyncPipeline object specifying:&lt;br&gt;
Pipeline name: “review Analysis”&lt;br&gt;
Completion message: “Review Analysis Done!”&lt;br&gt;
List of tasks to be executed: only the review_analysis_task in this case.&lt;br&gt;
output.run(): Executes the pipeline, triggering the review analysis task using the defined model and instructions.&lt;br&gt;
return output[0]['task_output']: Retrieves the output of the first task (the review analysis task) from the output list and returns it. This likely contains the analyzed and summarized reviews.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;review = st.text_area("Enter Your Reviews", height=300)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;review = st.text_area creates a text area for users to enter their Reviews. It sets the height to 300 pixels.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Convert"):
    solution = review_analyst(review)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Defines a button labeled “Convert”. Clicking the button calls the review_analyst function with the user-provided reviews and displays the returned analysis (potentially including summarized reviews, key insights, and visualizations) using markdown formatting.&lt;br&gt;
&lt;strong&gt;Running the App&lt;/strong&gt;&lt;br&gt;
Finally, run the app using the following command in your terminal:s&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://lyzr-review-analyst.streamlit.app/"&gt;https://lyzr-review-analyst.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Revolutionize Your Movie Script Translation with AI</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 01 Jul 2024 06:18:43 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/revolutionize-your-movie-script-translation-with-ai-27gm</link>
      <guid>https://forem.com/harshitlyzr/revolutionize-your-movie-script-translation-with-ai-27gm</guid>
      <description>&lt;p&gt;In the digital age, creating multilingual content is essential to reach a broader audience. However, translating movie scripts while preserving their tone, style, and cultural context is a significant challenge. Our new AI Movie Script Autodubbing app, powered by Lyzr Automata and Streamlit, aims to simplify this process, making it seamless and efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is AI Movie Script Autodubbing?&lt;/strong&gt;&lt;br&gt;
AI Movie Script Autodubbing is an advanced application designed to translate movie scripts from one language to another while maintaining the original essence of the content. It leverages the powerful capabilities of the OpenAI Model and Lyzr Automata’s sophisticated pipelines to deliver accurate and culturally relevant translations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Does It Work?&lt;/strong&gt;&lt;br&gt;
User-Friendly Interface: Built using Streamlit, the app offers an intuitive interface where users can easily input their script and select the source and target languages.&lt;br&gt;
Secure API Integration: Users can securely enter their OpenAI API key to access the GPT-4 Turbo model, ensuring privacy and data protection.&lt;br&gt;
Advanced Translation Pipeline: Utilizing Lyzr Automata’s LinearSyncPipeline, the app follows a structured process to translate scripts accurately, maintaining the tone and style of the original content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Accurate Translations: The app ensures that translations are not only accurate but also convey the original meaning and emotions of the dialogues and descriptions.&lt;br&gt;
Cultural Adaptation: It adapts cultural references appropriately, making sense to the target language audience.&lt;br&gt;
Consistency: The app maintains the characters’ personalities and voices consistent with the original script.&lt;br&gt;
Formatting Preservation: It preserves the formatting of the script, including scene headings, action lines, and dialogues.&lt;br&gt;
Why Choose AI Movie Script Autodubbing?&lt;br&gt;
AI Content Detector: Our app uses advanced AI technology similar to content detectors to ensure high-quality translations.&lt;br&gt;
AI Content Generator: Leveraging capabilities akin to AI content generators, the app produces natural and fluent translations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Imports:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imports necessary libraries: streamlit, libraries from lyzr_automata&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install lyzr_automata streamlit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import streamlit as st
from lyzr_automata.ai_models.openai import OpenAIModel
from lyzr_automata import Agent,Task
from lyzr_automata.pipelines.linear_sync_pipeline import LinearSyncPipeline
from PIL import Image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sidebar Configuration&lt;/strong&gt;&lt;br&gt;
We create a sidebar for user inputs, including an API key input for accessing the OpenAI GPT-4 model. This ensures that the API key remains secure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;api = st.sidebar.text_input("Enter our OPENAI API KEY Here", type="password")
if api:
    openai_model = OpenAIModel(
        api_key=api,
        parameters={
            "model": "gpt-4-turbo-preview",
            "temperature": 0.2,
            "max_tokens": 1500,
        },
    )
else:
    st.sidebar.error("Please Enter Your OPENAI API KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;api_documentation Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def script_translator(lang1, lang2, script):
    translator_agent = Agent(
        prompt_persona=f"You are a Script translator with over 10 years of experience in the film industry.You have a deep understanding of both {lang1} and {lang2} languages and is well-versed in the nuances of movie scripts.",
        role="Script Translation",
    )

    translation_task = Task(
        name="Script Translation Task",
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
        model=openai_model,
        agent=translator_agent,
        log_output=True,
        instructions=f"""Translate the provided movie script from {lang1} to {lang2} while maintaining the original tone, style, and cultural context.
        Follow Below Instructions:
            - Ensure that the translation is accurate and conveys the original meaning and emotions of the dialogues and descriptions.
            - Adapt cultural references appropriately to make sense to a {lang2}-speaking audience.
            - Maintain the natural flow of conversations and descriptions, ensuring that the translated text sounds natural to native {lang2} speakers.
            - Keep the characters' personalities and voices consistent with the original script.
            - Preserve the formatting of the script, including scene headings, action lines, and dialogues.

        Script: {script}

        """,
    )

    output = LinearSyncPipeline(
        name="Script Translation",
        completion_message="Script Translation Done!",
        tasks=[
            translation_task
        ],
    ).run()
    return output[0]['task_output']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;def script_translator(lang1, lang2, script):: Defines a function named script_translator that takes three arguments:&lt;br&gt;
lang1: The source language of the script.&lt;br&gt;
lang2: The target language for translation.&lt;br&gt;
script: The script content to be translated.&lt;br&gt;
translator_agent = Agent(...): Creates an Agent object defining the prompt persona and role for the AI model. The persona describes the agent as a script translator with expertise in the source and target languages.&lt;br&gt;
translation_task = Task(...): Creates a Task object defining the translation task. This includes the task name, output and input types, the AI model to be used, the agent persona, logging configuration, and instructions for the model. The instructions specify the translation goals, cultural adaptation considerations, maintaining natural flow and character consistency, and preserving script formatting.&lt;br&gt;
output = LinearSyncPipeline(...): Creates a LinearSyncPipeline object specifying the pipeline name, completion message ("Script Translation Done!"), and the list of tasks to be executed (in this case, only the translation_task).&lt;br&gt;
output.run(): This line executes the LinearSyncPipeline object. The run method likely triggers the translation task using the defined OpenAI model and agent.&lt;br&gt;
return output[0]['task_output']: After running the pipeline, the code retrieves the output of the first task (the translation task) from the output list. The specific index ([0]) is used because there's only one task in this pipeline. The output likely contains the translated script text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Code Input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;language1 = st.text_input("Enter Your Script Language", placeholder="English")
language2 = st.text_input("Enter Translating language", placeholder="Hindi")
scripts = st.text_area("Enter Your Script", height=300)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;language1 = st.text_input(...): Creates a text input field in the app where users can enter the source language of their script.&lt;br&gt;
language2 = st.text_input(...): Creates another text input field for users to specify the desired target language for translation.&lt;br&gt;
scripts = st.text_area(...): Creates a text area where users can paste their script content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate Button and Output Display:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if st.button("Translate"):
    solution = script_translator(language1, language2, scripts)
    st.markdown(solution)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if st.button("Translate"):: Checks if the user clicks a button labeled "Translate".&lt;br&gt;
solution = script_translator(...): If the button is clicked, calls the script_translator function with the user-provided languages and script content. The function presumably returns the translated script text.&lt;br&gt;
st.markdown(solution): Displays the translated script text (stored in the solution variable) using markdown formatting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running the App&lt;/strong&gt;&lt;br&gt;
Finally, run the app using the following command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://lyzr-script-translation.streamlit.app/"&gt;https://lyzr-script-translation.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://www.lyzr.ai/"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Creating an Interactive Airbnb Chatbot with Lyzr, OpenAI and Streamlit</title>
      <dc:creator>harshit-lyzr</dc:creator>
      <pubDate>Mon, 24 Jun 2024 06:44:47 +0000</pubDate>
      <link>https://forem.com/harshitlyzr/creating-an-interactive-airbnb-chatbot-with-lyzr-openai-and-streamlit-55bg</link>
      <guid>https://forem.com/harshitlyzr/creating-an-interactive-airbnb-chatbot-with-lyzr-openai-and-streamlit-55bg</guid>
      <description>&lt;p&gt;In the competitive landscape of the hospitality industry, providing exceptional guest experiences is crucial for retaining customers and gaining positive reviews. Airbnb hosts face the challenge of addressing numerous queries from guests promptly and accurately. Common questions range from property rules and amenities to local recommendations and troubleshooting issues during their stay. Managing these interactions manually can be time-consuming and prone to inconsistencies, especially for hosts managing multiple properties or those who are frequently unavailable to respond immediately.&lt;/p&gt;

&lt;p&gt;Airbnb hosts need an efficient, reliable, and consistent way to address guest inquiries to enhance their stay experience. Traditional methods of communication, such as emails and phone calls, can lead to delays and miscommunications. There is a clear need for an automated solution that can provide guests with quick, accurate, and friendly responses to their queries about the property and surrounding area.&lt;/p&gt;

&lt;p&gt;The objective is to develop an intelligent chatbot integrated into a Streamlit web application that leverages OpenAI’s API to handle guest inquiries. The chatbot should be able to:&lt;/p&gt;

&lt;p&gt;Provide accurate and relevant answers to common questions about the Airbnb property, such as wifi credentials, house rules, check-in/check-out times, and amenities.&lt;br&gt;
Offer personalized local recommendations based on the host’s knowledge.&lt;br&gt;
Operate with a welcoming, friendly, and attentive personality to ensure a positive guest interaction.&lt;br&gt;
Maintain consistency and reliability in the information provided to guests.&lt;br&gt;
We propose the development of the “Airbnb Chatbot,” a Streamlit-based web application that integrates the Lyzr QABot with OpenAI’s API. This chatbot will be trained on a comprehensive FAQ document related to the Airbnb property and will follow a predefined prompt that outlines its personality and response style. The chatbot will:&lt;/p&gt;

&lt;p&gt;Utilize advanced natural language processing capabilities to understand and respond to guest inquiries.&lt;br&gt;
Be accessible to guests 24/7 through a user-friendly interface.&lt;br&gt;
Ensure that responses are based strictly on the provided data to avoid misinformation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Metrics for Success:&lt;/strong&gt;&lt;br&gt;
Response Time: Average time taken to respond to guest queries.&lt;br&gt;
Guest Satisfaction: Measured through feedback and ratings.&lt;br&gt;
Consistency: Accuracy and reliability of the information provided by the chatbot.&lt;br&gt;
Usage Rate: Frequency of guest interactions with the chatbot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before we dive into the code, make sure you have the following:&lt;/p&gt;

&lt;p&gt;Python 3.8+ installed.&lt;br&gt;
Streamlit installed (pip install streamlit).&lt;br&gt;
OpenAI API Key.&lt;br&gt;
Lyzr library installed (pip install lyzr).&lt;br&gt;
dotenv library for loading environment variables (pip install python-dotenv).&lt;br&gt;
PIL (Pillow) for image processing (pip install pillow).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up the Environment&lt;/strong&gt;&lt;br&gt;
First, ensure that your OpenAI API key is stored in a .env file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OPENAI_API_KEY=your_openai_api_key_here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importing Libraries and Loading Environment Variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
import os
from lyzr import QABot
import openai
from dotenv import load_dotenv
from PIL import Image

load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code starts by importing necessary libraries:&lt;br&gt;
streamlit as st: for building the Streamlit application.&lt;br&gt;
os: for interacting with the operating system.&lt;br&gt;
lyzr and QABot: for using Lyzr's question answering capabilities.&lt;br&gt;
openai: (commented out) potentially for integration with OpenAI services.&lt;br&gt;
dotenv: for loading environment variables (likely containing an OpenAI API key).&lt;br&gt;
It then loads environment variables using load_dotenv() (likely for the OpenAI API key).&lt;br&gt;
An OpenAI API key is set using os.getenv("OPENAI_API_KEY"), but it's currently commented out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Defining the Chatbot Personality:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prompt=f"""
You are an Airbnb host with a welcoming, friendly, and attentive personality. 
You enjoy meeting new people and providing them with a comfortable and memorable stay. 
You have a deep knowledge of your local area and take pride in offering personalized recommendations. 
You are patient and always ready to address any concerns or questions with a smile. 
You ensure that your space is clean, cozy, and equipped with all the essentials. 
Your goal is to create a home away from home for your guests and to make their stay as enjoyable and stress-free as possible. 
When responding to guest questions, provide clear, helpful, and friendly answers based strictly on the provided data. 
[IMPORTANT]Do not give answers outside of the given information.
"""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A variable prompt is defined as a string containing the desired personality and functionalities for the Lyzr QABot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing the Chatbot Functionality:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@st.cache_resource
def rag_implementation():
    with st.spinner("Generating Embeddings...."):
        qa = QABot.pdf_qa(
            input_files=["airbnb.pdf"],
            system_prompt=prompt
        )
    return qa

st.session_state["chatbot"] = rag_implementation()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A function rag_implementation() is defined using &lt;a class="mentioned-user" href="https://dev.to/st"&gt;@st&lt;/a&gt;.cache_resource. This function uses Streamlit caching to avoid redundant computations.&lt;/p&gt;

&lt;p&gt;It displays a spinner message “Generating Embeddings…” while the code executes.&lt;br&gt;
Inside the function, it creates a QABot instance using QABot.pdf_qa().&lt;br&gt;
It specifies the input file “airbnb.pdf” containing Airbnb information and FAQs.&lt;br&gt;
It sets the system prompt to the previously defined prompt to guide the chatbot's responses.&lt;br&gt;
The function returns the created QABot object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Managing Chat State and User Interactions:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if "messages" not in st.session_state:
    st.session_state.messages = []

for message in st.session_state.messages:
    with st.chat_message(message["role"]):
        st.markdown(message["content"])

if "chatbot" in st.session_state:
    if prompt := st.chat_input("What is up?"):
        st.session_state.messages.append({"role": "user", "content": prompt})
        with st.chat_message("user"):
            st.markdown(prompt)

        with st.chat_message("assistant"):
            response = st.session_state["chatbot"].query(prompt)
            chat_response = response.response
            response = st.write(chat_response)
        st.session_state.messages.append(
            {"role": "assistant", "content": chat_response}
        )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code retrieves the chatbot instance from the session state (st.session_state["chatbot"]) using the result of rag_implementation().&lt;br&gt;
It checks if a key “messages” exists in the session state. If not, it initializes an empty list for messages (st.session_state.messages = []).&lt;br&gt;
The code iterates through the existing messages in the session state and displays them using st.chat_message() with the message role ("user" or "assistant") and content.&lt;br&gt;
The code checks if the chatbot instance exists in the session state.&lt;br&gt;
If the chatbot exists, it displays a chat input box using st.chat_input() with a prompt "What is up?".&lt;br&gt;
If the user enters a message, it’s stored in the session state messages list with the user role (“user”). The message is also displayed with st.chat_message().&lt;br&gt;
With another st.chat_message(), the code calls the chatbot's query() method with the user message to get a response.&lt;br&gt;
The chatbot response is stored in a variable chat_response.&lt;br&gt;
The response is displayed on the screen using st.write().&lt;br&gt;
Finally, the chatbot response is added to the session state messages with the assistant role (“assistant”).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Running the App:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To run the Streamlit app, save the code in a file (e.g., app.py) and use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;try it now: &lt;a href="https://lyzr-airbnb-host.streamlit.app/"&gt;https://lyzr-airbnb-host.streamlit.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information explore the website: &lt;a href="https://lyzr.ai"&gt;Lyzr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/harshit-lyzr/airbnb_chatbot"&gt;https://github.com/harshit-lyzr/airbnb_chatbot&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
