Generative AI

To create a travel work of AI performance

Crewai is an open source framework for decorating agents Agents in the group. It allows you to create ai “Crew” where each agent has each role and purpose and works together to achieve complex tasks. In Crewai program, many cases of cooperation, share information, and link them for their actions for normal purposes. This makes it possible for the problem to be a problem with below activities and have special agents that deal with each part, as a group of people with a different profession.

In this lesson, we will be a case of using multilile AIs, which work together using Crewai using Crewai. Our example of Scentario will include the article summarizing three agents of different roles:

  • Research Servor – You read an article and issue the main points or facts.
  • Summanisizer Agent – takes main points and summarizes the story.
  • The author's agent – a summary review and formatting in the formal finalization (for example, to enter a subject or conclusion).

This functionality of partnerships partnerships how the team can work: One member collects information, one is synchronized, and the third culture supports the presentation. We will use this work with crewy work (agents, activities and group).

The use of the code

!pip install crewai crewai-tools transformers

First we include all the necessary packages of project in one transit. Crewai and Clewai packions provide additional frameworks and services agents Agents AIs orchestrangers AI, while transformers are ped to build the trained models before summarizing.

from crewai import Agent, Task, Crew, Process

Here we import important classes to Crewail program. The Agent Class allows you to explain AI with a particular role and behavior, work represents a unit of employment assigned to an agent, and the process sets the departure of death work (such as the same).

# Define the agents' roles, goals, and backstories to satisfy the model requirements.
research_agent = Agent(
    role="Research Assistant",
    goal="Extract the main points and important facts from the article.",
    backstory="You are a meticulous research assistant who carefully reads texts and extracts key points."
)
summarizer_agent = Agent(
    role="Summarizer",
    goal="Summarize the key points into a concise paragraph.",
    backstory="You are an expert summarizer who can condense information into a clear and brief summary."
)
writer_agent = Agent(
    role="Writer",
    goal="Organize the summary into a final report with a title and conclusion.",
    backstory="You are a creative writer with an eye for structure and clarity, ensuring the final output is polished."
)

It describes three special AIents using a crewail frame with the above code. Each agent prepared for a particular role, a goal, and a backstory, which taught them how to share in the full work: and the research assistant issues those points in a short paragraph, and the writer plans to exit the final report.

# Example: Create tasks for each agent
research_task = Task(
    description="Read the article and identify the main points and important facts.",
    expected_output="A list of bullet points summarizing the key information from the article.",
    agent=research_agent
)
summarization_task = Task(
    description="Take the above bullet points and summarize them into a concise paragraph that captures the article's essence.",
    expected_output="A brief paragraph summarizing the article.",
    agent=summarizer_agent
)
writing_task = Task(
    description="Review the summary paragraph and format it with a clear title and a concluding sentence.",
    expected_output="A structured summary of the article with a title and conclusion.",
    agent=writer_agent
)

The above descriptions of the above work provides specific responsibilities in appropriate agents. Research_Task instructs research assistant to issue key points from article, Sunfiilization_Task coordinates SUFFING

# Create a crew with a sequential process
crew = Crew(
    agents=[research_agent, summarizer_agent, writer_agent],
    tasks=[research_task, summarization_task, writing_task],
    process=Process.sequential,
    verbose=True
)


print("Agents defined successfully!")

Now, we do something that partnership between three are described and its compatible functions in successive work travel. Through the process.sequential, each work is done by one after another, and set the verbose = The Truth enables detailed process.

# Sample article text (as a multi-paragraph string)
article_text = """Artificial intelligence (AI) has made significant inroads in various sectors, transforming how we work and live.
One of the most notable impacts of AI is seen in healthcare, where machine learning algorithms assist doctors in diagnosing diseases faster and more accurately.


In the automotive industry, AI powers self-driving cars, analyzing traffic patterns in real-time to ensure passenger safety.
This technology also plays a crucial role in finance, with AI-driven algorithms detecting fraudulent transactions and enabling personalized banking services.


Education is another field being revolutionized by AI. Intelligent tutoring systems and personalized learning platforms adapt to individual student needs, making education more accessible and effective.


Despite these advancements, AI adoption also raises important questions.
Concerns about job displacement, ethical use of AI, and ensuring data privacy are at the forefront of public discourse as AI continues to evolve.


Overall, AI's growing influence across industries showcases its potential to tackle complex problems, but it also underscores the need for thoughtful integration to address the challenges that accompany these innovations.
"""
print("Article length (characters):", len(article_text))

