동적 데이터 기반 보고서를 자동으로 작성
저는 LLM을 통한 에이전트 흐름을 정말 좋아해요. 단순히 더 많은 것을 가능하게 할 뿐만 아니라, 고급 Text2Cypher 구현은 물론이고 다양한 의미 계층 구현의 문도 열어주거든요. 정말 강력하고 다재다능한 접근 방식이죠.
이번 블로그 포스팅에서는 또 다른 종류의 보고서 생성 에이전트를 구현해 보려고 해요. 일반적인 Q&A 사용 사례 대신, 특정 위치의 특정 산업에 대한 자세한 보고서를 생성하는 에이전트죠. 구현에는 CrewAI를 활용할 거예요. CrewAI는 개발자가 AI 에이전트를 쉽게 조정할 수 있도록 지원하는 플랫폼이에요.

이 시스템은 세 명의 에이전트가 조화롭게 협력해서 포괄적인 비즈니스 보고서를 제공하도록 조정되어 있어요.
- : 특정 도시의 조직에 대한 산업별 데이터 수집 및 분석을 전문으로 하며, 회사 수, 공기업, 총 수익 및 최고 성과 조직에 대한 통찰력을 제공해요.
- : 관련 기업의 최신 뉴스를 추출하고 요약하는 데 중점을 두고 있으며, 동향, 시장 동향, 정서 분석에 대한 스냅샷을 제공하죠.
- : 연구 및 뉴스 통찰력을 체계적이고 실행 가능한 마크다운 보고서로 종합하여 지원되지 않는 정보를 추가하지 않고도 명확성과 정확성을 보장합니다.
이러한 에이전트들은 함께 특정 위치에 맞는 통찰력 있는 업계 보고서를 생성하기 위한 흐름을 형성하는 거죠.
코드는 다음에서 확인할 수 있어요: .
데이터세트
우리는 조직, 개인에 대한 자세한 정보는 물론 일부 조직의 최신 뉴스까지 포함하는 Neo4j 데모 서버의 데이터베이스를 사용할 거예요. 이 데이터를 가져오기 위해 Diffbot API를 사용할 거고요.

