File size: 1,698 Bytes
7516245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from langgraph.graph import StateGraph, START, END
from state import NewsState, ArticleScraperState, BlogState
from nodes import (
    search_ai_news, 
    parse_news_items, 
    scrape_article_content,
    orchestrator,
    llm_call,
    synthesizer,
    assign_workers
)

def create_news_search_workflow():
    """Create a workflow for searching and parsing AI news"""
    workflow = StateGraph(NewsState)
    
    # Add nodes
    workflow.add_node("search_ai_news", search_ai_news)
    workflow.add_node("parse_news_items", parse_news_items)
    
    # Add edges
    workflow.add_edge(START, "search_ai_news")
    workflow.add_edge("search_ai_news", "parse_news_items")
    workflow.add_edge("parse_news_items", END)
    
    return workflow.compile()

def create_article_scraper_workflow():
    """Create a workflow for scraping article content"""
    workflow = StateGraph(ArticleScraperState)
    
    # Add node
    workflow.add_node("scrape_article", scrape_article_content)
    
    # Add edges
    workflow.add_edge(START, "scrape_article")
    workflow.add_edge("scrape_article", END)
    
    return workflow.compile()

def create_blog_generator_workflow():
    """Create a workflow for generating the blog"""
    workflow = StateGraph(BlogState)
    
    # Add nodes
    workflow.add_node("orchestrator", orchestrator)
    workflow.add_node("llm_call", llm_call)
    workflow.add_node("synthesizer", synthesizer)
    
    # Add edges
    workflow.add_edge(START, "orchestrator")
    workflow.add_conditional_edges("orchestrator", assign_workers, ["llm_call"])
    workflow.add_edge("llm_call", "synthesizer")
    workflow.add_edge("synthesizer", END)
    
    return workflow.compile()