AhsanRazi commited on
Commit
9040e87
·
verified ·
1 Parent(s): 91e8649

Update pages/General.py

Browse files
Files changed (1) hide show
  1. pages/General.py +69 -13
pages/General.py CHANGED
@@ -15,11 +15,18 @@ load_dotenv(override=True)
15
  gemini_api_key = os.getenv("GEMINI_API_KEY")
16
 
17
 
 
18
  from blog_title_generator import blog_titles_llm
19
  from blog_content_generator import blog_content_agent
20
  from image_fomatted_blog_generator import image_formatted_blog
21
  from image_prompts_generator import image_prompts
22
 
 
 
 
 
 
 
23
 
24
  llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", api_key = gemini_api_key) # type:ignore
25
 
@@ -28,6 +35,12 @@ class BlogState(TypedDict):
28
  blog_topics: List[str]
29
  final_topic: str
30
  blog_content: str
 
 
 
 
 
 
31
  image_formated_blog: str
32
  prompts: Dict[str, str]
33
 
@@ -42,18 +55,46 @@ graph1 = builder1.compile()
42
  # Graph 2:
43
  builder2 = StateGraph(BlogState)
44
  builder2.add_node("blog_agent", lambda state: blog_content_agent(llm, state))
 
 
45
  builder2.add_node("image_formatted_blog", lambda state: image_formatted_blog(llm, state))
46
  builder2.add_node("image_prompts", lambda state: image_prompts(llm, state))
47
 
48
  builder2.add_edge(START, "blog_agent")
49
- builder2.add_edge("blog_agent", "image_formatted_blog")
 
 
50
  builder2.add_edge("image_formatted_blog", "image_prompts")
51
  builder2.add_edge("image_prompts", END)
 
52
  graph2 = builder2.compile()
53
 
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  st.title("Generate General Informational Blog")
 
57
  input_data = st.text_input("Enter a Category for your blog:")
58
 
59
  if 'titles' not in st.session_state:
@@ -74,15 +115,30 @@ if input_data: # Only proceed if input_data is not empty
74
  if st.session_state.titles:
75
  st.session_state.selected_title = st.selectbox("Pick the Title for your Blog", st.session_state.titles)
76
 
77
- if st.button("Generate Blog") and st.session_state.selected_title:
78
- try:
79
- content = graph2.invoke({"final_topic": st.session_state.selected_title})
80
- st.markdown(content.get('image_formated_blog', "No content generated.")) # Avoid KeyError
81
- except Exception as e:
82
- st.error(str(e))
83
-
84
-
85
-
86
-
87
-
88
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  gemini_api_key = os.getenv("GEMINI_API_KEY")
16
 
17
 
18
+
19
  from blog_title_generator import blog_titles_llm
20
  from blog_content_generator import blog_content_agent
21
  from image_fomatted_blog_generator import image_formatted_blog
22
  from image_prompts_generator import image_prompts
23
 
24
+ from company_content_generator import company_content
25
+ from marketed_blog import marketed_blog
26
+ from seo_keywords import seo_keywords
27
+ from seo_optimized_content_generator import seo_optimized_content_with_marketing
28
+ from seo_optimized_content_generator import simple_seo_optimized_content
29
+
30
 
31
  llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp", api_key = gemini_api_key) # type:ignore
32
 
 
35
  blog_topics: List[str]
36
  final_topic: str
37
  blog_content: str
38
+ url: str #//
39
+ contact_us_url: str #//
40
+ company_information: str #//
41
+ company_marketed_blog: str #//
42
+ seo_keywords: str #//
43
+ seo_optimized_blog: str #//
44
  image_formated_blog: str
45
  prompts: Dict[str, str]
46
 
 
55
  # Graph 2:
56
  builder2 = StateGraph(BlogState)
57
  builder2.add_node("blog_agent", lambda state: blog_content_agent(llm, state))
58
+ builder2.add_node("seo_keyword", lambda state: seo_keywords(state)) # //
59
+ builder2.add_node("simple_seo_blog", lambda state: simple_seo_optimized_content(llm, state)) # //
60
  builder2.add_node("image_formatted_blog", lambda state: image_formatted_blog(llm, state))
61
  builder2.add_node("image_prompts", lambda state: image_prompts(llm, state))
62
 
63
  builder2.add_edge(START, "blog_agent")
64
+ builder2.add_edge("blog_agent", "seo_keyword")
65
+ builder2.add_edge("seo_keyword", "simple_seo_blog")
66
+ builder2.add_edge("simple_seo_blog", "image_formatted_blog")
67
  builder2.add_edge("image_formatted_blog", "image_prompts")
68
  builder2.add_edge("image_prompts", END)
69
+
70
  graph2 = builder2.compile()
71
 
72
 
73
+ # Graph 3:
74
+ builder3 = StateGraph(BlogState)
75
+
76
+ builder3.add_node("blog_agent", lambda state: blog_content_agent(llm, state))
77
+ builder3.add_node("company", lambda state: company_content(llm, state)) #//
78
+ builder3.add_node("market_blog", lambda state: marketed_blog(llm, state)) #//
79
+ builder3.add_node("seo_keyword", lambda state: seo_keywords(state)) # //
80
+ builder3.add_node("market_seo_blog", lambda state: seo_optimized_content_with_marketing(llm, state)) # //
81
+ builder3.add_node("image_formatted_blog", lambda state: image_formatted_blog(llm, state))
82
+ builder3.add_node("image_prompts", lambda state: image_prompts(llm, state))
83
+
84
+ builder3.add_edge(START, "blog_agent")
85
+ builder3.add_edge("blog_agent", "company")
86
+ builder3.add_edge("company", "market_blog")
87
+ builder3.add_edge("market_blog", "seo_keyword")
88
+ builder3.add_edge("seo_keyword", "market_seo_blog")
89
+ builder3.add_edge("market_seo_blog", "image_formatted_blog")
90
+ builder3.add_edge("image_formatted_blog", "image_prompts")
91
+ builder3.add_edge("image_prompts", END)
92
+
93
+ graph3 = builder3.compile()
94
+
95
 
96
  st.title("Generate General Informational Blog")
97
+
98
  input_data = st.text_input("Enter a Category for your blog:")
99
 
100
  if 'titles' not in st.session_state:
 
115
  if st.session_state.titles:
116
  st.session_state.selected_title = st.selectbox("Pick the Title for your Blog", st.session_state.titles)
117
 
118
+ # Checkbox for adding CTAs
119
+ add_cta = st.checkbox("Include Call to Actions")
120
+
121
+ if add_cta:
122
+ # Input fields for website and contact URLs
123
+ website_url = st.text_input("Enter your website URL:")
124
+ contact_url = st.text_input("Enter your contact us URL:")
125
+
126
+ # Generate Blog with CTAs button
127
+ if st.button("Generate Blog with CTAs"):
128
+ try:
129
+ content = graph3.invoke({
130
+ "final_topic": st.session_state.selected_title,
131
+ "url": website_url,
132
+ "contact_us_url": contact_url
133
+ })
134
+ st.markdown(content.get('image_formated_blog', "No content generated.")) # Avoid KeyError
135
+ except Exception as e:
136
+ st.error(str(e))
137
+ else:
138
+ # Generate Blog button without CTAs
139
+ if st.button("Generate Blog"):
140
+ try:
141
+ content = graph2.invoke({"final_topic": st.session_state.selected_title})
142
+ st.markdown(content.get('image_formated_blog', "No content generated.")) # Avoid KeyError
143
+ except Exception as e:
144
+ st.error(str(e))