Ashar11 commited on
Commit
bf32293
Β·
verified Β·
1 Parent(s): 0f2a126

Upload 5 files

Browse files
Files changed (5) hide show
  1. .env +1 -0
  2. app.py +38 -0
  3. main.py +30 -0
  4. requirements.txt +10 -0
  5. utils.py +573 -0
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ GOOGLE_API_KEY = "AIzaSyAcwFvIa53hEcUrIJXV0ST82_bSng8v6DM "
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from utils import generate_content
4
+ # FastAPI Endpoint (Update this if using ngrok or a deployed server)
5
+ # API_URL = "https://231e-119-156-102-95.ngrok-free.app/generate-content/"
6
+
7
+ st.title("Website Content Generator")
8
+
9
+ company_name = st.text_input("Enter Company Name", "GreenTech Solar")
10
+ services = st.text_area("Enter Services (comma-separated)", "Solar Panel Installation, Maintenance, Consultation")
11
+ idea = st.text_area("Enter Business Idea", "Solar Energy Solutions")
12
+ service_area = st.text_area("Enter Service Area (comma-separated)", "Exmouth , Newton Abbot, Teignmouth, Taunton")
13
+
14
+ if st.button("Generate Content"):
15
+ # Convert user input into JSON format
16
+ # payload = {
17
+ # "idea": idea,
18
+ # "company_name": company_name,
19
+ # "services": services
20
+ # }
21
+
22
+ with st.spinner("Generating content... Please wait ⏳"):
23
+ content = generate_content(idea, company_name, services, service_area)
24
+ # Check for errors
25
+
26
+ st.success("Content generated successfully!")
27
+ # content = response.json()
28
+ # Display content as plain text instead of Markdown
29
+ st.subheader("Home Page")
30
+ st.markdown(content["home_page"].content) # Show as plain text
31
+ st.subheader("About Us Page")
32
+ st.markdown(content["about_us_page"].content)
33
+ st.subheader("Service Page")
34
+ st.markdown(content["service_page"].content)
35
+ st.subheader("Individual Service Page")
36
+ st.markdown(content["individual_service_page"].content)
37
+
38
+
main.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+ from utils import generate_content
4
+
5
+ app = FastAPI(title="AI-Powered Website Content Generator")
6
+ # βœ… Request Model
7
+ class ContentRequest(BaseModel):
8
+ idea: str
9
+ company_name: str
10
+ services: str
11
+ service_area: str
12
+
13
+ # βœ… Response Model
14
+ class ContentResponse(BaseModel):
15
+ home_page: str
16
+ about_us_page: str
17
+ service_page: str
18
+ individual_service_page: str
19
+ quality_score: int
20
+ @app.post("/generate-content/", response_model=ContentResponse)
21
+ def generate_content_endpoint(request: ContentRequest):
22
+ content = generate_content(request.idea, request.company_name, request.services,request.service_area)
23
+ # βœ… Extract `.content` from AIMessage objects
24
+ return ContentResponse(
25
+ home_page=content["home_page"].content,
26
+ about_us_page=content["about_us_page"].content,
27
+ service_page=content["service_page"].content,
28
+ individual_service_page=content["individual_service_page"].content,
29
+ quality_score=content["quality_score"]
30
+ )
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ langchain
4
+ langgraph
5
+ duckduckgo-search
6
+ pydantic
7
+ langchain_community
8
+ langchain-google-genai
9
+ python-dotenv
10
+ pyngrok
utils.py ADDED
@@ -0,0 +1,573 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict
2
+ from langchain_google_genai import ChatGoogleGenerativeAI
3
+ from langchain_community.tools import DuckDuckGoSearchRun
4
+ import os
5
+ from dotenv import load_dotenv
6
+ from langgraph.graph import StateGraph, END
7
+ load_dotenv()
8
+
9
+ GEMINI_API_KEY = os.getenv("GOOGLE_API_KEY")
10
+ # Initialize LLM
11
+ llm = ChatGoogleGenerativeAI(model="gemini-1.0-pro",google_api_key=GEMINI_API_KEY)
12
+ search_tool = DuckDuckGoSearchRun(region="uk-en", safe="strict")
13
+
14
+ class ContentState(Dict):
15
+ idea: str
16
+ company_name: str
17
+ services: str
18
+ service_area:str
19
+ research_data: str
20
+ seo_optimization: str
21
+ home_page: str
22
+ about_us_page: str
23
+ service_page: str
24
+ individual_service_page: str
25
+ quality_score: int
26
+
27
+ # βœ… Define Workflow
28
+ workflow = StateGraph(ContentState)
29
+
30
+
31
+ # βœ… Research Task
32
+ def research_task(state: ContentState) -> ContentState:
33
+ research_query = f"{state['idea']}-{state['company_name']} - {state['services']}"
34
+ research_data = search_tool.run(research_query )
35
+ state.update({"research_data": research_data})
36
+ return state
37
+
38
+
39
+ # βœ… SEO Optimization Task
40
+ def seo_optimization_task(state: ContentState) -> ContentState:
41
+ prompt = f"Optimize the following research for SEO: {state['research_data']}"
42
+ seo_optimization = llm.invoke(prompt)
43
+ state.update({"seo_optimization": seo_optimization})
44
+ return state
45
+
46
+ # βœ… Content Writing Task (Generates Home, About Us, and Service Pages)
47
+ def content_writing_task(state: ContentState) -> ContentState:
48
+ research_data = state["research_data"]
49
+ seo_data = state["seo_optimization"]
50
+ services = ", ".join(state["services"])
51
+ service_area = ", ".join(state["service_area"])
52
+ company_name=state["company_name"]
53
+ prompts = {
54
+ "home_page": f"""You are a highly skilled web content writer specializing in creating persuasive, SEO-optimized website content. Your task is to write an engaging **Home Page** for a company named **{company_name}**, which provides **{services}**.
55
+
56
+ #### **Key Requirements:**
57
+ - **Headline & Subheadline:**
58
+ - Craft a compelling headline that immediately conveys the company’s expertise and value proposition.
59
+ - Use a concise subheadline to reinforce trust and credibility.
60
+
61
+ - **Introduction:**
62
+ - Write a powerful opening paragraph that clearly introduces the company, its specialization, and its core services.
63
+ - Ensure the tone is professional yet approachable, instilling confidence in potential customers.
64
+
65
+ - **Service Sections:**
66
+ - Break down key services (**{services}**) into structured sections, detailing their benefits and unique selling points.
67
+ - Highlight any special features, certifications, or guarantees that differentiate the company from competitors.
68
+
69
+ - **Trust & Experience:**
70
+ - Showcase the company’s industry expertise, years of experience, and qualifications (e.g., certifications, accreditations).
71
+ - Mention any professional affiliations that reinforce credibility.
72
+
73
+ - **Customer Benefits & Competitive Advantages:**
74
+ - Emphasize why customers should choose this company over competitors.
75
+ - Include unique selling points such as fast service, free consultations, financing options, warranties, or emergency availability.
76
+
77
+ - **Call to Action (CTA):**
78
+ - Craft a strong CTA that encourages immediate action (e.g., "Book a Free Consultation Today!" or "Get Your Quote Now!").
79
+ - Use persuasive, action-oriented language to drive conversions.
80
+
81
+ - **SEO Optimization:**
82
+ - Naturally integrate relevant keywords for better search visibility.
83
+ - Ensure readability, avoiding keyword stuffing.
84
+ - Generate a compelling meta description to improve click-through rates.
85
+
86
+ - **Regional Adaptability:**
87
+ - Keep the content adaptable by avoiding references to specific locations, unless specified.
88
+
89
+ - **Use This Research for Accuracy:**
90
+ {research_data}
91
+
92
+ - **Apply These SEO Best Practices:**
93
+ {seo_data}
94
+
95
+ Ensure the content flows smoothly, engages the reader, and maintains a clear, structured layout that is easy to scan. The tone should balance professionalism with friendliness, making it both informative and persuasive.
96
+ """,
97
+
98
+ "about_us_page": f"""You are an expert storyteller and professional content writer. Write a compelling **About Us Page** for {company_name}, a company specializing in {services}. The content should be **engaging, structured, and customer-focused**, closely resembling the example provided.
99
+
100
+ ### **Key Requirements:**
101
+ - **Headline & Introduction:**
102
+ - Start with a strong, attention-grabbing headline that establishes the company’s authority.
103
+ - Provide a warm and engaging introduction that highlights the company’s expertise, commitment to customer satisfaction, and high-quality service.
104
+
105
+ - **Company Overview:**
106
+ - Clearly define the company’s **mission, values, and dedication** to professionalism, reliability, and customer care.
107
+ - Emphasize industry experience, certifications, and partnerships with trusted brands.
108
+ - If applicable, include any notable statistics (e.g., years of experience, number of clients served, customer satisfaction ratings).
109
+
110
+ - **Services Overview:**
111
+ there is the list of service {services} so show one by one.
112
+ - Present a structured list of key services, similar to how a **bullet-point format** is used in the example.
113
+ - Ensure descriptions are clear, informative, and compelling.
114
+ - The services is pass dynamically insert {services} show the data only these service.
115
+
116
+ - **Unique Selling Points & Customer Benefits:**
117
+ - Highlight what makes this company stand out (e.g., 24/7 emergency services, free consultations, long-term warranties, financing options).
118
+ - Explain how the company’s approach is **customer-first**, ensuring transparency, trust, and superior service.
119
+
120
+ - **Work Process Overview:**
121
+ - Provide a **step-by-step explanation** of the company’s service process for clarity and transparency.
122
+ - Ensure this section builds confidence in potential customers.
123
+
124
+ - **Call to Action:**
125
+ - Conclude with a strong, action-driven statement that encourages customers to **get in touch, request a quote, or book a consultation**.
126
+
127
+ - **SEO Optimization & Readability:**
128
+ - Ensure the content is **SEO-friendly**, with relevant keywords for better search rankings.
129
+ - Use concise paragraphs, bullet points where necessary, and persuasive language.
130
+
131
+ - **Universal Applicability:**
132
+ - Avoid references to specific locations unless explicitly required.
133
+ - Ensure the content is adaptable to various regions without needing modifications.
134
+
135
+ - **Use this research:** {research_data}
136
+ - **Apply these SEO best practices:** {seo_data}
137
+ ### **Content Example Structure:**
138
+ - **About {company_name}** (Introduction)
139
+ - **Our Mission & Values** (Commitment to quality, customer satisfaction, professionalism)
140
+ - **Why Choose Us?** (Experience, certifications, reliability, customer perks)
141
+ - **Our Services:** (Bullet list of key services like {services})
142
+ - **Areas We Cover:** (Dynamically insert {service_area} to list locations served and shown only name in a bullet point)
143
+ - **Contact Us** (Call to action)
144
+ The content should be **professional yet personable**, building trust and encouraging potential customers to engage with the business.
145
+ """,
146
+
147
+
148
+ "service_page": f"""You are a professional content strategist and expert copywriter. Create a **dedicated service page** for {services} that is **engaging, structured, and customer-focused** while maintaining a professional yet approachable tone.
149
+
150
+ ### **Key Requirements:**
151
+
152
+ - **Headline & Introduction:**
153
+ - Start with a strong, compelling headline introducing the service.
154
+ - Provide a **concise yet engaging introduction**, highlighting the importance of this service and how it benefits the customer.
155
+
156
+ - **Service Offerings:**
157
+ - Break down the service into **clear, distinct sections**, similar to the example provided.
158
+ - Use **subheadings** to introduce different aspects of the service, ensuring clarity and easy navigation.
159
+ - Clearly explain **what is included**, covering key features and benefits.
160
+
161
+ - **Why Choose Us:**
162
+ - Emphasize **expertise, experience, and unique advantages** (e.g., warranties, certifications, customer satisfaction).
163
+ - Highlight **any exclusive benefits** such as fast response times, emergency support, or personalized service.
164
+
165
+ - **Process Overview:**
166
+ - Provide a **step-by-step breakdown** of how this service is delivered.
167
+ - Ensure the process is **easy to understand** and builds trust with potential customers.
168
+
169
+ - **Customer Benefits:**
170
+ - Clearly outline **how customers will benefit** (e.g., cost savings, improved efficiency, long-term reliability).
171
+ - Use a **reassuring tone** to emphasize professionalism, quality, and customer satisfaction.
172
+
173
+ - **Call to Action (CTA):**
174
+ - Include a **strong, action-driven CTA** that encourages customers to take the next step (e.g., "Contact us today for a free consultation!" or "Book your service now and enjoy hassle-free heating").
175
+
176
+ - **SEO Optimization & Readability:**
177
+ - Ensure content is **SEO-optimized**, with relevant keywords for better search rankings.
178
+ - Use **concise paragraphs, bullet points, and subheadings** for easy reading.
179
+
180
+ - **Adaptability:**
181
+ - Do not mention specific locations unless required, ensuring universal applicability.
182
+
183
+ - **Use this research:** {research_data}
184
+ - **Apply these SEO best practices:** {seo_data}
185
+
186
+ The content should be **engaging, structured, and persuasive**, designed to build trust and encourage customer engagement.
187
+ """,
188
+
189
+
190
+ "individual_service_page": f"""You are a professional web content writer. Write a **dedicated service page** for the service: {services}. The content should be structured with a clear heading for each service and the related content underneath it. Ensure that the page is **informative, practical, and engaging** while maintaining a professional tone.
191
+ ### **Service: {services}**
192
+ there is the list of service {services} so show one by one.
193
+ #### **Introduction**
194
+ Provide a brief, clear introduction to the service, explaining its purpose and value for the customer.
195
+
196
+ #### **Service Details**
197
+ Describe what is included in this service, highlighting its key features and benefits.
198
+
199
+ #### **Process**
200
+ Outline the step-by-step process of how this service is delivered, including any important details customers should know.
201
+
202
+ #### **Customer Benefits**
203
+ Explain how the customer will benefit from this service, whether through cost savings, enhanced efficiency, or improved reliability.
204
+
205
+ #### **Why Choose Us?**
206
+ Provide practical reasons why customers should trust this company for this service, focusing on expertise, quality, and customer satisfaction.
207
+
208
+ #### **Call to Action (CTA)**
209
+ Encourage customers to take action, such as requesting a quote, scheduling an appointment, or getting in touch for more details.
210
+
211
+ - Ensure the content is **clear, persuasive, SEO-optimized, and engaging**.
212
+ - Do not mention specific locations so the content remains adaptable for any service area.
213
+ - Keep the content **concise, natural, and SEO-friendly**β€”avoid overly promotional language.
214
+ - Use this research: {research_data}
215
+ - Apply these SEO best practices: {seo_data}
216
+ """
217
+
218
+ }
219
+ pages = {key: llm.invoke(prompt) for key, prompt in prompts.items()}
220
+ state.update(pages)
221
+ return state
222
+
223
+
224
+ def refine_content(state: ContentState) -> ContentState:
225
+ services = ", ".join(state["services"])
226
+ prompts = {
227
+ "refine_home_page_content": f"""You are an expert UK-based web content writer. Your task is to refine the following **Home Page Content** to match the structure, style, and detail level of top-tier UK service websites. The content should be well-organized, highly detailed, and formatted professionally.
228
+ ---
229
+
230
+ ### **Few-Shot Examples of Desired Structure (UK-Specific, Highly Detailed)**
231
+
232
+ #### **Example 1 - Exeter’s Heating Experts**
233
+ 🏑 **Your Trusted Local Heating Specialists** | Providing Gas Boiler Installations & Central Heating Solutions Across Exeter & South Devon
234
+
235
+ πŸ”Ή **Professional Boiler Installations – A-rated Efficiency & Reliability**
236
+ At **South Coast Plumbing and Heating**, we specialise in fitting modern **A-rated combi, traditional, and system boilers** from **Viessmann, Worcester Bosch, and Vaillant**β€”brands known for their exceptional reliability and energy efficiency. Our **Gas Safe registered engineers** ensure that your new boiler is installed safely, efficiently, and in compliance with **UK heating regulations**.
237
+
238
+ ⭐ **Why Choose Us for Your Boiler Installation?**
239
+ βœ” **Next-Day Boiler Fitting:** If your boiler breaks down unexpectedly, we can fit a **replacement boiler within 24 hours**.
240
+ βœ” **Free Smart Thermostat:** Every boiler installation includes a **smart thermostat**, helping you **reduce energy bills** by up to 30%.
241
+ βœ” **Extended Manufacturer’s Warranties:** We offer warranties of **up to 10 years** for select models, ensuring peace of mind.
242
+
243
+ πŸ”Ή **Experienced & Certified Heating Engineers**
244
+ Our team is **Gas Safe Registered** and **certified through City & Guilds**, with a **combined experience of over 40 years**. We’ve worked on **every type of heating system**, meaning we can handle anything from complex installations to emergency repairs.
245
+
246
+ πŸ“ž **Reliable Customer Service** – We always **answer your calls** and **respond promptly** to your inquiries, so you’re never left waiting when you need help.
247
+
248
+ πŸ”Ή **Air-Source Heat Pump Installations – Future-Proof Your Home**
249
+ Looking for a sustainable heating solution? We install **energy-efficient air-source heat pumps** that help **reduce carbon footprint** and **lower heating costs**. These systems **extract heat from the air** to provide **year-round warmth**, even in cold UK weather.
250
+
251
+ πŸ”Ή **Annual Boiler Servicing – Keep Your Heating System Running Smoothly**
252
+ Regular servicing extends the **lifespan of your boiler** and prevents costly breakdowns. Our **comprehensive servicing includes**:
253
+ βœ… Checking for **gas leaks and corrosion**
254
+ βœ… Testing **efficiency and emissions**
255
+ βœ… Inspecting **safety controls and components**
256
+ βœ… Cleaning & optimizing **internal parts**
257
+
258
+ πŸ—“ **Book your annual servicing today** to keep your heating system in peak condition!
259
+
260
+ ---
261
+
262
+ #### **Example 2 - Cheltenham Heating Solutions**
263
+ πŸ”₯ **Your Local Heating & Boiler Experts in Cheltenham, Gloucester, and Worcestershire**
264
+
265
+ βœ… **New Gas Boilers - High Efficiency & Cost Savings**
266
+ We supply and install the **latest A-rated boilers** from **Worcester Bosch, Vaillant, and Ideal**. Our boilers come with **up to 10 years’ warranty** and are **professionally installed by our Gas Safe engineers**.
267
+
268
+ ⭐ **Exclusive Benefits When You Choose Us:**
269
+ βœ” **FREE Annual Boiler Servicing** – We service your boiler **free of charge** for the **entire length of your warranty**!
270
+ βœ” **Flexible Finance Options** – Spread the cost of your new boiler with **0% interest-free finance**.
271
+ βœ” **Expert Guidance & No Hard Sell** – We provide **honest advice** and won’t pressure you into unnecessary purchases.
272
+
273
+ πŸ“ž **Emergency Boiler Repairs - Fast Response**
274
+ Boiler failure? No heating or hot water? Our **emergency call-out service** ensures a **same-day response** to restore warmth to your home quickly.
275
+
276
+ πŸ”Ή **Comprehensive Central Heating Services**
277
+ From full **central heating system installations** to **power flushing** and **radiator repairs**, we offer a **complete range of services** to keep your home warm and energy-efficient.
278
+
279
+ πŸ›  **What We Offer:**
280
+ βœ… **Gas Boiler Replacements & Repairs**
281
+ βœ… **Landlord Gas Safety Certificates (CP12)**
282
+ βœ… **Radiator & Thermostat Installations**
283
+ βœ… **Power Flushing for Heating Systems**
284
+ βœ… **Emergency Plumbing Services**
285
+
286
+ πŸ“ **Areas We Cover:** Cheltenham, Gloucester, Tewkesbury, Worcester, Stroud, and surrounding areas.
287
+
288
+ ---
289
+
290
+ ### **NOW, Refine the Following Home Page Content to Match These High-Detail Examples:**
291
+
292
+ {state["home_page"].content}
293
+
294
+ ---
295
+
296
+ ### **πŸ“Œ Instructions for Refinement (UK-Specific, Highly Detailed & Professional):**
297
+ βœ… **Enhance Detail & Professionalism:** The content should be **well-structured, informative, and engaging**.
298
+ βœ… **Use UK Spelling & Terminology:** Ensure terms like **Gas Safe, A-rated boilers, VAT, CP12 certificates, Smart Thermostats, 10-Year Warranties** are included.
299
+ βœ… **Use UK city only :** If the city need then use only UK city not a other**.
300
+ βœ… **Improve Readability:** Format with **clear headings, bullet points, and short paragraphs** for better user experience.
301
+ βœ… **Make it SEO-Friendly (Without Being Robotic):** Use relevant keywords naturally, ensuring it reads as **authentic, high-quality website content**.
302
+ βœ… **Focus on Benefits & Trustworthiness:** Clearly outline **why customers should choose this company**, including guarantees, fast response times, expert knowledge, and certifications.
303
+ βœ… **Ensure Content is UK Market-Specific:** Adapt services, pricing models, and customer expectations to fit UK consumer standards.
304
+
305
+ Return the improved home page content in a **fully structured, highly detailed, and polished format** suitable for a professional UK service business website.""",
306
+
307
+ "refine_about_us_page_content": f""" You are an expert UK-based content writer specializing in home services. Your task is to refine the following **About Us Page Content** for a heating and plumbing company to match the structure, style, and detail level of top-tier UK service websites. The content should be well-organized, informative, and highly professional.
308
+ ---
309
+ ### **Few-Shot Examples of Desired Structure (UK-Specific, Highly Detailed)**
310
+
311
+ #### **Example 1 - South Coast Plumbing and Heating**
312
+ 🏑 **Experienced Heating & Plumbing Specialists in Exeter, Devon**
313
+
314
+ **South Coast Plumbing and Heating** is a trusted team of **Gas Safe-registered engineers and certified plumbers** with over **20 years of industry experience**. We proudly serve **both domestic and commercial clients** across **Exeter, Devon, and the surrounding areas**, offering comprehensive heating and plumbing services.
315
+
316
+ πŸ”Ή **Our Expertise Includes:**
317
+ βœ” **New Gas & Oil Boiler Installations** – We specialise in the installation of modern **A-rated gas and oil boilers**, ensuring energy-efficient heating solutions for homes and businesses.
318
+ βœ” **Boiler Repairs & Servicing** – Our **Gas Safe registered engineers** carry out professional repairs and servicing, extending the lifespan of your boiler and preventing costly breakdowns.
319
+ βœ” **Air-Source Heat Pumps** – We install **renewable heating systems**, such as **air-source heat pumps**, to provide a **sustainable alternative** to traditional heating.
320
+ βœ” **Central Heating Systems & Power Flushing** – Our team also handles full central heating installations and **system power flushing**, ensuring that your home stays warm and your heating system operates at peak performance.
321
+
322
+ πŸ”Ή **Why Choose Us?**
323
+ βœ” **Over 20 Years of Experience** – We’ve built our reputation by delivering **reliable, affordable, and high-quality services**.
324
+ βœ” **24/7 Emergency Plumbing** – We’re available around the clock for emergency plumbing needs.
325
+ βœ” **Fully Qualified & Gas Safe Registered** – All our engineers are **fully certified**, offering peace of mind that your home is in expert hands.
326
+ βœ” **Areas We Cover:** Exeter, Exmouth, Newton Abbot, Taunton, Honiton, and surrounding areas.
327
+
328
+ πŸ”Ή **Our Commitment:**
329
+ At **South Coast Plumbing and Heating**, we focus on delivering a **personalised, customer-centric service**. We believe in honesty, integrity, and **exceptional workmanship**. Whether it’s a routine boiler service or an urgent repair, we treat every project with the same level of care and professionalism.
330
+
331
+ ---
332
+
333
+ #### **Example 2 - Superior Heat Solutions**
334
+ πŸ”₯ **Your Local Heating Experts in Central Scotland**
335
+
336
+ At **Superior Heat Solutions**, we take pride in our team’s **14+ years of experience** in the heating and plumbing industry. We provide **high-quality, energy-efficient solutions** to meet your unique needsβ€”whether it’s a new boiler, **central heating repairs**, or a **full bathroom installation**.
337
+
338
+ πŸ”Ή **Our Core Services Include:**
339
+ βœ” **New Boiler Installations** – We offer **A-rated gas boilers** from leading brands such as **Vaillant, Worcester Bosch, and Ideal**, backed by up to **10-year warranties**.
340
+ βœ” **Air Source Heat Pumps** – Our engineers are skilled in installing **eco-friendly heat pumps**, which help reduce carbon emissions and lower heating costs.
341
+ βœ” **Power Flushing** – We provide professional **power flushing services** to remove sludge and debris from your heating system, improving efficiency and performance.
342
+ βœ” **General Plumbing Services** – From fixing leaks to **installing new radiators**, our team is equipped to handle all your plumbing needs.
343
+
344
+ πŸ”Ή **Our Promise to You:**
345
+ βœ” **Guaranteed Quality Work** – We stand behind our work, ensuring that every project is completed to the **highest standard**.
346
+ βœ” **Affordable Pricing & Transparent Quotes** – We promise to beat any written quote for **boiler installations**, ensuring you get the best value for money.
347
+ βœ” **Constant Communication** – We keep you updated at every stage of the project, offering clear guidance and transparent advice.
348
+
349
+ πŸ”Ή **Areas We Serve:**
350
+ We proudly serve **Cheltenham**, **Gloucester**, **Tewkesbury**, **Stroud**, and the surrounding areas in **Central Scotland**.
351
+
352
+ ---
353
+
354
+ ### **NOW, Refine the Following About Us Content to Match These High-Detail Examples:**
355
+
356
+ {state["about_us_page"].content}
357
+
358
+ ---
359
+
360
+ ### **πŸ“Œ Instructions for Refinement (UK-Specific, Highly Detailed & Professional):**
361
+ βœ… **Enhance Detail & Professionalism:** The content should be **well-structured**, **clear**, and **engaging**.
362
+ βœ… **Use UK Spelling & Terminology:** Ensure terms like **Gas Safe**, **A-rated boilers**, **VAT**, and **renewable energy** are included.
363
+ βœ… **Improve Readability:** Use **clear headings**, **bullet points**, and **short paragraphs** for ease of reading.
364
+ βœ… **Focus on Benefits & Trustworthiness:** Make sure to clearly outline **why customers should choose this company**, highlighting **experience, customer service, and certifications**.
365
+ βœ… **Make it SEO-Friendly:** Integrate **relevant UK-based keywords** naturally into the content to improve SEO ranking without sacrificing readability.
366
+ βœ… **Include Location Details & Coverage Areas:** Clearly specify the regions served, emphasizing the **local expertise** of the business.
367
+
368
+ Return the improved **About Us Page** content in a **fully structured, highly detailed, and polished format** suitable for a professional UK service business website.""",
369
+
370
+
371
+ "refine_service_page": f""" You are an expert in creating **SEO-optimized, highly detailed, and engaging** service pages for business websites.
372
+ Your task is to **refine the service page content** to make it more structured, comprehensive, and conversion-friendly.
373
+ ### **Instructions for Refinement:**
374
+ - **Expand Each Section** – Provide **in-depth descriptions** of the services, including their **benefits and processes**.
375
+ - **Use Clear Headings & Subheadings** – Structure the content properly for **better readability and SEO**.
376
+ - **Highlight Key Features with Bullet Points** – Make the information **easy to scan and engaging**.
377
+ - **Incorporate Persuasive & Actionable Language** – Encourage visitors to **take action** (e.g., **"Get a Free Quote Today!"**).
378
+ - **Ensure Natural Keyword Integration** – Optimize for **search engines** while keeping it human-friendly.
379
+ - **Mention the Location Where Relevant** – If the services are location-specific, naturally include city names.
380
+ ---
381
+
382
+ ### **Example of a Structured & Detailed Service Page:**
383
+ ```
384
+ ## **Our Expert Plumbing & Heating Services in London**
385
+ At **South Coast Plumbing & Heating**, we offer a full range of **reliable and high-quality heating and plumbing services** in London. Our experienced, **Gas Safe registered engineers** ensure your home stays warm, safe, and energy-efficient all year round.
386
+
387
+ ### **πŸ”Ή New Boiler Installation**
388
+ Looking for a new boiler? We supply and install **high-efficiency A-rated boilers** from top brands like **Worcester Bosch, Vaillant, and Ideal**. Our experts recommend the **best energy-efficient solution** based on your home’s heating needs.
389
+
390
+ βœ… Free Consultation & Personalized Advice
391
+ βœ… Professional Installation with a 10-Year Warranty
392
+ βœ… Energy-Saving Solutions to Lower Your Bills
393
+
394
+ ### **πŸ”Ή Fast & Reliable Boiler Repairs**
395
+ Experiencing boiler issues? We provide **same-day emergency repairs** for all major brands. Common issues we fix:
396
+
397
+ - **No heating or hot water**
398
+ - **Leaks, pressure drops, and error codes**
399
+ - **Strange noises or pilot light failures**
400
+
401
+ πŸš€ **Call now for urgent repairs!**
402
+ ### **πŸ”Ή Annual Boiler Servicing**
403
+ Keep your boiler in **top condition** with our **comprehensive servicing**:
404
+
405
+ - **Safety checks** to prevent carbon monoxide risks
406
+ - **Cleaning & tuning** for maximum efficiency
407
+ - **Early fault detection** to avoid costly repairs
408
+
409
+ πŸ”₯ **Book your service today to avoid winter breakdowns!**
410
+ ---
411
+ ```
412
+
413
+ ---
414
+
415
+ ### **Now, refine the following service page content into a highly detailed, structured, and persuasive version like the example above:**
416
+
417
+ {state["service_page"].content}
418
+
419
+ **Make sure to:**
420
+ - Expand the details of each section.
421
+ - Use structured headings and subheadings.
422
+ - Improve the **clarity, engagement, and persuasiveness** of the content.
423
+ - Include **strong call-to-action statements**.
424
+ - Ensure **SEO optimization** with natural keyword integration.
425
+
426
+ Provide the refined content in a **well-formatted and professional** manner.
427
+ """,
428
+
429
+ "refine_individual_service_page" : f""" You are an expert at generating professional, structured, and SEO-optimized service pages for a business website.
430
+
431
+ Please **rewrite and refine** the following individual service page content using the exact format of the examples provided below.
432
+ Your response **must strictly follow the same structure, tone, and clarity** as the examples.
433
+ ### **Service: {services}**
434
+ there is the list of service {services} so show one by one.
435
+ **Instructions:**
436
+ - Maintain the **exact headings, formatting, and structure** used in the examples.
437
+ - Ensure **clarity and professionalism** in the content.
438
+ - Use **engaging and SEO-friendly language**.
439
+ - Structure the content with **clear headings, subheadings, and sections**.
440
+ - Adapt the text while keeping it **relevant to the service and location**.
441
+
442
+ **Example Format of a Well-Structured Service Page:**
443
+ ```
444
+ SERVICE AREAS PAGES
445
+ Exeter
446
+
447
+ Heating Services for Exeter
448
+
449
+ Whether you need a new boiler, central heating installation, power flushing service, or boiler repair, our Gas Safe engineers are here to ensure your home stays warm and comfortable. South Coast Plumbing and Heating covers Exeter and provides a complete range of services for Natural Gas and oil boilers.
450
+
451
+ New Boilers Installed in Exeter
452
+ Are you looking to upgrade to a new, energy-efficient boiler in Exeter? We supply and install A-rated gas and oil boilers from leading manufacturers. Our experienced gas heating engineers can help you choose the right replacement boiler for your home. Get an online quote from us for a new boiler that delivers optimum efficiency and reduces your energy bills.
453
+
454
+ We Service Gas and Oil Boilers in Exeter
455
+ Regular maintenance is key to ensuring your boiler works safely and efficiently all year round. Our team offers annual boiler servicing for homes across Exeter. During the boiler service, we perform a full inspection, identifying any potential issues before they become costly repairs. Keeping your boiler in top condition can also help to extend its lifespan and maintain your warranty.
456
+
457
+ Boilers Fixed Professionally in Exeter
458
+ If your boiler breaks down, you don’t want to be left without heating or hot water for long. We offer fast and reliable boiler repairs throughout Exeter. Our team of Gas Safe engineers is fully equipped to diagnose and fix common boiler issues, such as leaks, no hot water, and non-firing systems. If you’re experiencing boiler problems, contact us for a quick, professional repair service.
459
+
460
+ Air Source Heat Pumps
461
+ Ask our team to give you a quote for a new air source heat pump in Exeter. Renewable energy products are the next generation in heating technology, so ask us about installing it in your home. We are your local renewable energy experts, available to install the best heat pump system to suit your home in Exeter.
462
+
463
+ All Plumbing for Exeter
464
+ When you need a reliable plumber in Exeter, our team is here to help. We handle all types of plumbing projects, including general plumbing and emergency plumbing. You can count on us for prompt and professional service every time. For new kitchen or bathroom plumbing and 24-hour plumbers, our Exeter plumbers have you covered.
465
+
466
+ Commercial Boilers & Plumbing Exeter
467
+ If you need a commercial plumber or heating engineer for your Exeter business, then South Coast Plumbing and Heating is the best team to contact. We install and maintain commercial boilers and hot water systems in Exeter. We also cover commercial plumbing projects.
468
+ ```
469
+
470
+ **Now, rewrite the following service page content to match the format above, strictly follow:**
471
+
472
+ ```
473
+ {state["individual_service_page"].content}
474
+ ```
475
+
476
+ **Your response must follow the example structure exactly.**
477
+ """
478
+ }
479
+ pages = {key: llm.invoke(prompt) for key, prompt in prompts.items()}
480
+ state.update(pages)
481
+ return state
482
+
483
+ def evaluate_content_quality(state: ContentState) -> ContentState:
484
+ """Evaluates the quality of the given content and assigns a score from 0 to 10.
485
+ If the score is 7 or below, it suggests regeneration.
486
+ """
487
+ prompt = f"""
488
+ ### **Role & Responsibility**
489
+ You are an **extremely strict content quality evaluator**, ensuring that the provided website content is **highly professional, conversion-focused, human-like, and SEO-optimized**.
490
+ Your job is to **identify even the smallest weaknesses** and ensure that only **exceptional** content is accepted.
491
+
492
+ ### **Evaluation Criteria (Be Extremely Critical)**
493
+ 1. **Readability & Flow** – Is the content **crystal clear** and **engaging**, or does it contain **clunky phrasing, awkward transitions, or unnecessary complexity**?
494
+ 2. **Coherence & Structure** – Does the content **flow logically** with **no redundancy or repetition**? Are sections **properly structured** with **clear headers**?
495
+ 3. **Depth & Relevance** – Is the content **deeply informative** and **highly relevant** to plumbing, heating, and boiler services, or is it **generic and lacking real value**?
496
+ 4. **SEO Optimization** – Does the content **seamlessly integrate important keywords** while avoiding **keyword stuffing**? Are **headings, subheadings, and formatting** properly optimized?
497
+ 5. **Factual Accuracy** – Is the content **technically sound and correct**? Are there **any vague, misleading, or inaccurate claims**?
498
+ 6. **Human-like & Persuasive Tone** – Does the content read **smoothly and naturally**, or does it sound **robotic, generic, or AI-generated**?
499
+ 7. **Grammar & Language** – Are there **any grammar mistakes, typos, awkward sentence structures, or inconsistencies**?
500
+ 8. **Persuasiveness & Conversion Ability** – Does the content **convince customers to take action (e.g., request a quote, book a service)**? Are CTAs **strong and compelling**?
501
+
502
+ ---
503
+
504
+ ### **Scoring System (Be VERY Harsh – Only Near-Perfect Content Gets High Scores)**
505
+ - **0-3: Unacceptable** – Poorly written, unclear, lacks professionalism. Needs a total rewrite.
506
+ - **4-6: Below Average** – Some acceptable elements, but **not good enough** for high-quality business content. Needs serious improvement.
507
+ - **7: Average** – Acceptable but still **far from perfect**. Requires multiple refinements.
508
+ - **8: Above Average** – Decent, but **lacks the level of refinement needed for top-tier content**. Needs adjustments.
509
+ - **9: Almost There** – High quality, **but still room for final polishing**.
510
+ - **10: Perfect** – **Extremely rare.** Only award a **10** if the content is **flawless, highly persuasive, and perfectly structured**.
511
+
512
+ ---
513
+
514
+ ### **Content to Evaluate:**
515
+
516
+ ```
517
+ {state["home_page"].content}
518
+ {state["about_us_page"].content}
519
+ {state["service_page"].content}
520
+ {state["individual_service_page"].content}
521
+ ```
522
+
523
+ **Strictly return ONLY this format:**
524
+ - **Quality Score: X/10**
525
+ - **Reason for Score: [Concise Explanation]**
526
+ - **Key Areas to Improve (if applicable)**
527
+ """
528
+
529
+ response = llm.invoke(prompt)
530
+ output = response.content
531
+
532
+ # Extract the score from the response
533
+ try:
534
+ score_line = [line for line in output.split("\n") if "Quality Score" in line][0]
535
+ score = int(score_line.split(":")[-1].strip().split("/")[0])
536
+ except (IndexError, ValueError):
537
+ score = 0 # Default to 0 if parsing fails
538
+
539
+ # **Fix: Return updated state instead of just the score**
540
+ state["quality_score"] = score
541
+ return state # **Ensure we return the updated dictionary**
542
+
543
+ # βœ… Define Workflow Steps
544
+ workflow.add_node("research_step", research_task)
545
+ workflow.add_node("seo_step", seo_optimization_task)
546
+ workflow.add_node("writing_step", content_writing_task)
547
+ workflow.add_node("refine_content", refine_content)
548
+ workflow.add_node("evaluate_content_quality", evaluate_content_quality)
549
+ workflow.add_edge("refine_content", "evaluate_content_quality")
550
+ # βœ… Define Transitions
551
+ workflow.set_entry_point("research_step")
552
+ workflow.add_edge("research_step", "seo_step")
553
+ workflow.add_edge("seo_step", "writing_step")
554
+ workflow.add_edge("writing_step", "refine_content")
555
+ workflow.add_conditional_edges(
556
+ "evaluate_content_quality",
557
+ lambda state: "refine_content" if state["quality_score"] <= 7 else END,
558
+ {
559
+ "refine_content": "refine_content",
560
+ END: END
561
+ }
562
+ )
563
+ content_graph = workflow.compile()
564
+
565
+ def generate_content(idea: str, company_name: str, services: str, service_area: str) -> Dict:
566
+ state = content_graph.invoke({
567
+ "idea": idea,
568
+ "company_name": company_name,
569
+ "services": services,
570
+ "service_area":service_area,
571
+ "quality_score": 0
572
+ })
573
+ return state