Houzeric commited on
Commit
77c658d
·
verified ·
1 Parent(s): 11d8dcb

Upload 29 files

Browse files
README.md CHANGED
@@ -1,14 +1,56 @@
1
  ---
2
  title: WebpageCreator
3
- emoji: 🐨
4
- colorFrom: green
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.33.0
8
  app_file: app.py
9
  pinned: false
10
- license: apache-2.0
11
- short_description: AI-based tool that generates a complete, responsive website.
 
12
  ---
13
 
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: WebpageCreator
3
+ emoji: 👀
4
+ colorFrom: gray
5
+ colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 5.32.1
8
  app_file: app.py
9
  pinned: false
10
+ license: unknown
11
+ short_description: Build and preview custom websites with agent.
12
+ tags: [agent-demo-track]
13
  ---
14
 
15
+ # 🌐 WebpageCreator AI-Powered Website Generator
16
+
17
+ **WebpageCreator** is an AI-based tool that generates a complete, responsive website from a simple text brief. Customize your brand colors, language, and company name — and the agent will generate professional HTML code section by section, live in your browser. ⚡
18
+
19
+ ## 🎥 Demo Video
20
+
21
+ ▶️ [Watch the demo](https://youtu.be/Hyovc5FYOYo)
22
+
23
+ ## ✨ Features
24
+
25
+ - 🏷 **Company Name** input for personalized branding
26
+ - 📝 **Brief field** to describe your business, product, or service
27
+ - 🎨 **Primary & Secondary Colors** via Color Pickers
28
+ - 🌍 **Multilingual Output**: French, English, Spanish, German
29
+ - ⚡ **Real-time Preview** in an iframe while the site is building
30
+ - 🧠 Powered by an autonomous agent (HektoreAgent)
31
+
32
+ ## 🧩 Sections Automatically Generated
33
+
34
+ - Header with logo and gradient top bar
35
+ - Hero section with headline and CTA
36
+ - “Trusted by” logos section
37
+ - Services cards (with icons, titles, and text)
38
+ - About / Mission section
39
+ - Testimonials carousel
40
+ - Call-to-Action section
41
+ - Newsletter subscription form
42
+ - Footer with navigation, contact, and social links
43
+
44
+ ## 🔧 Tech Stack
45
+
46
+ - **Gradio** – frontend UI
47
+ - **smolagents** – lightweight agent orchestration
48
+ - **Selenium** – for icon name scraping
49
+ - **Tailwind CSS**, **Alpine.js**, **Swiper.js** – for responsive UI
50
+ - **Phosphor Icons** – beautiful open-source icon set
51
+
52
+ ## 🖥️ Run Locally
53
+
54
+ ```bash
55
+ pip install -r requirements.txt
56
+ python app.py
agent.py ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import CodeAgent, Tool
2
+ import os
3
+ import time
4
+ import requests
5
+ import re
6
+ from typing import Dict, List, Optional, Any
7
+ from smolagents.models import Model
8
+ from smolagents.default_tools import DuckDuckGoSearchTool, FinalAnswerTool
9
+ from dotenv import load_dotenv
10
+ import os
11
+
12
+ from myTools.ExtractWikipediaSection import ExtractWikipediaSection
13
+ from myTools.ExtractWebContentWithSelenium import ExtractWebContentWithSelenium
14
+ from myTools.GetPlaceholderImageTool import GetPlaceholderImageTool
15
+ from myTools.GetSVG import GetSVG
16
+ from myTools.GetSVGList import GetSVGList
17
+ from myTools.GetLogo import GetLogo
18
+
19
+ load_dotenv()
20
+ api_key = os.getenv("MistralApiKey")
21
+
22
+
23
+
24
+ class ChatMessage:
25
+ def __init__(self, role: str, content: str):
26
+ self.role = role
27
+ self.content = content
28
+ self.raw = None
29
+
30
+ @classmethod
31
+ def from_dict(cls, message_dict: Dict[str, str]) -> 'ChatMessage':
32
+ return cls(role=message_dict['role'], content=message_dict['content'])
33
+
34
+ def __repr__(self):
35
+ return f"ChatMessage(role={self.role}, content={self.content})"
36
+
37
+
38
+
39
+ class MistralClient:
40
+ def __init__(self, api_key: str, api_base: str = "https://api.mistral.ai"):
41
+ self.api_key = api_key
42
+ self.api_base = api_base
43
+
44
+ def generate(self, model_id: str, messages: List[Dict[str, str]], **kwargs):
45
+ url = f"{self.api_base}/v1/chat/completions"
46
+ headers = {
47
+ "Authorization": f"Bearer {self.api_key}",
48
+ "Content-Type": "application/json"
49
+ }
50
+ data = {
51
+ "model": model_id,
52
+ "messages": messages,
53
+ "temperature": 0.7,
54
+ "max_tokens": 4096,
55
+ **kwargs
56
+ }
57
+ retries = 5
58
+ backoff = 2.0
59
+ for attempt in range(1, retries + 1):
60
+ response = requests.post(url, headers=headers, json=data)
61
+
62
+ if response.status_code == 429:
63
+ print(f"[429] Trop de requêtes - tentative {attempt}/{retries}, attente {backoff}s...")
64
+ time.sleep(backoff)
65
+ backoff *= 2
66
+ continue
67
+
68
+ try:
69
+ response.raise_for_status()
70
+ return response.json()
71
+ except requests.exceptions.HTTPError as e:
72
+ print(f"[ERREUR] HTTP {response.status_code}: {e}")
73
+ raise e
74
+
75
+ raise RuntimeError(f"Échec après {retries} tentatives (429 ou autres erreurs)")
76
+
77
+
78
+
79
+ class MistralApiModel(Model):
80
+ """A class to interact with Mistral's API for language model interaction."""
81
+
82
+ def __init__(
83
+ self,
84
+ model_id: str,
85
+ api_key: Optional[str] = None,
86
+ api_base: Optional[str] = None,
87
+ **kwargs,
88
+ ):
89
+ super().__init__(**kwargs)
90
+ self.model_id = model_id
91
+ self.api_key = api_key
92
+ self.api_base = api_base or "https://api.mistral.ai"
93
+ self.client = MistralClient(api_key=self.api_key, api_base=self.api_base)
94
+
95
+ def generate(
96
+ self,
97
+ messages: List[Dict[str, str]],
98
+ **kwargs,
99
+ ) -> ChatMessage:
100
+ return self.__call__(messages=messages, **kwargs)
101
+
102
+ def __call__(
103
+ self,
104
+ messages: List[Dict[str, str]],
105
+ stop_sequences: Optional[List[str]] = None,
106
+ **kwargs,
107
+ ) -> ChatMessage:
108
+ completion_kwargs = self._prepare_completion_kwargs(
109
+ messages=messages,
110
+ stop_sequences=stop_sequences,
111
+ **kwargs,
112
+ )
113
+
114
+ response = self.client.generate(model_id=self.model_id, **completion_kwargs)
115
+
116
+
117
+ message = ChatMessage.from_dict(response['choices'][0]['message'])
118
+ message.raw = response
119
+ usage = response.get('usage', {})
120
+ message.token_usage = type('TokenUsage', (), {
121
+ "input_tokens": usage.get("prompt_tokens", 0),
122
+ "output_tokens": usage.get("completion_tokens", 0),
123
+ "total_tokens": usage.get("total_tokens", 0)
124
+ })()
125
+ return message
126
+
127
+ class HektoreAgent:
128
+ def __init__(self):
129
+ print("Agent initialized.")
130
+
131
+ def __call__(self, section: str, brief: str, colorOne: str, colorTwo: str, language: str, company_name: str, current_html: str = "", additional_args: dict = {}) -> str:
132
+
133
+ print(f"Agent received brief : {brief}...")
134
+ print(f"Additional args received : {additional_args}...")
135
+
136
+ all_tools = [
137
+ GetPlaceholderImageTool(),
138
+ ExtractWebContentWithSelenium(),
139
+ DuckDuckGoSearchTool(),
140
+ GetSVG(),
141
+ GetSVGList(),
142
+ GetLogo(),
143
+ FinalAnswerTool()
144
+ ]
145
+ marketing_tools = [
146
+ ExtractWebContentWithSelenium(),
147
+ DuckDuckGoSearchTool(),
148
+ FinalAnswerTool()
149
+ ]
150
+
151
+ model = MistralApiModel(
152
+ model_id="codestral-2501",
153
+ api_base="https://api.mistral.ai",
154
+ api_key=api_key
155
+ )
156
+
157
+ marketing_agent = CodeAgent(
158
+ model=model,
159
+ name="MarketingSEOExpert",
160
+ description="Specialist in marketing web and SEO, generate powerful content with impact. Can't generate HTML, juste generate raw text.",
161
+ tools=marketing_tools,
162
+ additional_authorized_imports=[
163
+ "geopandas",
164
+ "plotly",
165
+ "shapely",
166
+ "json",
167
+ "pandas",
168
+ "numpy",
169
+ "time",
170
+ "openpyxl",
171
+ "pdfminer",
172
+ "pdfminer.six",
173
+ "PyPDF2",
174
+ "io",
175
+ "open",
176
+ "librosa",
177
+ "bs4",
178
+ "os",
179
+ "builtins.open",
180
+ "builtins.write",
181
+ "PyGithub",
182
+ "requests"
183
+ ],
184
+ verbosity_level=2,
185
+ #final_answer_checks=[check_reasoning],
186
+ max_steps=15,
187
+ )
188
+
189
+ manager_agent = CodeAgent(
190
+ model=model,
191
+ tools=all_tools,
192
+ #managed_agents=[marketing_agent],
193
+ additional_authorized_imports=[
194
+ "geopandas",
195
+ "plotly",
196
+ "shapely",
197
+ "json",
198
+ "pandas",
199
+ "numpy",
200
+ "time",
201
+ "openpyxl",
202
+ "pdfminer",
203
+ "pdfminer.six",
204
+ "PyPDF2",
205
+ "io",
206
+ "open",
207
+ "librosa",
208
+ "bs4",
209
+ "os",
210
+ "builtins.open",
211
+ "builtins.write",
212
+ "PyGithub",
213
+ "requests"
214
+ ],
215
+ planning_interval=10,
216
+ verbosity_level=2,
217
+ #final_answer_checks=[check_reasoning],
218
+ max_steps=100,
219
+ )
220
+
221
+
222
+
223
+ prompt = f"""
224
+ You are a professional AI website generator.
225
+ Your job is to build a rich, modern, and impressive HTML + TailwindCSS, using semantic HTML5 and responsive design.
226
+ You will build the website section by section. Only output the HTML markup for the current section.
227
+ The content text must be awesome and very very rich.
228
+
229
+ ⚠️ Do not output any <html>, <head>, <body>, or <!DOCTYPE> tags.
230
+ ⚠️ Only write the core section content.
231
+ The name or the company is : {company_name}
232
+ The website is about : {brief}
233
+ Language of the website : {language}
234
+ You are encouraged to use advanced design elements and modern layout ideas.
235
+ We need a lot of text in each section. All text must be SEO compliant. We need Call to action.
236
+ Develop this section :
237
+
238
+ {section}
239
+
240
+
241
+
242
+
243
+ **Styling and layout**:
244
+ - Use Tailwind utility classes
245
+ - Use Tailwind's `container`, `grid`, `flex`, `gap`, `rounded`, `shadow`, `text-*`, `bg-*` utilities
246
+ - Add responsive breakpoints (`sm:`, `md:`, `lg:`) where needed
247
+ - Add hover/focus/transition effects for buttons and cards
248
+ - Add a fixed header if relevant
249
+ - The CTA text must be impactful and very short
250
+ - Use these 2 colors : Primary : {colorOne} and secondary : {colorTwo}
251
+ - Don't use join in python to build multiple block in html section
252
+ - Use TailwindCSS via CDN:
253
+ `<script src="https://cdn.tailwindcss.com"></script>`
254
+
255
+ **Extras (encouraged but optional)**:
256
+ - Use Alpine.js for interactions (mobile nav, carousel, etc.)
257
+ - Add animation classes (`transition`, `duration-300`, `ease-in-out`)
258
+ - Use SVG separators or background patterns
259
+ - Include meta tags for SEO, accessibility attributes, and semantic labels
260
+ - Use real picture, no lorem ipsum.
261
+
262
+ You may use Alpine.js for dynamic UI behavior (e.g., toggles, mobile menus, tabs).
263
+ Load it via CDN:
264
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script>
265
+
266
+ You may use Swiper.js for testimonials or logo sliders:
267
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" />
268
+ <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script>
269
+
270
+ You may use animate.css (Animatation) for smooth animations :
271
+ <link
272
+ rel="stylesheet"
273
+ href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
274
+ />
275
+
276
+ You may use Micromodal.js (Modal) for simple modal :
277
+ <script src="https://unpkg.com/micromodal/dist/micromodal.min.js"></script>
278
+
279
+ The page should look ready to present to enterprise clients. Do not oversimplify. No `Lorem ipsum`. Write realistic, sharp content. Only output the HTML for this section. Do not include <html>, <head>, or <body>. Do not include DOCTYPE.
280
+ """
281
+
282
+ result = manager_agent.run(task=prompt, additional_args=additional_args)
283
+ return result
myTools/ExtractWebContentWithSelenium.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.options import Options
4
+ from selenium.webdriver.chrome.service import Service as ChromeService
5
+ from webdriver_manager.chrome import ChromeDriverManager
6
+ from markdownify import markdownify as md
7
+
8
+ class ExtractWebContentWithSelenium(Tool):
9
+ name = "extract_web_content_selenium"
10
+ description = "Visit a webpage and extract the full HTML content of a web page."
11
+
12
+ inputs = {
13
+ "url": {
14
+ "type": "string",
15
+ "description": "URL of the page to load"
16
+ }
17
+ }
18
+
19
+ output_type = "string"
20
+
21
+ def forward(self, url: str) -> str:
22
+ chrome_options = Options()
23
+ chrome_options.add_argument("--headless")
24
+ chrome_options.add_argument("--no-sandbox")
25
+ chrome_options.add_argument("--disable-dev-shm-usage")
26
+ chrome_options.add_argument(
27
+ "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
28
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
29
+ "Chrome/114.0.0.0 Safari/537.36"
30
+ )
31
+
32
+ # Installe automatiquement ChromeDriver
33
+ driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
34
+
35
+ try:
36
+ driver.get(url)
37
+ page_content = driver.page_source
38
+ markdown = md(page_content, heading_style="ATX")
39
+ finally:
40
+ driver.quit()
41
+
42
+ return markdown
myTools/ExtractWikipediaSection.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ import requests
3
+ import re
4
+ from markdownify import markdownify as md
5
+
6
+ class ExtractWikipediaSection(Tool):
7
+ name = "extract_wikipedia_section"
8
+ description = "Extracts a specific section from a Wikipedia page in Markdown format."
9
+
10
+ inputs = {
11
+ "url": {
12
+ "type": "string",
13
+ "description": "URL of the Wikipedia page"
14
+ },
15
+ "section": {
16
+ "type": "string",
17
+ "description": "Title of the section to extract"
18
+ },
19
+ }
20
+
21
+ output_type = "string"
22
+
23
+ def forward(self, url: str, section: str) -> str:
24
+ headers = {
25
+ "User-Agent": "Mozilla/5.0 (compatible; WebScraper/1.0; +https://example.com/bot)"
26
+ }
27
+
28
+ try:
29
+ response = requests.get(url, headers=headers, timeout=10)
30
+ response.raise_for_status()
31
+ except Exception as e:
32
+ raise RuntimeError(f"Failed to fetch page: {e}")
33
+
34
+ markdown = md(response.text, heading_style="ATX")
35
+
36
+ # RegEx pour détecter la section markdown
37
+ pattern = rf"^##+\s*{re.escape(section)}\s*$(.*?)^##+"
38
+ match = re.search(pattern, markdown, re.DOTALL | re.MULTILINE)
39
+ if match:
40
+ return match.group(1).strip()
41
+ else:
42
+ return f"❌ Section '{section}' not found on page."
myTools/GetLogo.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.options import Options
4
+ from selenium.webdriver.chrome.service import Service as ChromeService
5
+ from webdriver_manager.chrome import ChromeDriverManager
6
+ from markdownify import markdownify as md
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+ from selenium.webdriver.support import expected_conditions as EC
9
+ from selenium.webdriver.common.by import By
10
+ import random
11
+
12
+ class GetLogo(Tool):
13
+ name = "get_logo"
14
+ description = "Lookup and search for a logo and generate the SVG code"
15
+
16
+ inputs = {
17
+
18
+ }
19
+
20
+ output_type = "string"
21
+
22
+ def forward(self) -> str:
23
+ chrome_options = Options()
24
+ chrome_options.add_argument("--headless")
25
+ chrome_options.add_argument("--no-sandbox")
26
+ chrome_options.add_argument("--disable-dev-shm-usage")
27
+ chrome_options.add_argument(
28
+ "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
29
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
30
+ "Chrome/114.0.0.0 Safari/537.36"
31
+ )
32
+
33
+ driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
34
+
35
+ try:
36
+ url = f"https://logoipsum.com/"
37
+ driver.get(url)
38
+ wait = WebDriverWait(driver, 10)
39
+ buttons = wait.until(
40
+ EC.presence_of_all_elements_located((By.CSS_SELECTOR, "div.artwork"))
41
+ )
42
+ if not buttons:
43
+ return "Aucun résultat trouvé."
44
+
45
+ random_logo = random.choice(buttons)
46
+ svg_element = random_logo.find_element(By.TAG_NAME, "svg")
47
+ svg_code = svg_element.get_attribute("outerHTML")
48
+
49
+ return svg_code
50
+ finally:
51
+ driver.quit()
myTools/GetPlaceholderImageTool.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ import os
3
+ import requests
4
+
5
+ class GetPlaceholderImageTool(Tool):
6
+ name = "get_placeholder_image_tool"
7
+ description = "Get placeholder image for website with specific size"
8
+
9
+ inputs = {
10
+ "height": {"type": "integer", "description": "The height of the placeholder"},
11
+ "width": {"type": "integer", "description": "The width of the placeholder"},
12
+ }
13
+
14
+ output_type = "string"
15
+
16
+ def forward(self, height: int, width: int) -> str:
17
+
18
+ return f"https://placehold.co/{width}x{height}"
myTools/GetSVG.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.options import Options
4
+ from selenium.webdriver.chrome.service import Service as ChromeService
5
+ from webdriver_manager.chrome import ChromeDriverManager
6
+ from markdownify import markdownify as md
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+ from selenium.webdriver.support import expected_conditions as EC
9
+ from selenium.webdriver.common.by import By
10
+
11
+ class GetSVG(Tool):
12
+ name = "get_svg"
13
+ description = "Lookup and search for an icon and generate the SVG code"
14
+
15
+ inputs = {
16
+ "request": {
17
+ "type": "string",
18
+ "description": "The description of the svg from GetSVGList Tool"
19
+ }
20
+ }
21
+
22
+ output_type = "string"
23
+
24
+ def forward(self, request: str) -> str:
25
+ chrome_options = Options()
26
+ chrome_options.add_argument("--headless")
27
+ chrome_options.add_argument("--no-sandbox")
28
+ chrome_options.add_argument("--disable-dev-shm-usage")
29
+ chrome_options.add_argument(
30
+ "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
31
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
32
+ "Chrome/114.0.0.0 Safari/537.36"
33
+ )
34
+
35
+ driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
36
+
37
+ try:
38
+ url = f"https://phosphoricons.com/?q={request}"
39
+ driver.get(url)
40
+ wait = WebDriverWait(driver, 10)
41
+ buttons = wait.until(
42
+ EC.presence_of_all_elements_located((By.CSS_SELECTOR, "button.grid-item"))
43
+ )
44
+ if not buttons:
45
+ return "Aucun résultat trouvé."
46
+
47
+ first_icon = buttons[0]
48
+ svg_element = first_icon.find_element(By.TAG_NAME, "svg")
49
+ svg_code = svg_element.get_attribute("outerHTML")
50
+
51
+ return svg_code
52
+ finally:
53
+ driver.quit()
myTools/GetSVGList.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+ from selenium import webdriver
3
+ from selenium.webdriver.chrome.options import Options
4
+ from selenium.webdriver.chrome.service import Service as ChromeService
5
+ from webdriver_manager.chrome import ChromeDriverManager
6
+ from markdownify import markdownify as md
7
+ from selenium.webdriver.support.ui import WebDriverWait
8
+ from selenium.webdriver.support import expected_conditions as EC
9
+ from selenium.webdriver.common.by import By
10
+
11
+ class GetSVGList(Tool):
12
+ name = "get_svg_list"
13
+ description = "Get list of svg available to generate it with GetSVG Tool"
14
+
15
+ inputs = {
16
+
17
+ }
18
+
19
+ output_type = "array"
20
+
21
+ def forward(self) -> str:
22
+ chrome_options = Options()
23
+ chrome_options.add_argument("--headless")
24
+ chrome_options.add_argument("--no-sandbox")
25
+ chrome_options.add_argument("--disable-dev-shm-usage")
26
+ chrome_options.add_argument(
27
+ "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
28
+ "AppleWebKit/537.36 (KHTML, like Gecko) "
29
+ "Chrome/114.0.0.0 Safari/537.36"
30
+ )
31
+
32
+ driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
33
+
34
+ try:
35
+ url = "https://phosphoricons.com/"
36
+ driver.get(url)
37
+
38
+ wait = WebDriverWait(driver, 10)
39
+ name_elements = wait.until(
40
+ EC.presence_of_all_elements_located((By.CSS_SELECTOR, "span.name"))
41
+ )
42
+
43
+ icon_names = [el.text.strip() for el in name_elements if el.text.strip()]
44
+ return icon_names
45
+ if not icon_names:
46
+ return "Aucun nom d'icône trouvé."
47
+
48
+ return "\n".join(icon_names)
49
+ finally:
50
+ driver.quit()
myTools/__init__.py ADDED
File without changes
myTools/__pycache__/CountObjectsInYoutubeWithYOLO.cpython-310.pyc ADDED
Binary file (4.67 kB). View file
 
myTools/__pycache__/CreateDirectoryTool.cpython-310.pyc ADDED
Binary file (880 Bytes). View file
 
myTools/__pycache__/DeleteFileTool.cpython-310.pyc ADDED
Binary file (852 Bytes). View file
 
myTools/__pycache__/DownloadFileTool.cpython-310.pyc ADDED
Binary file (1.31 kB). View file
 
myTools/__pycache__/DownloadYoutubeVideo.cpython-310.pyc ADDED
Binary file (1.76 kB). View file
 
myTools/__pycache__/ExtractWebContentWithPuppeteer.cpython-310.pyc ADDED
Binary file (1.52 kB). View file
 
myTools/__pycache__/ExtractWebContentWithSelenium.cpython-310.pyc ADDED
Binary file (1.56 kB). View file
 
myTools/__pycache__/ExtractWikipediaSection.cpython-310.pyc ADDED
Binary file (1.47 kB). View file
 
myTools/__pycache__/FixPythonCode.cpython-310.pyc ADDED
Binary file (1.55 kB). View file
 
myTools/__pycache__/GetLogo.cpython-310.pyc ADDED
Binary file (1.9 kB). View file
 
myTools/__pycache__/GetPlaceholderImageTool.cpython-310.pyc ADDED
Binary file (903 Bytes). View file
 
myTools/__pycache__/GetSVG.cpython-310.pyc ADDED
Binary file (1.98 kB). View file
 
myTools/__pycache__/GetSVGList.cpython-310.pyc ADDED
Binary file (1.91 kB). View file
 
myTools/__pycache__/QwenImageAnalyzer.cpython-310.pyc ADDED
Binary file (3.36 kB). View file
 
myTools/__pycache__/ReadFileTool.cpython-310.pyc ADDED
Binary file (881 Bytes). View file
 
myTools/__pycache__/TranscribeAudioOVH.cpython-310.pyc ADDED
Binary file (3.57 kB). View file
 
myTools/__pycache__/WriteFileTool.cpython-310.pyc ADDED
Binary file (1.03 kB). View file
 
myTools/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (144 Bytes). View file
 
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio
2
+ smolagents
3
+ markdownify
4
+ selenium
5
+ webdriver-manager
6
+ duckduckgo-search