In today’s tech-driven world, AI is making significant strides in healthcare, including veterinary care. Imagine having a virtual assistant that can provide expert advice based on your pet’s breed, age, and symptoms. With Lyzr Automata and Streamlit, you can build a powerful Pet Diagnosis Assistant. This guide will walk you through the process step-by-step.
The Pet Diagnosis Assistant uses Lyzr Automata and OpenAI’s GPT-4 model to offer expert veterinary advice. By entering details about your pet, such as breed, age, and symptoms, you can receive tailored guidance and preliminary diagnoses.
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.
Lets get Started
Setting Up the Environment
First, ensure you have Streamlit and Lyzr Automata installed. You can install these packages using pip:
pip install streamlit lyzr-automata
Start by importing the necessary libraries and setting up your Streamlit app:
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
import os
Configuring the OpenAI API Key
Ensure your OpenAI API key is set. You can securely store and access it using Streamlit secrets:
os.environ["OPENAI_API_KEY"] = st.secrets["apikey"]
Input Section
An input field snipped for users to provide their pet’s information:
st.title("Pet Diagnosis Assistant 🐶")
st.markdown("Welcome to the Pet Diagnosis Assistant! Tell us about your pet's symptoms, and we'll provide expert advice tailored to their breed and age, helping you understand and address their health concerns.")
input = st.text_input("Please enter the breed, age, and the concerns:", placeholder="Type here")
Setting Up the AI Model
Configure the OpenAI model for text completion:
open_ai_text_completion_model = OpenAIModel(
api_key=st.secrets["apikey"],
parameters={
"model": "gpt-4-turbo-preview",
"temperature": 0.2,
"max_tokens": 1500,
},
)
Creating the Generation Function
Define a function to generate the veterinary advice:
def generation(input):
generator_agent = Agent(
role="Expert VETERINARY DIAGNOSTICIAN",
prompt_persona="Your task is to ANALYZE the user-provided data on their pet's breed, age, and visible symptoms or issues observed. You MUST CAREFULLY provide the necessary diagnosis and step-by-step guidance."
)
prompt = f"""
You are an Expert VETERINARY DIAGNOSTICIAN. Your task is to ANALYZE the user-provided data on their pet's breed, age, and visible symptoms or issues observed. You MUST CAREFULLY provide the necessary diagnosis and step-by-step guidance.Follow this sequence of steps:
[Prompts here]
"""
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()
return generator_agent_task
Adding the Assist Button
Add a button that triggers the generation function when clicked:
if st.button("Assist!"):
solution = generation(input)
st.markdown(solution)
With these steps, you can create a Pet Diagnosis Assistant that provides expert advice based on your pet’s details. This application not only demonstrates the capabilities of Lyzr Automata and Streamlit but also highlights how AI can be leveraged to enhance pet care.
App link: https://petassistant-lyzr.streamlit.app/
Source Code: https://github.com/isakshay007/Pet_Assistant
The Pet Diagnosis Assistant is powered by the Lyzr Automata Agent, utilizing the capabilities of OpenAI’s GPT-4 . 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)