USER commited on
Commit
f9385df
·
0 Parent(s):

add project

Browse files
Files changed (5) hide show
  1. .gradio/flagged/dataset1.csv +2 -0
  2. README.md +13 -0
  3. analyserWeb +1 -0
  4. app.py +119 -0
  5. requirements.txt +4 -0
.gradio/flagged/dataset1.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ URL à analyser,output,timestamp
2
+ www.bocs-primature.sn,"url='https://bocs-primature.sn' title=""Page d'accueil - Bureau Opérationnel de Coordination et de Suivi -"" description='Site officiel du Bureau Opérationnel de Coordination et de Suivi des Projets et Programmes au Sénégal (BOCS).' features=['Présentation de la vision Sénégal 2050', 'Présentation de la mission et des axes stratégiques', 'Mot du Directeur Général', 'Actualités illustrées', 'Accès aux documents officiels (décret, vision)', 'Présentation des partenaires institutionnels et au développement'] content_sections=[ContentSection(heading='Vision et mission', content='Le BOCS vise à concrétiser les ambitions de la Vision Sénégal 2050, sous l’autorité du Premier Ministre. Sa mission : coordonner, suivre, accélérer et garantir la mise en œuvre des projets et réformes structurants du pays.'), ContentSection(heading='Axes d’intervention', content='L’agenda national de transformation repose sur 4 axes : économie compétitive, capital humain et équité sociale, aménagement et développement durables, bonne gouvernance et engagement africain. Chacun de ces axes est brièvement explicité.'), ContentSection(heading='Mot du Directeur Général', content='Le Directeur valorise la transparence, l’action efficace, l’inclusion et l’excellence. Le rôle du BOCS est positionné comme catalyseur de transformation au Sénégal.'), ContentSection(heading='Actualités', content='Galerie d’actualités et illustrations des actions du BOCS (séances de travail, ateliers, partenariats, etc.).'), ContentSection(heading='Partenaires stratégiques et au développement', content='Logos et liens vers de nombreux partenaires institutionnels et techniques.')] links={'Vision Sénégal 2050': 'https://bocs-primature.sn/wp-content/uploads/2025/02/Vision-2050-Senegal-2050.pdf', 'Décret création BOCS': 'https://bocs-primature.sn/wp-content/uploads/2025/02/DECRET-n2024-3410-PORTANT-CREATION-ET-FIANT-LES-REGLES-DORGANISATION-ET-DE-FONCTIONNEMENT-DU-BOCS.pdf', 'Actualités': 'https://bocs-primature.sn/actualites/', 'À propos': 'https://bocs-primature.sn/a-propos/'} contact_info=None metadata={'language': 'fr-FR', 'generator': 'WordPress 6.8.1 / Elementor', 'twitter': '@BOCS_PP2050'} feedback=None",2025-05-25 14:55:43.276984
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: "Analyseur UX Web"
3
+ emoji: "🕵️"
4
+ colorFrom: "purple"
5
+ colorTo: "blue"
6
+ sdk: "gradio"
7
+ app_file: "app.py"
8
+ license: "mit"
9
+ ---
10
+
11
+ # Agent d’analyse UX des sites web
12
+
13
+ Ce Space utilise Firecrawl + GPT-4 pour analyser une page web selon des critères UX/UI comme la lisibilité, la navigation, la sécurité, etc.
analyserWeb ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 9241ea68081525e953ec19915105b466446334b1
app.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from textwrap import dedent
3
+ from typing import Dict, List, Optional
4
+
5
+ import gradio as gr
6
+ from dotenv import load_dotenv
7
+ from pydantic import BaseModel, Field
8
+ from agno.agent import Agent
9
+ from agno.models.openai import OpenAIChat
10
+ from agno.tools.firecrawl import FirecrawlTools
11
+
12
+ load_dotenv()
13
+
14
+ # Variables d’environnement depuis Hugging Face "Secrets"
15
+ os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
16
+ os.environ["FIRECRAWL_API_KEY"] = os.getenv("FIRECRAWL_API_KEY")
17
+
18
+ # Modèle de réponse structuré
19
+ class ContentSection(BaseModel):
20
+ heading: Optional[str] = Field(None, description="Section heading")
21
+ content: str = Field(..., description="Section content text")
22
+
23
+ class PageInformation(BaseModel):
24
+ url: str
25
+ title: str
26
+ description: Optional[str]
27
+ features: Optional[List[str]]
28
+ content_sections: Optional[List[ContentSection]]
29
+ links: Optional[Dict[str, str]]
30
+ contact_info: Optional[Dict[str, str]]
31
+ metadata: Optional[Dict[str, str]]
32
+ feedback: Optional[str]
33
+
34
+ # Définition de l'agent
35
+ agent = Agent(
36
+ model=OpenAIChat(id="gpt-4.1"),
37
+ tools=[FirecrawlTools(scrape=True, crawl=False)],
38
+ instructions=dedent("""
39
+ Analysez la page fournie et extrayez les informations clés en respectant ce format :
40
+ - Lisibilité
41
+ - Ergonomie / navigation
42
+ - Design
43
+ - Sécurité
44
+ - Pertinence des rubriques
45
+ - Améliorations à suggérer
46
+ Soyez clair et synthétique. Résumez les parties longues.
47
+ """).strip(),
48
+ response_model=PageInformation,
49
+ )
50
+
51
+ # Fonction utilisée par Gradio
52
+ def analyser_page(url: str):
53
+ prompt = (
54
+ f"Analyse la page {url} selon les critères suivants : lisibilité, ergonomie/navigation, "
55
+ "design, sécurité, pertinence des rubriques, améliorations à suggérer. Résume et structure la réponse."
56
+ )
57
+ result = agent.run(prompt)
58
+ print("DEBUG TYPE:", type(result))
59
+ print("DEBUG VALUE:", result)
60
+
61
+ # Utilise le vrai contenu structuré
62
+ content = getattr(result, "content", None)
63
+ if hasattr(content, "dict") and callable(content.dict):
64
+ data = content.dict()
65
+ elif isinstance(content, dict):
66
+ data = content
67
+ elif isinstance(content, str):
68
+ return f"Réponse brute :\n\n{content}"
69
+ else:
70
+ return f"Type inattendu pour content : {type(content)}\nValeur : {content}"
71
+
72
+ # Construction d'un markdown structuré
73
+ markdown = f"# Analyse de la page\n\n"
74
+ markdown += f"**URL :** {data.get('url', url)}\n\n"
75
+ if data.get("title"):
76
+ markdown += f"**Titre :** {data['title']}\n\n"
77
+ if data.get("description"):
78
+ markdown += f"**Description :** {data['description']}\n\n"
79
+ if data.get("features"):
80
+ markdown += "## Fonctionnalités\n"
81
+ for feat in data["features"]:
82
+ markdown += f"- {feat}\n"
83
+ markdown += "\n"
84
+ if data.get("content_sections"):
85
+ for section in data["content_sections"]:
86
+ if section.get("heading"):
87
+ markdown += f"## {section['heading']}\n"
88
+ markdown += f"{section['content']}\n\n"
89
+ if data.get("links"):
90
+ markdown += "## Liens\n"
91
+ for name, link in data["links"].items():
92
+ markdown += f"- [{name}]({link})\n"
93
+ markdown += "\n"
94
+ if data.get("contact_info"):
95
+ markdown += "## Contact\n"
96
+ for k, v in data["contact_info"].items():
97
+ markdown += f"- **{k}** : {v}\n"
98
+ markdown += "\n"
99
+ if data.get("metadata"):
100
+ markdown += "## Métadonnées\n"
101
+ for k, v in data["metadata"].items():
102
+ markdown += f"- **{k}** : {v}\n"
103
+ markdown += "\n"
104
+ if data.get("feedback"):
105
+ markdown += f"## Feedback\n{data['feedback']}\n"
106
+
107
+ return markdown
108
+
109
+ # Interface Gradio
110
+ demo = gr.Interface(
111
+ fn=analyser_page,
112
+ inputs=gr.Textbox(label="URL à analyser", placeholder="https://www.exemple.com"),
113
+ outputs=gr.Markdown(), # Affichage markdown structuré
114
+ title="🧠 Analyseur de Page Web",
115
+ description="Entrez une URL à analyser selon des critères UX/UI.",
116
+ )
117
+
118
+ if __name__ == "__main__":
119
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ python-dotenv
3
+ agno
4
+ openai