Giter VIP home page Giter VIP logo

lyzr-automata's Introduction

version Discord YouTube Video

Lyzr Automata Banner

Lyzr Automata

1. Introduction

A low-code multi-agent automation framework.

Note : Framework was developed swiftly as an experiment, leading to initial imperfections. We're committed to enhancing its stability and structure in upcoming releases, ensuring a high-quality. We encourage contributions from everyone, aiming to advance the project further together.

Lyzr Automata - Autonomous Multi-Agent Framework for Process Automation

Lyzr Automata is a sophisticated multi-agent automation framework designed to keep things simple, with a focus on workflow efficiency and effectiveness. It enables the creation of multiple agents that are coupled with specific tasks. The agents and tasks can run independently and complete the provided instructions, thus entering a stable state.

Lyzr Automata

2. Installation

You can install our package simply by running

pip install lyzr-automata

3. Understanding fundamentals

To make things very simple, we have split our framework into fundamental building blocks.

  1. Models
  2. Agents
  3. Tools
  4. Tasks
  5. Pipelines

1. Models

Models are the core unit of the framework, which helps you connect different LLM or other AI Models to workflows.

Note: You can use our prebuilt model classes for OpenAI and Perplexity or extend our base AIModel class to provide support for your own models.

1.1 Let's look at an example to create a OpenAI Model with parameters

from lyzr_automata.ai_models.openai import OpenAIModel

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

1.2 Let's look at an example to create a Perplexity Model with parameters

from lyzr_automata.ai_models.perplexity import PerplexityModel

perplexity_model_text = PerplexityModel(
    api_key="YOUR_KEY_HERE",
    parameters={
        "model": "pplx-70b-online",
    },
)

2. Agents

Agents are directed specialists which have a set role, persona and memory, they are used to set direction and expertise for LLM models to increase its effectiveness.

2.1 Let's look at an example to create a simple linkedin content creator agent.

from lyzr_automata import Agent
    
linkedin_content_creator_agent = Agent(
        role="linkedin content creator",
        prompt_persona="you are an expert linkedin content creator who holds a Phd in molecular biology and are good at creating engaging linkedin posts."
    )

3. Tools

Tools are used by Agents to complete tasks. In general sense tools help agents to connect with external software components like API's or other functions.

Note: You can use our pre-built tools or tools from other providers like Llama Hub. Optionally you can also use our base Tool class to create your own custom tool by providing the function, input and output Pydantic models.

3.1 Let's look at an example to use prebuilt linkedin post tool

from lyzr_automata.tools.prebuilt_tools import linkedin_image_text_post_tool

linkedin_post_tool = linkedin_image_text_post_tool(
    owner="urn:li:person:<YOUR_ID_HERE>",
    token="YOUR_TOKEN_HERE",
)

3.2 Let's look at an example to use our tool class to create your own custom tool

3.2 Step 1. Create a function
     def multiply_numbers(a, b):
        """
        Multiply two numbers.
    
        Parameters:
        - a (int/float): The first number.
        - b (int/float): The second number.
    
        Returns:
        - int/float: The product of the two numbers.
        """
        return a * b
3.2 Step 2. Create Pydantic input model
#INPUT
from pydantic import BaseModel

class MultiplyInput(BaseModel):
	      a: float  # Assuming we want to allow floating point numbers
	      b: float
3.2 Step 3. Create Pydantic output model
#OUPUT
 class MultiplyOutput(BaseModel):
       result: float
3.3 Step 4. Create a tool instance
from lyzr_automata import Tool

    multiplication_tool = Tool(
		    name="Multiplication tool",
		    desc="multiplies two numbers",
		    function=multiply_numbers,
		    function_input=MultiplyInput,
		    function_output=MultiplyOutput,
	    )

4. Tasks

Tasks are our smallest functioning unit/node that helps you define what do you want to get done by the agent. It combines agent & tools.

4.1 Let's look at an example, on how you can define a task

from  lyzr_automata  import  Task
    
linkedin_content_writing_task = Task(

            name="linkedin content writing",
            agent=linkedin_content_writer_agent,
            output_type=OutputType.TEXT,
            input_type=InputType.TEXT,
            model=open_ai_model_text,
            instructions="Write a linkedin post on gene editing using CRISPR",
            log_output=True,
            enhance_prompt=False,
)

4.1 Let's look at an example, on how you can create a tool task

	linkedin_post_task  =  Task(
			name="upload post to linkedin",
			model=open_ai_model_text,
			tool=linkedin_post_tool,
			instructions="Post on Linkedin",
	)

5. Pipelines

Pipelines help us run the tasks in a directed orderly fashion. Currently we support linear async pipeline, with plans to release async DAG pipelines in next versions.

Let us look at a simple sync flow to create a pipeline for automated Linkedin post.

5.1 Flow

graph LR
A((T1. Write Content))  --> B((T2. Publish Content))
Loading

5.2 Code

from  lyzr_automata.pipelines.linear_sync_pipeline  import  LinearSyncPipeline

LinearSyncPipeline(
    name="Linkedin post automation pipeline",
    completion_message="post successfully posted ๐ŸŽ‰",
    tasks=[
        linkedin_content_writing_task,
        linkedin_post_task,
    ],
).run()

Example Colabs

  1. Linkedin Post Automation: https://colab.research.google.com/drive/1lVJrdjHVZjbwZSqwJEU_etHC4GM3ihD0?usp=sharing
  2. Blog Automation: https://colab.research.google.com/drive/1e1Qa2pRjbngvX683pXTFLyuqLK11g967?usp=sharing#scrollTo=TmBixqI_BULu

Join our community

Discord

Contact

For queries, reach us at [email protected]

lyzr-automata's People

Contributors

shreyas-lyzr avatar rasswanth-lyzr avatar sivasurend avatar harshit-lyzr avatar iamrash-7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.