Building a First Aid Assistant with Lyzr SDK

Building a First Aid Assistant with Lyzr SDK

In today’s fast-paced world, having access to immediate medical assistance can be crucial in emergency situations. With advancements in AI and development frameworks like Streamlit and Lyzr SDK, building tools to aid in such scenarios has become more accessible than ever.

In this post, we’ll walk through the development of a First Aid Assistant application using Streamlit and Lyzr SDK. This app aims to provide step-by-step first aid instructions tailored to the specifics of an emergency, based on user-provided details such as the nature of the injury, its location, and severity.

To harness the power of AI in our First Aid Assistant, we leverage Lyzr SDK for seamless integration with the OpenAI GPT model. Lyzr provides a range of AI models and tools tailored for various applications, making it an ideal choice for our project.

By utilizing Lyzr’s Agent and Task components, we can easily orchestrate the process of generating customized first aid instructions based on the user’s input. The OpenAI GPT model, integrated via Lyzr, enables us to understand and respond intelligently to diverse emergency scenarios.

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!

Setting Up the Environment: To start, let’s ensure we have all the necessary libraries installed. We’re using Streamlit for the web interface, Lyzr Automata for task automation, and PIL for image processing.

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
# Set the OpenAI API key
os.environ[“OPENAI_API_KEY”] = st.secrets[“apikey”]

Designing the User Interface: Now, let’s create a visually appealing interface using Streamlit. We’ll include an input field for users to enter their details and display the Lyzr logo.

image = Image.open(“./logo/lyzr-logo.png”)
st.image(image, width=150)

# App title and introduction
st.title(“First Aid Assistant🏥”)
st.markdown(“Built using Lyzr SDK🚀”)

input = st.text_input(“Please briefly describe the nature of the injury, its location, and its severity so we can provide the appropriate assistance.”,placeholder=f”””Type here”””)

Generating Responses with OpenAI: Let’s dive into the heart of our application — the generation of responses using OpenAI’s language model.

Here’s how we prompt the model with instructions and user input to craft personalized instructions:

open_ai_text_completion_model = OpenAIModel(
api_key=st.secrets[“apikey”],
parameters={
“model”: “gpt-4-turbo-preview”,
“temperature”: 0.2,
“max_tokens”: 1500,
},
)
def first_aid_generation(input):
generator_agent = Agent(
role=” FIRST AID CONSULTANT expert”,
prompt_persona=f”your task is to PROVIDE step-by-step INSTRUCTIONS in response to user-provided details such as the NATURE OF EMERGENCY, LOCATION OF INJURY, and SEVERITY. You MUST also offer FOLLOW-UP ADVICE.”
)

prompt = f”””
You are an Expert FIRST AID CONSULTANT. Your task is to PROVIDE step-by-step INSTRUCTIONS in response to user-provided details such as the NATURE OF EMERGENCY, LOCATION OF INJURY, and SEVERITY. You MUST also offer FOLLOW-UP ADVICE. Here’s how you should approach it:[]
[prompts here]
“””

generator_agent_task = Task(
name=”First Aid 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

User Interaction and Output: Once the user inputs their details, they can generate a personalized first aid intructions with the click of a button.

Here’s how we handle user interaction and display the responses:

if st.button(“Generate!”):
solution = pitch_generation(input)
st.markdown(solution)

In this post, we’ve explored the development of a First Aid Assistant application using Streamlit and Lyzr SDK. By combining the simplicity of Streamlit for UI development with the AI capabilities of Lyzr SDK, we’ve created a tool that can potentially save lives by providing timely and tailored first aid instructions.

As technology continues to advance, the possibilities for leveraging AI in healthcare and emergency response are endless. Tools like the First Aid Assistant demonstrate how AI can be harnessed to augment human capabilities and provide assistance in critical situations.

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

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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *