First create agents
# Agent focusing on product features
features_agent = Agent(
name="FeaturesAgent",
instructions="Extract the key product features from the review."
)
# Agent focusing on pros & cons
pros_cons_agent = Agent(
name="ProsConsAgent",
instructions="List the pros and cons mentioned in the review."
)
# Agent focusing on sentiment analysis
sentiment_agent = Agent(
name="SentimentAgent",
instructions="Summarize the overall user sentiment from the review."
)
# Agent focusing on recommendation summary
recommend_agent = Agent(
name="RecommendAgent",
instructions="State whether you would recommend this product and why."
)
parallel_agents = [
features_agent,
pros_cons_agent,
sentiment_agent,
recommend_agent
]
# Meta-agent to combine outputs
meta_agent = Agent(
name="MetaAgent",
instructions="You are given multiple summaries labeled with Features, ProsCons, Sentiment, and a Recommendation."
" Combine them into a concise executive summary of the product review with a 1-5 star rating for each summary area."
)
starts, ends = [], []
async def run_agent(agent, review_text: str):
agent_name = agent.name
start = time.time()
starts.append((agent_name, start))
result = await Runner.run(agent, review_text)
end = time.time()
ends.append((agent_name, end))
return result
async def run_agents(review_text: str):
responses = await asyncio.gather(
*(run_agent(agent, review_text) for agent in parallel_agents)
)
labeled_summaries = [
f"### {resp.last_agent.name}\n{resp.final_output}"
for resp in responses
]
collected_summaries = "\n".join(labeled_summaries)
final_summary = await run_agent(meta_agent, collected_summaries)
print('Final summary:', final_summary.final_output)
return
review_text = """
I recently upgraded to the AuroraSound X2 wireless noise-cancelling headphones, and after two weeks of daily use I have quite a bit to share. First off, the design feels premium without being flashy: the matte‐finish ear cups are softly padded and rotate smoothly for storage, while the headband’s memory‐foam cushion barely presses on my temples even after marathon work calls. Connectivity is seamless—pairing with my laptop and phone took under five seconds each time, and the Bluetooth 5.2 link held rock-solid through walls and down the hallway.
The noise-cancelling performance is genuinely impressive. In a busy café with music and chatter swirling around, flipping on ANC immediately quiets low-level ambient hums, and it even attenuates sudden noises—like the barista’s milk frother—without sounding distorted. The “Transparency” mode is equally well‐tuned: voices come through clearly, but the world outside isn’t overwhelmingly loud. Audio quality in standard mode is rich and balanced, with tight bass, clear mids, and a hint of sparkle in the highs. There’s also a dedicated EQ app, where you can toggle between “Podcast,” “Bass Boost,” and “Concert Hall” presets or craft your own curve.
On the control front, intuitive touch panels let you play/pause, skip tracks, and adjust volume with a simple swipe or tap. One neat trick: holding down on the right ear cup invokes your phone’s voice assistant. Battery life lives up to the hype, too—over 30 hours with ANC on, and the quick‐charge feature delivers 2 hours of playtime from just a 10-minute top-up.
That said, it isn’t perfect. For one, the carrying case is a bit bulky, so it doesn’t slip easily into a slim bag. And while the touch interface is mostly reliable, I occasionally trigger a pause when trying to adjust the cup position. The headphones also come in only two colorways—black or white—which feels limiting given the premium price point.
"""
asyncio.get_event_loop().run_until_complete(run_agents(review_text))
def plot_timeline(starts, ends):
# Plot the timeline of the agents
# normalize times to zero
base = min(t for _, t in starts)
labels = [n for n, _ in starts]
start_offsets = [t - base for _, t in starts]
lengths = [ends[i][1] - starts[i][1] for i in range(len(starts))]
plt.figure(figsize=(8, 3))
plt.barh(labels, lengths, left=start_offsets)
plt.xlabel("Seconds since kickoff")
plt.title("Agent Execution Timeline")
plt.show()
plot_timeline(starts, ends)
Final summary: ### Executive Summary The AuroraSound X2 wireless noise-cancelling headphones offer a blend of premium design and advanced features. The headphones boast a matte-finish with comfortable, memory-foam padding, making them ideal for extended use. With Bluetooth 5.2, they provide seamless connectivity and stable communication. The noise-cancelling capabilities effectively reduce ambient noise and feature a well-tuned Transparency mode for essential sound transmission. **Audio Quality** is a highlight, delivering rich, balanced sound with customizable EQ presets including “Podcast,” “Bass Boost,” and “Concert Hall.” Intuitive touch controls allow for easy navigation, though some users report occasional misfires. The extended battery life offers over 30 hours with ANC on, with a quick-charge option for convenience. **Minor Limitations** include a bulky carrying case, occasional touch control issues, and limited color choices (black or white). Despite these, the overall sentiment is highly positive, with users particularly appreciating the headphones' design, connectivity, and performance. The product is recommended for those seeking high-quality audio experiences with effective noise-cancelling features. ### Star Ratings - **Features**: ★★★★☆ - **Pros & Cons**: ★★★★☆ - **Sentiment**: ★★★★★ - **Recommendation**: ★★★★★ Overall, the AuroraSound X2 headphones are a compelling choice, offering excellent value despite minor drawbacks.
