Organizing your tasks effectively can significantly boost productivity and reduce stress. To help users achieve this, I created a To-Do List Generator app using Lyzr Automata SDK and OpenAI’s GPT-4 Turbo. This app takes your project name, subtasks, and any additional notes to generate a clear and actionable to-do list. Here’s a step-by-step guide to building this helpful app.
Setting Up the Environment
First, we need to import the required libraries and set up the environment, including the OpenAI API key.
import streamlit as st from lyzr_automata.ai_models.openai import OpenAIModel from lyzr_automata import Agent, Task 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"]
Creating the App Title and Introduction
We then set the title and provide a brief introduction to guide users on what information they need to input.
st.title("To-Do List Generator?") st.markdown("Welcome! Effortlessly organize your tasks with our intuitive to-do list generator. Simply provide the main project name and a few subtasks, and we'll create a clear and actionable list for you.") st.markdown("1) Mention your Task Name.") st.markdown("2) Mention your Subtasks.") st.markdown("3) Mention any additional notes or comments.") input = st.text_input("Please enter the above details:", placeholder="Type here")
Initializing the OpenAI Model
We initialize the OpenAI model with specific parameters for text completion. This model will generate the to-do list.
open_ai_text_completion_model = OpenAIModel( api_key=st.secrets["apikey"], parameters={ "model": "gpt-4-turbo-preview", "temperature": 0.2, "max_tokens": 1500, }, )
Defining the Generation Function
The generation function uses the OpenAI model to generate a comprehensive to-do list based on user input. The function defines the agent's role and prompt for the task.
def generation(input): generator_agent = Agent( role="Expert TO-DO LIST ORGANIZER", prompt_persona="Your task is to CREATE a COMPREHENSIVE to-do list based on the DETAILS provided by the user, including TASK NAME, SUBTASKS, and any additional NOTES.") prompt = """ [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 Generate Button
We add a button that triggers the generation of the to-do list when clicked.
if st.button("Generate!"): solution = generation(input) st.markdown(solution)
The To-Do List Generator app helps users create organized and actionable to-do lists by analyzing their task names, subtasks, and additional notes. Leveraging the power of Lyzr Automata SDK and OpenAI’s GPT-4 Turbo, this app provides a practical solution for efficient task management.
App link: https://to-dogenerator-lyzr.streamlit.app/
Source Code: https://github.com/isakshay007/To-do_Generator
Try building your own version of the To-Do List Generator app and experience the benefits of AI-driven task organization! If you have any questions or need further assistance, feel free to contact Lyzr.
Website: Lyzr.ai
Book a Demo: Book a Demo
Discord: Join our Discord community
Slack: Join our Slack channel
The above is the detailed content of Building a To-Do List Generator using Lyzr SDK. For more information, please follow other related articles on the PHP Chinese website!