Collaborative AI Workflow: Using Ceylon Framework for Streamlined Article Creation

Dewmal
CeylonAI
Published in
2 min readJul 21, 2024

Source code

  1. Colab — https://colab.research.google.com/drive/1C-E9BN992k5sZYeJWnVrsWA5_ryaaT8m?usp=sharing

Step 1: Import Required Libraries

First, we need to import the necessary libraries:

import pickle
from langchain_community.chat_models import ChatOllama
from ceylon.llm.types import Job, Step, AgentDefinition
from ceylon.llm.unit import LLMAgent, ChiefAgent
from ceylon.tools.search_tool import SearchTool

These imports provide the core components of the Ceylon Framework and additional tools we’ll use.

Step 2: Set Up the Language Model

We initialize the language model that our agents will use:

llm_lib = ChatOllama(model="llama3:instruct")

This creates an instance of the ChatOllama model, which will be used by our agents for natural language processing tasks.

Step 3: Create the Chief Agent

The Chief Agent orchestrates the workflow:

chief = ChiefAgent()

This agent will manage the execution of our job and coordinate between other agents.

Step 4: Define Specialized Agents

We create three specialized agents: writer, researcher, and proof_writer. Each agent is initialized with an AgentDefinition that specifies its role, responsibilities, skills, and other parameters. Here’s an example for the writer agent:

writer = LLMAgent(
AgentDefinition(
name="writer",
role="AI Content Writer",
role_description="Transform complex AI research into engaging, accessible content for a wide audience.",
responsibilities=[
"Write 800+ word articles on AI topics",
"Simplify technical concepts with metaphors",
"Create narrative-driven content",
"Ensure scientific accuracy and readability",
],
# ... other parameters ...
),
llm=llm_lib
)

Similarly, we define the researcher and proof_writer agents with their specific roles and capabilities.

Step 5: Define the Job

We create a Job object that specifies the workflow:

job = Job(
title="write_article",
work_order=[
Step(owner="researcher", dependencies=[]),
Step(owner="writer", dependencies=["researcher"]),
Step(owner="proof_writer", dependencies=["writer"]),
],
input={
"title": "How to use AI for Machine Learning",
"tone": "informal",
"style": "creative"
}
)

This job defines the sequence of steps, dependencies between agents, and input parameters for the task.

Step 6: Execute the Job

Finally, we run the job using the Chief Agent:

res = chief.run_admin(pickle.dumps(job), [
writer,
researcher,
proof_writer
])
print("Response:", res)

The run_admin method takes the serialized job and a list of agents as arguments. It executes the job and returns the result.

Conclusion

This Ceylon Framework allows for the creation of specialized AI agents that can collaborate on complex tasks. In this example, we’ve set up a system to research, write, and edit an article on AI in machine learning. The framework’s modular design enables easy customization and expansion for various AI-driven tasks.

--

--