DEV Community

Akshay Keerthi
Akshay Keerthi

Posted on

Building a Skin Care Assistant with Lyzr Automata

In the ever-evolving world of skincare, finding the perfect regimen tailored to your unique skin type and concerns can be a daunting task. However, thanks to advancements in artificial intelligence (AI) and natural language processing (NLP), achieving radiant, healthy skin is now easier than ever. Enter the Skin Care Assistant, an application powered by Lyzr Automata that offers personalized skincare recommendations at your fingertips.

Image description

The Skin Care Assistant takes the guesswork out of skincare by harnessing the power of AI to provide customized recommendations based on your specific skin type and concerns. Whether you have oily, sensitive, combination, normal, or dry skin, the Skin Care Assistant has you covered. Simply input your skin type and any particular concerns you’d like to address, and let the magic happen.

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 a new file and use that

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
Enter fullscreen mode Exit fullscreen mode

This Python script uses the Streamlit library to create a web application. It imports modules for interacting with the Lyzr Automata library, handling image display, and managing environment variables. The core functionality likely involves AI-driven tasks for skincare recommendations, utilizing OpenAI models through the OpenAIModel class .

This line of code sets the environment variable “OPENAI_API_KEY” to the value stored in the Streamlit secrets dictionary under the key “apikey”. This API key is essential for authenticating and accessing the OpenAI API, allowing the application to utilize OpenAI’s models and services for natural language processing tasks. By assigning the API key to the environment variable, it ensures that subsequent requests made to the OpenAI API are properly authenticated.

# Set the OpenAI API key
os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]
Enter fullscreen mode Exit fullscreen mode
open_ai_text_completion_model = OpenAIModel(
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
Enter fullscreen mode Exit fullscreen mode

This block of code initializes an instance of the OpenAIModel class with specific parameters. The api_key parameter is set to the value retrieved from Streamlit secrets, ensuring authentication with the OpenAI API. The parameters dictionary contains settings for the AI model, specifying “gpt-4-turbo-preview” as the model to be used, a temperature of 0.2, and a maximum token limit of 1500. These settings configure how the model generates text responses, controlling factors such as creativity and length. The initialized OpenAIModel instance will be utilized for generating text based on input prompts in subsequent parts of the code.

def skincare_generation(input):
    generator_agent = Agent(
        role="SKINCARE CONSULTANT expert",
        prompt_persona=f"Your task is to RECOMMEND a CUSTOMIZED SKINCARE REGIMEN tailored to user entered skin types"

    prompt = f"""
You are an Expert SKINCARE CONSULTANT. Always introduce yourself. Your task is to RECOMMEND a CUSTOMIZED SKINCARE REGIMEN tailored to user entered skin types—be it OILY, SENSITIVE, COMBINATION, NORMAL, or DRY and also based on SPECIFIC CONCERNS or requirements mentioned by the user.

Enter fullscreen mode Exit fullscreen mode

This function, skincare_generation(input), is responsible for generating personalized skincare recommendations based on user input. It begins by creating an instance of the Agent class, which represents a virtual entity with a specific role and persona. In this case, the agent is defined as a "SKINCARE CONSULTANT expert" with a personalized prompt_persona indicating its task.

The function then constructs a prompt, which serves as the input to the AI model for generating the skincare recommendations. The prompt provides instructions and context for the AI model, guiding it to recommend a customized skincare regimen tailored to various skin types (such as OILY, SENSITIVE, COMBINATION, NORMAL, or DRY) and specific concerns or requirements mentioned by the user.

   generator_agent_task = Task(
        name="skincare Generation",

    return generator_agent_task 

if st.button("Generate!"):
    solution = skincare_generation(input)
Enter fullscreen mode Exit fullscreen mode

A function skincare_generation(input) is defined to generate personalized skincare recommendations based on user input. Within this function, a Task object is instantiated to execute the skincare generation process. The Task constructor takes parameters such as the task name, the AI model to be used, the agent responsible for the task, the prompt instructions, default input, and the expected input and output types. Once the Task object is created, the execute() method is called to generate the skincare recommendations.

The code then checks if a button labeled “Generate!” has been clicked in the Streamlit interface. Upon clicking the button, the skincare_generation function is invoked with the user input, and the resulting skincare recommendations are displayed in the Streamlit application interface. This mechanism allows users to obtain personalized skincare advice by simply entering their skin type and concerns and clicking the "Generate!" button.

The Skin Care Assistant, powered by Lyzr Automata, represents a paradigm shift in skincare recommendations through AI integration. By utilizing advanced AI models like GPT-4 Turbo, it delivers personalized skincare regimens tailored to individual skin types and concerns. This innovative tool simplifies skincare routines, offering users expert guidance and informed decisions for achieving healthier, radiant skin. With its user-friendly interface and commitment to excellence, the Skin Care Assistant redefines skincare, providing tailored solutions at the forefront of digital innovation.

App link:

Source Code:

Connect with Lyzr
To learn more about Lyzr and its SDK’s, visit our website or get in touch with our team:

Book a Demo: Book a Demo
Discord: Join our Discord community
Slack: Join our Slack channel

Top comments (0)