DEV Community

Cover image for Simplify Your System Design Process with Lyzr Automata,OpenAI and Streamlit
harshit-lyzr
harshit-lyzr

Posted on

Simplify Your System Design Process with Lyzr Automata,OpenAI and Streamlit

Are you tired of spending hours outlining system architectures based on vague requirements?with Lyzr Automata you can build a powerful tool to streamline the system design process using the latest in AI and automation technologies.

System design is a critical phase in software development, yet it often involves complex decision-making and meticulous planning. To address this challenge, we've developed the System Designer using Lyzr Automata, a user-friendly app that transforms your requirements into actionable system designs.

Lyzr.ai

Check out the Lyzr.ai community on Discord - hang out with 307 other members and enjoy free voice and text chat.

favicon discord.com

Setting Up the Environment
Import necessary libraries:

pip install streamlit lyzr_automata openai
Enter fullscreen mode Exit fullscreen mode
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 dotenv import load_dotenv
import os

load_dotenv()
api = os.getenv("OPENAI_API_KEY")
Enter fullscreen mode Exit fullscreen mode

streamlit for creating the web interface.
lyzr_automata for interacting with agents and models.
PIL for handling images.
dotenv for loading environment variables.
os for accessing environment variables.
Load the OpenAI API key from a .env file.

Input and OpenAI model setup:

open_ai_text_completion_model = OpenAIModel(
    api_key=api,
    parameters={
        "model": "gpt-4-turbo-preview",
        "temperature": 0.2,
        "max_tokens": 1500,
    },
)

system = st.text_area("Enter Your Requirements: ")
tech = st.text_input("Enter Tech Stack: ",placeholder="Python,AWS,Docker")
Enter fullscreen mode Exit fullscreen mode

open_ai_text_completion_model = OpenAIModel(): Creates an instance of the OpenAIModel class, likely using the retrieved API key to configure access to GPT-4.
system = st.text_area(): Creates a text area for users to enter their system requirements.
tech = st.text_input(): Creates a text input field for users to enter their desired technology stack.

System Designer Function:

def system_designer(systems,tech_stack):
    analysis_agent = Agent(
        role="System Analysis expert",
        prompt_persona=f"You are a system Analyst.your task is to implement system based on requiremnts"
    )

    prompt=f"""You are an expert system analyst.
        Your task is to create system outline for {system}.The technology stack is {tech}.
        Follow below instruction:
        1\ you have to you have to craete Infrastructure and organizational proposed system.
        2\ Think how many data schema possible and generate data schema(design table for each class)
        Design seperate table for each class show as below:
        | Attribute | Type   | Description                     |
        | UserID | String    | Unique identifier for the user  |
        | Name     | String  | Name of the user                |
        3\ A function hierarchy diagram or web page map that graphically describes the program structure in given tech and language
        [!important] don't show nothing apart from above details
    """

    Analysis_task = Task(
        name="System Design Task",
        model=open_ai_text_completion_model,
        agent=analysis_agent,
        log_output=True,
        instructions=prompt
    )

    output = LinearSyncPipeline(
        name="System Design Pipeline",
        completion_message="System Created!!",
        tasks=[
            Analysis_task
        ],
    ).run()

    answer = output[0]['task_output']

    return answer
Enter fullscreen mode Exit fullscreen mode

def system_designer(systems, tech_stack):: Defines a function named system_designer that takes systems (likely a placeholder) and tech_stack as input.
Agent Definition:

analysis_agent = Agent(): Creates an instance of the Agent class, likely defining the persona of a "System Analysis expert".
prompt_persona=: Sets the prompt persona for the agent, instructing it to act as a system analyst based on requirements.

Prompt Definition:

prompt=: Defines a multi-line string containing the prompt that will be fed to the GPT-4 model through the Analysis_task. The prompt instructs the model to act as a system analyst and design a system based on user input and specified technology stack. It outlines specific deliverables including infrastructure, data schema, and function hierarchy diagrams.

Task Creation:

Analysis_task = Task(): Creates an instance of the Task class, likely defining a task named "System Design Task".
model=open_ai_text_completion_model: Assigns the previously loaded open_ai_text_completion_model to the task's model attribute.
agent=analysis_agent: Assigns the previously created analysis_agent to the task's agent attribute

Output:

if st.button("Design"):
    solution = system_designer(system,tech)
    st.markdown(solution)
Enter fullscreen mode Exit fullscreen mode

Create an "Design" button:
When clicked, call the system_designer function with the user's requirements
Display the formatted solution using Streamlit's markdown function.

Ready to experience the future of system design? Visit the Lyzr System Designer and witness the power of AI-driven automation firsthand. Say hello to faster, smarter, and more efficient system designs with Lyzr Automata.

try it now: https://lyzr-system-designer.streamlit.app/
For more information explore the website: Lyzr

Top comments (0)