Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

write-a-book-with-flows → Lyzr ADK

Translation: CrewAI Flows → Lyzr ADK
Source: https://github.com/crewAIInc/crewAI-examples/tree/main/flows/write_a_book_with_flows
Generated by: Framework Translator Agent v2.0.0


What this does

An AI book-writer pipeline that:

  1. Researches a topic and generates a structured chapter outline
  2. Writes all chapters in parallel (~3 000 words each, Markdown)
  3. Joins and saves the complete book to a .md file on disk

The original CrewAI code used two Crews orchestrated by a Flow; this translation uses four Lyzr ADK agents orchestrated by a plain Python async function that preserves identical parallel chapter-writing behaviour.


Agent Map

Lyzr Agent Source CrewAI Agent Crew
outline_researcher researcher OutlineCrew
book_outliner outliner OutlineCrew
chapter_researcher researcher WriteBookChapterCrew
chapter_writer writer WriteBookChapterCrew

Setup

1. Install dependencies

pip install lyzr-adk requests pydantic

2. Set environment variables

export LYZR_API_KEY="sk-..."        # from https://studio.lyzr.ai → Settings → API Keys
export OPENAI_API_KEY="sk-..."      # required by openai/gpt-4o inside Lyzr
export SERPER_API_KEY="..."         # from https://serper.dev — used by web_search tool

3. Run

python3 write_a_book_lyzr_adk.py

The script will:

  • Create 4 agents in your Lyzr Studio workspace (one-time)
  • Run the book generation flow
  • Save the finished book as The_Current_State_of_AI_in_July_2025.md in the current directory

Translation Notes

# Source (CrewAI) Target (Lyzr ADK) Fidelity
1 Flow[BookState] with @start/@listen Plain async Python orchestration function Adapted
2 crewai_tools.SerperDevTool web_search() function calling Serper.dev REST API Adapted
3 output_pydantic=BookOutline / output_pydantic=Chapter (CrewAI task) response_model=BookOutline / response_model=Chapter (Lyzr agent.run()) Direct
4 @persist durable Flow state Not supported — crash = restart from Stage 1 Lossy
5 asyncio.gather() parallel chapters asyncio.gather() preserved identically Direct
6 Process.sequential inside each Crew Sequential agent.run() calls within each stage Direct
7 crew.kickoff(inputs={...}) agent.run(prompt) Adapted
8 YAML agents.yaml / tasks.yaml configs Inline studio.create_agent(role=, goal=, instructions=) Adapted

Architecture

[main()]
   │
   ▼
[create_all_agents()]   ← POST /v3/agents/ × 4  (runs once at startup)
   │
   ▼
[generate_book_outline()]          ← Stage 1 (sequential)
   │  outline_researcher.run()  →  research findings
   │  book_outliner.run()       →  BookOutline (JSON → Pydantic)
   │
   ▼
[write_chapters()]                 ← Stage 2 (parallel via asyncio.gather)
   │  for each ChapterOutline:
   │    chapter_researcher.run()  →  research findings
   │    chapter_writer.run()      →  Chapter (Markdown)
   │
   ▼
[join_and_save_chapter()]          ← Stage 3 (sequential)
      Combine all chapters → write ./{Book_Title}.md

Files

File Description
write_a_book_lyzr_adk.py Main translated script — run this
README.md This file

About

CrewAI book writer translated to Lyzr ADK by Framework Translator Agent v2.0.0

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages