AhsanRazi commited on
Commit
e65d325
Β·
verified Β·
1 Parent(s): c8432f6

Update company_content_generator.py

Browse files
Files changed (1) hide show
  1. company_content_generator.py +102 -92
company_content_generator.py CHANGED
@@ -1,93 +1,103 @@
1
- import sys
2
- import asyncio
3
- from langchain_core.prompts import PromptTemplate
4
-
5
- from crawl import marketing_crawling
6
-
7
-
8
- company_prompt_template = PromptTemplate.from_template("""
9
- # Task
10
- This is the scraped content from the company website. Read this content and extract the key information in an easy-to-read, professional format.
11
-
12
- #**Instructions:**
13
- - Focus on the most important details and present them in a structured, clear format.
14
- - Follow the example below for formatting and style.
15
- - Organize the content into clear sections such as:
16
- - **About the Company**
17
- - **Services Offered** (with sub-sections for each service)
18
- - **Why Choose the Company** (highlight unique selling points and certifications)
19
- - **Company Information** (contact details, address, and other relevant details)
20
- - Avoid irrelevant details, redundant information, and generic text.
21
- - Use professional, concise language that is easy to understand.
22
- - Ensure consistency in formatting and tone.
23
-
24
- #**Example:**
25
-
26
- #### **About All Solar Works**
27
- All Solar Works specializes in **solar panels, battery storage, EV chargers, and electrical services** across Sussex, UK. They offer expert installation and high-quality solutions to help customers save money on energy bills while reducing their carbon footprint.
28
-
29
- ----------
30
-
31
- ### **Services Offered**
32
-
33
- #### **1. Solar Panels**
34
- - Install various solar panel systems to fit different budgets.
35
- - Helps customers reduce bills and enjoy long-term savings.
36
- - **Complete Solar Panel System Package includes:**
37
- - **X** kWp Solar PV System
38
- - **X** W Aiko Panels
39
- - **X** kW Hybrid Inverter
40
- - **Online Monitoring, DNO application, Warranty, and MCS certification**
41
- - Available **with or without battery storage**.
42
-
43
- #### **2. Battery Storage**
44
- - Certified **Fox ESS Elite Installer**, ensuring top performance and reliability.
45
- - Stores excess solar energy for use at night or during low sunlight hours.
46
-
47
- #### **3. EV Charging Solutions**
48
- - Install home and workplace **EV chargers**.
49
- - Compatible with **all Type-2 electric vehicles**.
50
- - Includes a dedicated app for full control over charging.
51
-
52
- #### **4. Electrical Services**
53
- - Professional and reliable services, including:
54
- - **Rewiring, consumer unit replacement, additional power points, and more.**
55
-
56
- ----------
57
-
58
- ### **Why Choose All Solar Works?**
59
- **Certified Fox ESS Elite Installer** – Ensures optimal battery storage performance.
60
- **Customizable Solar Solutions** – Tailored to individual energy needs.
61
- **Energy Independence** – Reduce reliance on the grid and lower bills.
62
- **Long-Term Savings** – Financially beneficial with eco-friendly advantages.
63
-
64
- ----------
65
-
66
- ### **Company Information**
67
- **Company Name:** All Solar Works
68
- **Location:** Edgehill Close, Worthing, West Sussex, BN XX
69
- **Contact:** info@allsolarworks.com | +44 XXX XXXX
70
- **Operating Hours:** Monday – Friday (9 AM – 5 PM), Saturday (10 AM – 2 PM)
71
-
72
- ----------
73
-
74
- Use this format and structure when extracting the content from the website. Ensure the final output is clean, structured, and easy to understand.
75
-
76
- ----------
77
-
78
- **Company Information:**
79
- {company_information}
80
-
81
- """)
82
-
83
-
84
- def company_content(llm, state):
85
- url = state["url"]
86
- if sys.platform == "win32":
87
- asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
88
- content = asyncio.run(marketing_crawling(url))
89
- prompt = company_prompt_template.invoke({"company_information": content})
90
- response = llm.invoke(prompt)
91
- print(response.content)
92
- return {"company_information": response.content}
 
 
 
 
 
 
 
 
 
 
93
 
 
1
+ import sys
2
+ import asyncio
3
+ from langchain_core.prompts import PromptTemplate
4
+
5
+ from crawl import marketing_crawling
6
+
7
+
8
+ import subprocess
9
+
10
+ # Install Playwright browsers
11
+ try:
12
+ subprocess.run(["playwright", "install", "--with-deps"], check=True)
13
+ print("Playwright browsers installed successfully.")
14
+ except subprocess.CalledProcessError as e:
15
+ print(f"Error installing Playwright browsers: {e}")
16
+
17
+
18
+ company_prompt_template = PromptTemplate.from_template("""
19
+ # Task
20
+ This is the scraped content from the company website. Read this content and extract the key information in an easy-to-read, professional format.
21
+
22
+ #**Instructions:**
23
+ - Focus on the most important details and present them in a structured, clear format.
24
+ - Follow the example below for formatting and style.
25
+ - Organize the content into clear sections such as:
26
+ - **About the Company**
27
+ - **Services Offered** (with sub-sections for each service)
28
+ - **Why Choose the Company** (highlight unique selling points and certifications)
29
+ - **Company Information** (contact details, address, and other relevant details)
30
+ - Avoid irrelevant details, redundant information, and generic text.
31
+ - Use professional, concise language that is easy to understand.
32
+ - Ensure consistency in formatting and tone.
33
+
34
+ #**Example:**
35
+
36
+ #### **About All Solar Works**
37
+ All Solar Works specializes in **solar panels, battery storage, EV chargers, and electrical services** across Sussex, UK. They offer expert installation and high-quality solutions to help customers save money on energy bills while reducing their carbon footprint.
38
+
39
+ ----------
40
+
41
+ ### **Services Offered**
42
+
43
+ #### **1. Solar Panels**
44
+ - Install various solar panel systems to fit different budgets.
45
+ - Helps customers reduce bills and enjoy long-term savings.
46
+ - **Complete Solar Panel System Package includes:**
47
+ - **X** kWp Solar PV System
48
+ - **X** W Aiko Panels
49
+ - **X** kW Hybrid Inverter
50
+ - **Online Monitoring, DNO application, Warranty, and MCS certification**
51
+ - Available **with or without battery storage**.
52
+
53
+ #### **2. Battery Storage**
54
+ - Certified **Fox ESS Elite Installer**, ensuring top performance and reliability.
55
+ - Stores excess solar energy for use at night or during low sunlight hours.
56
+
57
+ #### **3. EV Charging Solutions**
58
+ - Install home and workplace **EV chargers**.
59
+ - Compatible with **all Type-2 electric vehicles**.
60
+ - Includes a dedicated app for full control over charging.
61
+
62
+ #### **4. Electrical Services**
63
+ - Professional and reliable services, including:
64
+ - **Rewiring, consumer unit replacement, additional power points, and more.**
65
+
66
+ ----------
67
+
68
+ ### **Why Choose All Solar Works?**
69
+ **Certified Fox ESS Elite Installer** – Ensures optimal battery storage performance.
70
+ **Customizable Solar Solutions** – Tailored to individual energy needs.
71
+ **Energy Independence** – Reduce reliance on the grid and lower bills.
72
+ **Long-Term Savings** – Financially beneficial with eco-friendly advantages.
73
+
74
+ ----------
75
+
76
+ ### **Company Information**
77
+ **Company Name:** All Solar Works
78
+ **Location:** Edgehill Close, Worthing, West Sussex, BN XX
79
+ **Contact:** info@allsolarworks.com | +44 XXX XXXX
80
+ **Operating Hours:** Monday – Friday (9 AM – 5 PM), Saturday (10 AM – 2 PM)
81
+
82
+ ----------
83
+
84
+ Use this format and structure when extracting the content from the website. Ensure the final output is clean, structured, and easy to understand.
85
+
86
+ ----------
87
+
88
+ **Company Information:**
89
+ {company_information}
90
+
91
+ """)
92
+
93
+
94
+ def company_content(llm, state):
95
+ url = state["url"]
96
+ if sys.platform == "win32":
97
+ asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
98
+ content = asyncio.run(marketing_crawling(url))
99
+ prompt = company_prompt_template.invoke({"company_information": content})
100
+ response = llm.invoke(prompt)
101
+ print(response.content)
102
+ return {"company_information": response.content}
103