이 데이터 세트는 투자자, 이사회 구성원 및 관련 측면에 중점을 두고 있어서 업계 보고서 생성을 시연하기에 정말 좋은 리소스에요.
# Neo4j connection setup
URI = "neo4j+s://demo.neo4jlabs.com"
AUTH = ("companies", "companies")
driver = GraphDatabase.driver(URI, auth=AUTH)
다음으로, 이 블로그 게시물 전체에서 GPT-4o를 사용할 거니까 OpenAI 키를 정의해야 해요.
# Set your OpenAI API key
os.environ["OPENAI_API_KEY"] = getpass.getpass("OpenAI key: ")
llm = LLM(model='gpt-4o', temperature=0)
Knowledge Graph 기반 도구
에이전트/LLM이 데이터베이스에서 관련 정보를 검색할 수 있도록 하는 도구를 구현하는 것부터 시작해볼게요. 첫 번째 도구는 특정 도시의 특정 업계에 속한 회사에 대한 주요 통계를 가져오는 데 중점을 둬요.
industry_options = ["Software Companies", "Professional Service Companies", "Enterprise Software Companies", "Manufacturing Companies", "Software As A Service Companies", "Computer Hardware Companies", "Media And Information Companies", "Financial Services Companies", "Artificial Intelligence Companies", "Advertising Companies"]
class GetCityInfoInput(BaseModel):
"""Input schema for MyCustomTool."""
city: str = Field(..., description="City name")
industry: str = Field(..., description=f"Industry name, available options are: {industry_options}")
class GetCityInfo(BaseTool):
name: str = "Get information about a specific city"
description: str = "You can use this tools when you want to find information about specific industry within a city."
args_schema: Type[BaseModel] = GetCityInfoInput
def _run(self, city: str, industry: str) -> str:
data, _, _ = driver.execute_query("""MATCH (c:City)<-[:IN_CITY]-(o:Organization)-[:HAS_CATEGORY]->(i:IndustryCategory)
WHERE c.name = $city AND i.name = $industry
WITH o
ORDER BY o.nbrEmployees DESC
RETURN count(o) AS organizationCount,
sum(CASE WHEN o.isPublic THEN 1 ELSE 0 END) AS publicCompanies,
sum(o.revenue) AS combinedRevenue,
collect(CASE WHEN o.nbrEmployees IS NOT NULL THEN o END)[..5] AS topFiveOrganizations""", city=city, industry=industry)
return [el.data() for el in data]
The GetCityInfo 도구는 특정 도시 내 특정 산업 분야의 회사에 대한 주요 통계를 검색해요. 전체 조직 수, 공기업 수, 합산 매출액, 직원 수 기준 상위 5개 조직 등의 정보를 제공하죠. 이 도구를 확장할 수도 있지만, 일단은 간단하게 유지했어요.
두 번째 도구를 사용해서 특정 회사에 대한 최신 정보를 가져와 볼게요.
class GetNews(BaseTool):
name: str = "Get the latest news for a specific company"
description: str = "You can use this tool when you want to find the latest news about specific company"
def _run(self, company: str) -> str:
data, _, _ = driver.execute_query("""MATCH (c:Chunk)<-[:HAS_CHUNK]-(a:Article)-[:MENTIONS]->(o:Organization)
WHERE o.name = $company AND a.date IS NOT NULL
WITH c, a
ORDER BY a.date DESC
LIMIT 5
RETURN a.title AS title, a.date AS date, a.sentiment AS sentiment, collect(c.text) AS chunks""", company=company)
return [el.data() for el in data]
GetNews 도구는 특정 회사에 대한 최신 뉴스를 검색해요. 기사 제목, 발행일, 감정 분석, 기사의 주요 발췌 내용 등의 세부 정보를 제공하죠. 이 도구는 특정 조직과 관련된 최근 개발 및 시장 동향에 대한 최신 정보를 유지하는 데 도움이 되므로 보다 자세한 요약을 생성할 수 있어요.
자치령 대표
언급한 대로 우리는 세 개의 에이전트를 구현할 거예요. CrewAI는 플랫폼이 나머지를 처리하므로 최소한의 Prompt Engineering이 필요해요.
다음과 같이 에이전트를 구현합니다.
# Define Agents
class ReportAgents:
def __init__(self):
self.researcher = Agent(
role='Data Researcher',
goal='Gather comprehensive information about specific companies that are in relevant cities and industries',
backstory="""You are an expert data researcher with deep knowledge of
business ecosystems and city demographics. You excel at analyzing
complex data relationships.""",
verbose=True,
allow_delegation=False,
tools=[GetCityInfo()],
llm=llm
)
self.news_analyst = Agent(
role='News Analyst',
goal='Find and analyze recent news about relevant companies in the specified industry and city',
backstory="""You are a seasoned news analyst with expertise in
business journalism and market research. You can identify key trends
and developments from news articles.""",
verbose=True,
allow_delegation=False,
tools=[GetNews()],
llm=llm
)
self.report_writer = Agent(
role='Report Writer',
goal='Create comprehensive, well-structured reports combining the provided research and news analysis. Do not include any information that isnt explicitly provided.',
backstory="""You are a professional report writer with experience in
business intelligence and market analysis. You excel at synthesizing
information into clear, actionable insights. Do not include any information that isn't explicitly provided.""",
verbose=True,
allow_delegation=False,
llm=llm
)
CrewAI에서 에이전트는 기능을 향상시키는 선택적 도구를 사용하여 역할, 목표 및 배경을 지정하여 정의돼요. 이 설정에서는 세 가지 에이전트가 구현되는데요. GetCityInfo 도구를 사용하여 특정 도시 및 산업 분야의 회사에 대한 자세한 정보를 수집하는 데이터 연구원, GetNews 도구를 사용하여 관련 회사에 대한 최근 뉴스를 분석하는 뉴스 분석가, 외부 도구에 의존하지 않고 수집된 정보와 뉴스를 구조화되고 실행 가능한 보고서로 종합하는 보고서 작성기 이렇게 구성돼요. 역할과 목표가 명확하게 정의되어 있어 에이전트 간의 효과적인 협업이 보장되죠.
작업
에이전트를 정의하는 것 외에도 에이전트가 수행할 Task를 간략하게 설명해야 해요. 이 경우 세 가지 고유한 Task를 정의하겠어요.
# Define Tasks
city_research_task = Task(
description=f"""Research and analyze {city_name} and its business ecosystem in {industry_name} industry:
1. Get city summary and key information
2. Find organizations in the specified industry
3. Analyze business relationships and economic indicators""",
agent=agents.researcher,
expected_output="Basic statistics about the companies in the given city and industry as well as top performers"
)
news_analysis_task = Task(
description=f"""Analyze recent news about the companies provided by the city researcher""",
agent=agents.news_analyst,
expected_output="Summarization of the latest news for the company and how it might affect the market",
context=[city_research_task]
)
report_writing_task = Task(
description=f"""Create a detailed markdown report about the
results you got from city research and news analysis tasks.
Do not include any information that isn't provided""",
agent=agents.report_writer,
expected_output="Markdown summary",
context=[city_research_task, news_analysis_task]
)
Task는 에이전트의 역량에 맞춰 조정되는데요. `city_research_task`는 특정 도시와 산업의 비즈니스 생태계를 분석하고, 주요 통계를 수집하고, 우수 기관을 발굴하는 업무로 Data Researcher가 담당해요. `news_analysis_task`는 뉴스 분석가가 수행한 도시 조사 결과를 사용하여 이러한 회사와 관련된 최근 개발 상황을 조사하고 동향과 시장 영향을 요약하죠. `report_writing_task`는 이러한 결과를 보고서 작성자가 완성하는 포괄적인 마크다운 보고서로 종합하는 Task랍니다.
마지막으로, 이 모든 것을 합쳐볼까요?
# Create and run the crew
crew = Crew(
agents=[agents.researcher, agents.news_analyst, agents.report_writer],
tasks=[city_research_task, news_analysis_task, report_writing_task],
verbose=True,
process=Process.sequential,
)
테스트해 봐요!
city = "Seattle"
industry = "Hardware Companies"
report = generate_report(city, industry)
print(report)
에이전트의 중간 단계는 너무 상세해서 여기에 다 담을 수는 없지만, 프로세스는 특정 산업에 대한 주요 통계를 수집하고 관련 기업을 식별하는 것부터 시작해서 해당 기업에 대한 최신 뉴스를 검색하는 것으로 진행돼요.
결과:
# Seattle Computer Hardware Industry Report
## Overview
The Computer Hardware Companies industry in Seattle comprises 24 organizations, including 4 public companies. The combined revenue of these companies is approximately $229.14 billion. This report highlights the top performers in this industry and recent news developments affecting them.
## Top Performers
1. **Microsoft Corporation**
- **Revenue**: $198.27 billion
- **Employees**: 221,000
- **Status**: Public Company
- **Mission**: To empower every person and organization on the planet to achieve more.
2. **Nvidia Corporation**
- **Revenue**: $26.97 billion
- **Employees**: 26,196
- **Status**: Public Company
- **Formerly Known As**: Mellanox Technologies and Cumulus Networks
3. **F5 Networks**
- **Revenue**: $2.695 billion
- **Employees**: 7,089
- **Status**: Public Company
- **Focus**: Multi-cloud cybersecurity and application delivery
4. **Quest Software**
- **Revenue**: $857.415 million
- **Employees**: 4,055
- **Status**: Public Company
- **Base**: California
5. **SonicWall**
- **Revenue**: $310 million
- **Employees**: 1,600
- **Status**: Private Company
- **Focus**: Cybersecurity
These companies significantly contribute to Seattle's economic landscape, driving growth and innovation in the hardware industry.
## Recent News and Developments
- **Microsoft Corporation**: Faces legal challenges with its Activision Blizzard acquisition, which could impact its gaming market strategy.
- **Nvidia Corporation**: Experiences strong demand for GPUs in China, highlighting its critical role in AI advancements and potentially boosting its market position.
- **F5 Networks**: Gains recognition for its cybersecurity solutions, enhancing its industry reputation.
- **Quest Software**: Launches a new data intelligence platform aimed at improving data accessibility and AI model development.
- **SonicWall**: Undergoes leadership changes and releases a threat report, emphasizing its focus on cybersecurity growth and challenges.
These developments are poised to influence market dynamics, investor perceptions, and competitive strategies within the industry.
데모 데이터 세트는 오래되었어요. 뉴스는 정기적으로 가져오지 않으니 참고해주세요!
요약
Agentic Flow, Neo4j, 그리고 CrewAI를 사용해서 자동화된 보고서 생성 파이프라인을 구축하면, LLM이 단순한 Q&A 상호작용을 훨씬 뛰어넘을 수 있다는 걸 알 수 있어요. 에이전트 그룹에 특정 작업을 할당하고, 적절한 도구를 제공하면 관련 데이터를 가져와 처리하고, 보기 좋게 구조화된 통찰력을 만들어내는 역동적인 워크플로우를 만들 수 있죠.
이 접근 방식을 통해 에이전트들은 협력해서 특정 도시 산업의 주요 통계를 파악하고, 최신 뉴스를 수집해서 깔끔한 보고서로 종합할 수 있어요. LLM이 창의적인 다단계 프로세스에 투입되어 자동화된 비즈니스 인텔리전스나 데이터 기반 콘텐츠 생성 같은 정교한 사용 사례를 가능하게 한다는 걸 보여주는 거죠.
코드는 에서 확인할 수 있습니다.
- CrewAI
에이치시스템즈의 LogTree는 Neo4j 기반 GraphRAG 플랫폼으로, 데이터를 자동으로 지식그래프화하고 자연어 질의로 즉시 답을 제공합니다.
'Agent AI' 카테고리의 다른 글
| Neo4j로 GraphAcademy 교육 챗봇 구축하기 (1) | 2026.04.05 |
|---|---|
| 바운더리 그래프: 그래프 렌즈로 IPL 탐험하기 (1) | 2026.04.05 |
| RAG에서 Reqs로: 그래프와 챗봇으로 ASVS에 쉽게 접근하기 (0) | 2026.04.04 |
| Google MCP Toolbox와 Neo4j Knowledge Graph로 AI 에이전트 구축하기 (1) | 2026.04.04 |
| 실제 프로덕션에서 효과적인 AI 에이전트 활용 사례 연구 (0) | 2026.04.03 |