In this section, it describes one category of paragraphs that is Article_text Employer about the influence of AI in various fields, such as health care, cars, finance and education. Print Print for the length of article, helps ensure that the text is properly listed for additional processes.

import re


def extract_key_points(text):
    paragraphs = [p.strip() for p in text.split("nn") if p.strip()]
    key_points = []
    for para in paragraphs:
        sentences = re.split(r'(?<=.)s+', para.strip())
        if not sentences:
            continue
        main_sentence = max(sentences, key=len)
        point = main_sentence.strip()
        if point and point[-1] not in ".!?":
            point += "."
        key_points.append(point)
    return key_points


# Use the function on the article_text
key_points = extract_key_points(article_text)
print("Research Assistant Agent - Key Points:n")
for i, point in enumerate(key_points, 1):
    print(f"{i}. {point}")

Here we describe the Delivery Work_kay_points processing the article text by separating categories and again to be in sentence. In each stage, selects a very long sentence as the key point (such as) and confirms that it completes appropriate punctuation. Finally, the individual point of key view as a numbered list, imitating the help of the research assistant.

from transformers import pipeline


# Initialize a summarization pipeline
summarizer_pipeline = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")


# Prepare the input for summarization by joining the key points
input_text = " ".join(key_points)
summary_output = summarizer_pipeline(input_text, max_length=100, min_length=30, do_sample=False)
summary_text = summary_output[0]['summary_text']
print("Summarizer Agent - Summary:n")
print(summary_text)

We start a short pipe of hugging on the face using “Springefer / Distilbart-CNN-12-6”. It also joined keywords issued from one thread and feeds on pipe, which produces a short summary. Finally, the printer is a summary from, is imitating outgoing from Sffialer Agent.

# Writer agent formatting
title = "AI's Impact Across Industries: A Summary"
conclusion = "In conclusion, while AI offers tremendous benefits across sectors, addressing its challenges is crucial for its responsible adoption."


# Combine title, summary, and conclusion
final_report = f"# {title}nn{summary_text}nn{conclusion}"
print("Writer Agent - Final Output:n")
print(final_report)

Finally, we imitate the author of the author agent with the final output format. Describing themes and ending and includes this with previously reproduced abbreviated abbreviations (stored in the fountain_thext) using the F line. The final report is formatted on Markdown, on the topic of the subject, followed by a summary and sentence. Printed to indicate a complete, formal summary.

In conclusion, this lesson showed how we can build a team of Ai Agents using crewai and work together at work. We have organized the problem (Summarizing the article) in the below work-managed activities and showed the flow of ending ends by exemplary results. CRWAI provides a variable framework to manage these partners including the associated organizations with Alent Multi, while we, as users, describe the roles and procedures that guide the agency.


Here is the Colab Notebook of the above project. Also, don't forget to follow Sane and join ours Telegraph station including LinkedIn Grtopic. Don't forget to join ours 80k + ml subreddit.

🚨 Recommended Recommended Research for Nexus


Asphazzaq is a Markteach Media Inc. According to a View Business and Developer, Asifi is committed to integrating a good social intelligence. His latest attempt is launched by the launch of the chemistrylife plan for an intelligence, MarktechPost, a devastating intimate practice of a machine learning and deep learning issues that are clearly and easily understood. The platform is adhering to more than two million moon visits, indicating its popularity between the audience.

🚨 Recommended Open-Source Ai Platform: 'Interstagent open source system with multiple sources to test the difficult AI' system (promoted)

Source link

Related Articles

Leave a Reply

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

Back to top button