Rajan Sharma
12/13/2024, 3:53 PMRajan Sharma
12/13/2024, 3:54 PMRajan Sharma
12/13/2024, 3:55 PMNate
12/13/2024, 3:55 PMRajan Sharma
12/13/2024, 3:55 PMimport controlflow as cf
from typing import List, Dict
text_analyst = cf.Agent(
name="Text Analyst",
description="An AI agent specialized in analyzing and processing text",
instructions="""
You are an expert at analyzing text and extracting key information.
Follow these guidelines:
1. Be thorough in your analysis
2. Focus on key themes and patterns
3. Provide clear, structured output
"""
)
theme_extractor = cf.Agent(
name="Theme Extractor",
description="An AI agent specialized in extracting key themes from text",
instructions="""
You are an expert at analyzing text and extracting key information.
Follow these guidelines:
1. Be thorough in your analysis
2. Focus on key themes and patterns
3. Provide clear, structured output
"""
)
if __name__ == "__main__":
sample_text = """
Artificial intelligence has transformed many industries,
from healthcare to transportation. As these technologies evolve,
we must consider both their benefits and potential risks.
"""
theme_task = cf.Task(
"Extract key themes from the input text",
context={"input_text": sample_text},
result_type=List[str],
agents=[theme_extractor, text_analyst],
)
analysis_task = cf.Task(
"Generate a detailed analysis based on the themes",
result_type=Dict,
agents=[theme_extractor, text_analyst],
)
@cf.flow()
def my_flow():
cf.run_tasks([theme_task, analysis_task])
my_flow()
Rajan Sharma
12/13/2024, 3:55 PM