DEV Community

Akshay Keerthi
Akshay Keerthi

Posted on

Building a Plant Diagnosis Assistant using Lyzr SDK

In the age of technology, even plant care is getting an upgrade. Imagine having a personal plant expert at your fingertips, ready to diagnose and remedy any issues your green friends may be facing. In this post, we’ll explore how this AI-powered app is transforming the way we care for our plants, powered by Lyzr SDK.

Image description

The Plant Diagnosis Assistant is a web application designed to simplify the process of diagnosing and treating plant health issues. Whether you’re dealing with yellowing leaves, wilting stems, or mysterious spots, our app is here to help. Simply input your plant’s symptoms or concerns, and let our AI-powered assistant do the rest. From accurate diagnoses to tailored care instructions, we’ve got you covered every step of the way.

At the heart of Your Plant Health Companion is Lyzr SDK, a powerful toolkit for building AI-powered applications. Our app leverages Lyzr SDK’s advanced AI models to analyze user input, generate detailed diagnoses, and provide actionable recommendations. With Lyzr SDK, we’re able to deliver a seamless user experience, complete with personalized guidance tailored to each user’s specific needs.

Why use Lyzr SDK’s?

With Lyzr SDKs, crafting your own GenAI application is a breeze, requiring only a few lines of code to get up and running swiftly.

Checkout the Lyzr SDK’s

Lets get Started!

Create an app.py file

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
from lyzr_automata.tasks.task_literals import InputType, OutputType
import os
# Set the OpenAI API key
os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]
st.markdown(
    """
    <style>
    .app-header { visibility: hidden; }
    .css-18e3th9 { padding-top: 0; padding-bottom: 0; }
    .css-1d391kg { padding-top: 1rem; padding-right: 1rem; padding-bottom: 1rem; padding-left: 1rem; }
    </style>
    """,
    unsafe_allow_html=True,
)
image = Image.open("./logo/lyzr-logo.png")
st.image(image, width=150)
# App title and introduction
st.title("Plant Diagnosis Assistant")
st.markdown("Welcome to your Plant Health Companion, your go-to resource for diagnosing and remedying plant issues powered by Lyzr Automata. What can I assist you with today? ")
input = st.text_input("Please enter your problems or concerns",placeholder=f"""Type here""")
Enter fullscreen mode Exit fullscreen mode

In this snippet, we import the necessary libraries and set up the Streamlit interface for our app. We also load the Lyzr logo and display it on the app interface, providing users with a visual indication of the app’s association with Lyzr Automata.

open_ai_text_completion_model = OpenAIModel(
    api_key=st.secrets["apikey"],
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)
Enter fullscreen mode Exit fullscreen mode

Here, we initialize the OpenAI model using Lyzr SDK, configuring parameters such as the model version, temperature, and maximum tokens for text generation.

def generation(input):
    generator_agent = Agent(
        role=" Expert PLANT DIAGNOSIS ASSISTANT ",
        prompt_persona=f"Your task is to CAREFULLY ANALYZE the user's input regarding their plant's type, visible symptoms, and any other relevant details they provide. You MUST use your EXPERTISE to pinpoint possible issues and offer GUIDANCE on both IMMEDIATE and LONG-TERM care for their plant.")
    prompt = f"""
    # Instructions...
    """
    generator_agent_task = Task(
        name="Generation",
        model=open_ai_text_completion_model,
        agent=generator_agent,
        instructions=prompt,
        default_input=input,
        output_type=OutputType.TEXT,
        input_type=InputType.TEXT,
    ).execute()
Enter fullscreen mode Exit fullscreen mode

This function, generation, represents the core functionality of our app. It takes user input, creates a persona for the AI agent, defines task instructions, and executes the task using Lyzr SDK. The generated output, containing diagnoses and care instructions, is then returned to be displayed to the user.

With Plant Diagnosis Assistant, caring for your plants has never been easier. Powered by Lyzr SDK, our app combines the latest advancements in AI technology with expert knowledge to deliver personalized plant care guidance right to your fingertips. Say goodbye to guesswork and hello to healthier, happier plants!

App link: https://plantdiagnosis-lyzr.streamlit.app/

Source Code: https://github.com/isakshay007/Plant_Diagnosis

The Plant Diagnosis Assistant is powered by the Lyzr Automata Agent, utilizing the capabilities of OpenAI’s GPT-4 Turbo. For any inquiries or issues, please contact Lyzr. You can learn more about Lyzr and their offerings through the following links:

Website: Lyzr.ai
Book a Demo: Book a Demo
Discord: Join our Discord community
Slack: Join our Slack channel

Top comments (0)