DEV Community

Akshay Keerthi
Akshay Keerthi

Posted on

Building a Commute Navigator using Lyzr SDK

Navigating through the hustle and bustle of city life can be daunting, especially when it comes to finding the quickest and most affordable commuting options. Introducing Commute Navigator, your ultimate AI-powered assistant designed to simplify your daily travel. Powered by the advanced capabilities of Lyzr Automata, Commute Navigator takes the guesswork out of commuting by providing you with optimized routes and cost-effective options.

Image description

Commute Navigator is a user-friendly web application that helps you find the best commuting routes from your starting point to your destination. Whether you’re looking for the shortest travel time, the most accessible routes, or the cheapest options, Commute Navigator has got you covered. Just input your starting location and final destination, and let the app do the rest.

At the core of Commute Navigator is Lyzr SDK, a robust toolkit that leverages state-of-the-art AI models to deliver accurate and efficient commuting solutions. By utilizing Lyzr SDK, Commute Navigator can analyze a multitude of commuting options, evaluate their efficiency, and present the best possible routes along with associated costs.

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("Commute Navigator")
st.markdown("Welcome to Commute Navigator! Let us help you find the quickest, easiest, and most affordable options to get to your destination.")
input = st.text_input("Please enter your start and final destination:",placeholder=f"""Type here""")
Enter fullscreen mode Exit fullscreen mode

This snippet sets up the Streamlit interface for Commute Navigator. We import the necessary libraries, configure the OpenAI API key, and load the app’s logo. The Streamlit interface is designed to be intuitive, allowing users to input their starting location and destination easily.

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. We specify parameters such as the model version, temperature, and maximum tokens to optimize the text generation process.

def generation(input):
    generator_agent = Agent(
        role="Expert COMMUTE NAVIGATOR",
        prompt_persona=f"Your task is to IDENTIFY and DISPLAY the SHORTEST and MOST ACCESSIBLE commuting routes for users, from their PROVIDED STARTING POINT to their FINAL DESTINATION. You MUST also INCLUDE the PRICES associated with each commuting option.")
    prompt = f"""
    You are an Expert COMMUTE NAVIGATOR. Your task is to IDENTIFY and DISPLAY the SHORTEST and MOST ACCESSIBLE commuting routes for users, from their PROVIDED STARTING POINT to their FINAL DESTINATION. You MUST also INCLUDE the PRICES associated with each commuting option."""
[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
Enter fullscreen mode Exit fullscreen mode

This function, generation, is the core of our app. It takes user input, creates an AI agent persona, defines task instructions, and executes the task using Lyzr SDK. The AI agent identifies the best commuting routes, evaluates their efficiency, calculates costs, and organizes the information in a user-friendly format.

Commute Navigator is here to revolutionize the way you commute. By leveraging the advanced AI capabilities of Lyzr SDK, we provide you with the quickest, easiest, and most affordable routes to your destination. Say goodbye to the stress of planning your commute and hello to seamless travel experiences.

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

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

The Commute Navigator 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)