DinoFrog commited on
Commit
e5b4007
·
verified ·
1 Parent(s): 807c07d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +144 -95
app.py CHANGED
@@ -5,25 +5,26 @@ from huggingface_hub import InferenceClient
5
  import pandas as pd
6
  import os
7
  import nltk
8
- nltk.download('punkt_tab') # Changement de 'punkt' à 'punkt_tab'
 
9
  from nltk.tokenize import sent_tokenize
10
 
11
  HF_TOKEN = os.getenv("HF_TOKEN")
12
 
13
  # Fonction pour appeler l'API Zephyr avec des paramètres ajustés
14
- def call_zephyr_api(prompt, mode, hf_token=HF_TOKEN):
15
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=hf_token)
16
  try:
17
  if mode == "Rapide":
 
 
 
18
  max_new_tokens = 100
19
  temperature = 0.5
20
- elif mode == "Équilibré":
21
- max_new_tokens = 200
22
- temperature = 0.7
23
  else: # Précis
24
- max_new_tokens = 300
25
- temperature = 0.9
26
- response = client.text_generation(prompt, max_new_tokens=max_new_tokens, temperature=temperature)
27
  return response
28
  except Exception as e:
29
  raise gr.Error(f"❌ Erreur d'appel API Hugging Face : {str(e)}")
@@ -31,20 +32,14 @@ def call_zephyr_api(prompt, mode, hf_token=HF_TOKEN):
31
  # Chargement du modèle de sentiment pour analyser les réponses
32
  classifier = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")
33
 
34
- # Modèles de traduction
35
  translator_to_en = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
36
- translator_to_fr = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
 
37
 
38
- # Fonction pour traduire un texte long en le segmentant
39
  def safe_translate_to_fr(text, max_length=512):
40
- sentences = sent_tokenize(text)
41
- translated_sentences = []
42
-
43
- for sentence in sentences:
44
- translated = translator_to_fr(sentence, max_length=max_length)[0]['translation_text']
45
- translated_sentences.append(translated)
46
-
47
- return " ".join(translated_sentences)
48
 
49
  # Fonction pour suggérer le meilleur modèle
50
  def suggest_model(text):
@@ -60,20 +55,20 @@ def suggest_model(text):
60
  def create_sentiment_gauge(sentiment, score):
61
  score_percentage = score * 100
62
  if sentiment.lower() == "neutral":
63
- color = "gray"
64
  elif sentiment.lower() == "positive":
65
- color = "green"
66
  elif sentiment.lower() == "negative":
67
- color = "red"
68
  else:
69
- color = "gray"
70
 
71
  html = f"""
72
  <div style='width: 100%; max-width: 300px; margin: 10px 0;'>
73
- <div style='background-color: #e0e0e0; border-radius: 5px; height: 20px; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.2);'>
74
  <div style='background-color: {color}; width: {score_percentage}%; height: 100%; border-radius: 5px; transition: width 0.3s ease-in-out;'>
75
  </div>
76
- <span style='position: absolute; top: 0; left: 50%; transform: translateX(-50%); color: black; font-size: 12px; line-height: 20px; font-weight: 600;'>
77
  {score_percentage:.1f}%
78
  </span>
79
  </div>
@@ -84,48 +79,51 @@ def create_sentiment_gauge(sentiment, score):
84
  """
85
  return html
86
 
87
- # Fonction d'analyse
88
- def full_analysis(text, mode, detail_mode, count, history):
89
  if not text:
90
  return "Entrez une phrase.", "", "", 0, history, None, ""
91
 
 
 
 
92
  try:
93
  lang = detect(text)
94
  except:
95
  lang = "unknown"
96
 
97
  if lang != "en":
98
- text = translator_to_en(text, max_length=512)[0]['translation_text']
99
-
100
- prediction_prompt = f"""<|system|>
101
- You are a professional financial analyst AI with expertise in economic forecasting.
102
- </s>
103
- <|user|>
104
- Given the following question about a potential economic event: "{text}"
105
 
106
- Assume the event happens (e.g., if the question is "Will the Federal Reserve raise interest rates?", assume they do raise rates). What would be the likely economic impact of this event? Provide a concise explanation in one paragraph, focusing on the potential positive or negative effects on the economy. Do not repeat the question or the prompt in your response.
107
- </s>
108
- <|assistant|>"""
109
- prediction_response = call_zephyr_api(prediction_prompt, mode)
110
 
111
- result = classifier(prediction_response)[0]
 
 
112
  sentiment_output = f"Sentiment prédictif : {result['label']} (Score: {result['score']:.2f})"
113
  sentiment_gauge = create_sentiment_gauge(result['label'], result['score'])
114
 
 
 
 
115
  explanation_prompt = f"""<|system|>
116
- You are a professional financial analyst AI.
117
  </s>
118
  <|user|>
119
  Given the following question about a potential economic event: "{text}"
120
 
121
- Based on your prediction of the economic impact, which is: "{prediction_response}"
122
 
123
- The predicted sentiment for this impact is: {result['label'].lower()}.
124
-
125
- Now, explain why the sentiment is {result['label'].lower()} using a logical, fact-based explanation. Base your reasoning only on the predicted economic impact. Respond only with your financial analysis in one clear paragraph. Write in a clear and professional tone. {"Use simple language for a general audience." if detail_mode == "Normal" else "Use detailed financial terminology for an expert audience."}
126
  </s>
127
  <|assistant|>"""
128
- explanation_en = call_zephyr_api(explanation_prompt, mode)
 
 
 
 
129
  explanation_fr = safe_translate_to_fr(explanation_en, max_length=512)
130
 
131
  count += 1
@@ -137,7 +135,7 @@ Now, explain why the sentiment is {result['label'].lower()} using a logical, fac
137
  "Explication_FR": explanation_fr
138
  })
139
 
140
- return sentiment_output, explanation_en, explanation_fr, count, history, sentiment_gauge
141
 
142
  # Fonction pour télécharger historique CSV
143
  def download_history(history):
@@ -152,25 +150,39 @@ def download_history(history):
152
  def launch_app():
153
  custom_css = """
154
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
 
155
 
156
  body {
157
- background: linear-gradient(135deg, #1A1A2E 0%, #16213E 100%);
 
 
 
 
 
158
  color: #E0E0E0;
159
  font-family: 'Inter', sans-serif;
 
 
160
  }
161
 
162
  .gr-box {
163
- background: #2A2A4A !important;
164
  border-radius: 12px !important;
165
- border: 1px solid #3A3A5A !important;
166
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
167
- padding: 20px !important;
168
- margin: 10px 0 !important;
 
 
 
 
 
 
169
  }
170
 
171
  .gr-textbox, .gr-dropdown {
172
- background: #3A3A5A !important;
173
- border: 1px solid #4A4A7A !important;
174
  border-radius: 8px !important;
175
  color: #E0E0E0 !important;
176
  font-size: 16px !important;
@@ -180,38 +192,44 @@ def launch_app():
180
 
181
  .gr-textbox:focus, .gr-dropdown:focus {
182
  border-color: #FFD700 !important;
183
- box-shadow: 0 0 8px rgba(255, 215, 0, 0.3) !important;
184
  }
185
 
186
  .gr-button {
187
  background: linear-gradient(90deg, #FFD700 0%, #D4AF37 100%) !important;
188
- color: #1A1A2E !important;
189
  border: none !important;
190
  border-radius: 8px !important;
191
  padding: 12px 24px !important;
192
  font-weight: 600 !important;
193
  font-size: 16px !important;
194
  transition: transform 0.1s ease, box-shadow 0.3s ease !important;
195
- box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2) !important;
196
  }
197
 
198
  .gr-button:hover {
199
  transform: translateY(-2px) !important;
200
- box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4) !important;
201
  }
202
 
203
  h1, h2, h3 {
204
  color: #FFD700 !important;
205
  font-weight: 700 !important;
206
- text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
 
 
 
 
 
 
207
  }
208
 
209
  .gr-row {
210
- margin: 15px 0 !important;
211
  }
212
 
213
  .gr-column {
214
- padding: 10px !important;
215
  }
216
 
217
  label {
@@ -224,35 +242,35 @@ def launch_app():
224
  }
225
 
226
  label::before {
227
- content: '📊 ';
 
228
  margin-right: 8px;
229
  }
230
 
 
 
 
 
231
  .gr-html label::before {
232
- content: '📈 ';
233
  }
234
 
235
  .gr-file label::before {
236
- content: '💾 ';
237
  }
238
 
239
  .economic-question-section {
240
- background-image: url('https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?q=80&w=2070&auto=format&fit=crop');
241
- background-size: cover;
242
- background-position: center;
243
- background-repeat: no-repeat;
244
- background-color: rgba(42, 42, 74, 0.9);
245
- background-blend-mode: overlay;
246
  border-radius: 12px;
247
- padding: 20px;
248
  margin: 20px 0;
249
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
250
  }
251
 
252
  .economic-question-section .gr-textbox {
253
- background: rgba(58, 58, 90, 0.8) !important;
254
  border: 2px solid #FFD700 !important;
255
- box-shadow: 0 2px 8px rgba(255, 215, 0, 0.2) !important;
256
  font-size: 18px !important;
257
  padding: 15px !important;
258
  }
@@ -262,43 +280,73 @@ def launch_app():
262
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5) !important;
263
  }
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  .options-section {
266
  display: flex;
267
- justify-content: center;
268
- gap: 20px;
269
  margin-top: 15px;
270
  }
271
 
272
  .options-section .gr-dropdown {
273
  width: 200px !important;
274
  }
 
 
 
 
 
 
 
 
 
 
275
  """
276
 
277
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as iface:
278
  gr.Markdown("# 📈 Analyse Financière Premium + Explication IA", elem_id="title")
279
- gr.Markdown("Posez une question sur un événement économique. L'IA prédit l'impact et attribue un sentiment (positif, négatif, neutre).", elem_classes=["subtitle"])
280
 
281
  count = gr.State(0)
282
  history = gr.State([])
283
 
284
  with gr.Row(elem_classes=["economic-question-section"]):
285
- with gr.Column(scale=1, min_width=600):
286
- input_text = gr.Textbox(
287
- lines=4,
288
- placeholder="Entrez une question ici (ex. 'La Réserve fédérale augmentera-t-elle ses taux d'intérêt avant 2025 ?')",
289
- label="Question Économique"
290
- )
291
- with gr.Row(elem_classes=["options-section"]):
292
- mode_selector = gr.Dropdown(
293
- choices=["Rapide", "Équilibré", "Précis"],
294
- value="Équilibré",
295
- label="Mode (longueur et style de réponse)"
296
  )
297
- detail_mode_selector = gr.Dropdown(
298
- choices=["Normal", "Expert"],
299
- value="Normal",
300
- label="Niveau de détail (simplicité ou technicité)"
 
301
  )
 
 
 
 
 
 
 
 
 
 
 
302
 
303
  with gr.Row():
304
  analyze_btn = gr.Button("Analyser")
@@ -307,7 +355,8 @@ def launch_app():
307
 
308
  with gr.Row():
309
  with gr.Column(scale=1):
310
- sentiment_output = gr.Textbox(label="Résultat du Sentiment Prédictif")
 
311
  sentiment_gauge = gr.HTML(label="Jauge de Sentiment")
312
  with gr.Column(scale=2):
313
  with gr.Row():
@@ -321,7 +370,7 @@ def launch_app():
321
  analyze_btn.click(
322
  full_analysis,
323
  inputs=[input_text, mode_selector, detail_mode_selector, count, history],
324
- outputs=[sentiment_output, explanation_output_en, explanation_output_fr, count, history, sentiment_gauge]
325
  )
326
 
327
  download_btn.click(
@@ -330,7 +379,7 @@ def launch_app():
330
  outputs=[download_file]
331
  )
332
 
333
- iface.launch(share=True) # Ajout de share=True
334
 
335
  if __name__ == "__main__":
336
  launch_app()
 
5
  import pandas as pd
6
  import os
7
  import nltk
8
+ import asyncio
9
+ nltk.download('punkt_tab')
10
  from nltk.tokenize import sent_tokenize
11
 
12
  HF_TOKEN = os.getenv("HF_TOKEN")
13
 
14
  # Fonction pour appeler l'API Zephyr avec des paramètres ajustés
15
+ async def call_zephyr_api(prompt, mode, hf_token=HF_TOKEN):
16
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=hf_token)
17
  try:
18
  if mode == "Rapide":
19
+ max_new_tokens = 50
20
+ temperature = 0.3
21
+ elif mode == "Équilibré":
22
  max_new_tokens = 100
23
  temperature = 0.5
 
 
 
24
  else: # Précis
25
+ max_new_tokens = 150
26
+ temperature = 0.7
27
+ response = await asyncio.to_thread(client.text_generation, prompt, max_new_tokens=max_new_tokens, temperature=temperature)
28
  return response
29
  except Exception as e:
30
  raise gr.Error(f"❌ Erreur d'appel API Hugging Face : {str(e)}")
 
32
  # Chargement du modèle de sentiment pour analyser les réponses
33
  classifier = pipeline("sentiment-analysis", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")
34
 
35
+ # Modèles de traduction (optionnels, désactivés pour optimisation)
36
  translator_to_en = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
37
+ # Traduction en français désactivée pour l'instant
38
+ # translator_to_fr = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")
39
 
40
+ # Fonction pour traduire un texte long en le segmentant (désactivée pour l'instant)
41
  def safe_translate_to_fr(text, max_length=512):
42
+ return "Traduction désactivée pour l'instant pour améliorer la vitesse."
 
 
 
 
 
 
 
43
 
44
  # Fonction pour suggérer le meilleur modèle
45
  def suggest_model(text):
 
55
  def create_sentiment_gauge(sentiment, score):
56
  score_percentage = score * 100
57
  if sentiment.lower() == "neutral":
58
+ color = "#A9A9A9"
59
  elif sentiment.lower() == "positive":
60
+ color = "#2E8B57"
61
  elif sentiment.lower() == "negative":
62
+ color = "#DC143C"
63
  else:
64
+ color = "#A9A9A9"
65
 
66
  html = f"""
67
  <div style='width: 100%; max-width: 300px; margin: 10px 0;'>
68
+ <div style='background-color: #D3D3D3; border-radius: 5px; height: 20px; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.2);'>
69
  <div style='background-color: {color}; width: {score_percentage}%; height: 100%; border-radius: 5px; transition: width 0.3s ease-in-out;'>
70
  </div>
71
+ <span style='position: absolute; top: 0; left: 50%; transform: translateX(-50%); color: #0A1D37; font-size: 12px; line-height: 20px; font-weight: 600;'>
72
  {score_percentage:.1f}%
73
  </span>
74
  </div>
 
79
  """
80
  return html
81
 
82
+ # Fonction d'analyse corrigée
83
+ async def full_analysis(text, mode, detail_mode, count, history):
84
  if not text:
85
  return "Entrez une phrase.", "", "", 0, history, None, ""
86
 
87
+ # Message de progression
88
+ yield "Analyse en cours... (Étape 1 : Détection de la langue)", "", "", count, history, None, ""
89
+
90
  try:
91
  lang = detect(text)
92
  except:
93
  lang = "unknown"
94
 
95
  if lang != "en":
96
+ text_en = translator_to_en(text, max_length=512)[0]['translation_text']
97
+ else:
98
+ text_en = text
 
 
 
 
99
 
100
+ yield "Analyse en cours... (Étape 2 : Analyse du sentiment)", "", "", count, history, None, ""
 
 
 
101
 
102
+ # Analyse du sentiment avec RoBERTa sur le texte d'entrée
103
+ result = await asyncio.to_thread(classifier, text_en)
104
+ result = result[0]
105
  sentiment_output = f"Sentiment prédictif : {result['label']} (Score: {result['score']:.2f})"
106
  sentiment_gauge = create_sentiment_gauge(result['label'], result['score'])
107
 
108
+ yield "Analyse en cours... (Étape 3 : Explication de l'impact)", "", "", count, history, None, ""
109
+
110
+ # Appel à Zephyr pour expliquer l'impact basé sur le sentiment
111
  explanation_prompt = f"""<|system|>
112
+ You are a professional financial analyst AI with expertise in economic forecasting.
113
  </s>
114
  <|user|>
115
  Given the following question about a potential economic event: "{text}"
116
 
117
+ The predicted sentiment for this event is: {result['label'].lower()}.
118
 
119
+ Assume the event happens (e.g., if the question is "Will the Federal Reserve raise interest rates?", assume they do raise rates). Explain why this event would likely have a {result['label'].lower()} economic impact. Provide a concise explanation in one paragraph, focusing on the potential effects on the economy. {"Use simple language for a general audience." if detail_mode == "Normal" else "Use detailed financial terminology for an expert audience."}
 
 
120
  </s>
121
  <|assistant|>"""
122
+ explanation_en = await call_zephyr_api(explanation_prompt, mode)
123
+
124
+ yield "Analyse en cours... (Étape 4 : Traduction)", "", "", count, history, None, ""
125
+
126
+ # Traduction (désactivée pour l'instant)
127
  explanation_fr = safe_translate_to_fr(explanation_en, max_length=512)
128
 
129
  count += 1
 
135
  "Explication_FR": explanation_fr
136
  })
137
 
138
+ return sentiment_output, explanation_en, explanation_fr, count, history, sentiment_gauge, ""
139
 
140
  # Fonction pour télécharger historique CSV
141
  def download_history(history):
 
150
  def launch_app():
151
  custom_css = """
152
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');
153
+ @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
154
 
155
  body {
156
+ background-image: url('https://images.unsplash.com/photo-1593672715438-d88a70629abe?q=80&w=2070&auto=format&fit=crop');
157
+ background-size: cover;
158
+ background-position: center;
159
+ background-attachment: fixed;
160
+ background-color: #0A1D37;
161
+ background-blend-mode: overlay;
162
  color: #E0E0E0;
163
  font-family: 'Inter', sans-serif;
164
+ margin: 0;
165
+ padding: 20px;
166
  }
167
 
168
  .gr-box {
169
+ background: #1A3C34 !important;
170
  border-radius: 12px !important;
171
+ border: 1px solid #FFD700 !important;
172
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
173
+ padding: 25px !important;
174
+ margin: 15px 0 !important;
175
+ transition: transform 0.2s ease, box-shadow 0.3s ease !important;
176
+ }
177
+
178
+ .gr-box:hover {
179
+ transform: translateY(-3px) !important;
180
+ box-shadow: 0 8px 20px rgba(255, 215, 0, 0.3) !important;
181
  }
182
 
183
  .gr-textbox, .gr-dropdown {
184
+ background: #2E4A43 !important;
185
+ border: 1px solid #FFD700 !important;
186
  border-radius: 8px !important;
187
  color: #E0E0E0 !important;
188
  font-size: 16px !important;
 
192
 
193
  .gr-textbox:focus, .gr-dropdown:focus {
194
  border-color: #FFD700 !important;
195
+ box-shadow: 0 0 10px rgba(255, 215, 0, 0.4) !important;
196
  }
197
 
198
  .gr-button {
199
  background: linear-gradient(90deg, #FFD700 0%, #D4AF37 100%) !important;
200
+ color: #0A1D37 !important;
201
  border: none !important;
202
  border-radius: 8px !important;
203
  padding: 12px 24px !important;
204
  font-weight: 600 !important;
205
  font-size: 16px !important;
206
  transition: transform 0.1s ease, box-shadow 0.3s ease !important;
207
+ box-shadow: 0 3px 10px rgba(255, 215, 0, 0.3) !important;
208
  }
209
 
210
  .gr-button:hover {
211
  transform: translateY(-2px) !important;
212
+ box-shadow: 0 6px 14px rgba(255, 215, 0, 0.5) !important;
213
  }
214
 
215
  h1, h2, h3 {
216
  color: #FFD700 !important;
217
  font-weight: 700 !important;
218
+ text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;
219
+ animation: fadeIn 1s ease-in-out;
220
+ }
221
+
222
+ @keyframes fadeIn {
223
+ from { opacity: 0; transform: translateY(-10px); }
224
+ to { opacity: 1; transform: translateY(0); }
225
  }
226
 
227
  .gr-row {
228
+ margin: 20px 0 !important;
229
  }
230
 
231
  .gr-column {
232
+ padding: 15px !important;
233
  }
234
 
235
  label {
 
242
  }
243
 
244
  label::before {
245
+ font-family: "Font Awesome 6 Free";
246
+ font-weight: 900;
247
  margin-right: 8px;
248
  }
249
 
250
+ .gr-textbox label::before {
251
+ content: '\\f201';
252
+ }
253
+
254
  .gr-html label::before {
255
+ content: '\\f080';
256
  }
257
 
258
  .gr-file label::before {
259
+ content: '\\f019';
260
  }
261
 
262
  .economic-question-section {
263
+ background: rgba(26, 60, 52, 0.9) !important;
 
 
 
 
 
264
  border-radius: 12px;
265
+ padding: 25px;
266
  margin: 20px 0;
267
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
268
  }
269
 
270
  .economic-question-section .gr-textbox {
271
+ background: rgba(46, 74, 67, 0.8) !important;
272
  border: 2px solid #FFD700 !important;
273
+ box-shadow: 0 3px 10px rgba(255, 215, 0, 0.3) !important;
274
  font-size: 18px !important;
275
  padding: 15px !important;
276
  }
 
280
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5) !important;
281
  }
282
 
283
+ .prompt-box {
284
+ background: rgba(46, 74, 67, 0.6) !important;
285
+ border: 1px solid #FFD700 !important;
286
+ border-radius: 8px !important;
287
+ color: #E0E0E0 !important;
288
+ font-size: 16px !important;
289
+ padding: 12px !important;
290
+ margin-top: 10px !important;
291
+ }
292
+
293
+ .prompt-box label::before {
294
+ content: '\\f075';
295
+ }
296
+
297
  .options-section {
298
  display: flex;
299
+ flex-direction: column;
300
+ gap: 15px;
301
  margin-top: 15px;
302
  }
303
 
304
  .options-section .gr-dropdown {
305
  width: 200px !important;
306
  }
307
+
308
+ .options-section .gr-dropdown label::before {
309
+ content: '\\f0c9';
310
+ }
311
+
312
+ .progress-message {
313
+ color: #FFD700 !important;
314
+ font-style: italic;
315
+ margin-bottom: 10px;
316
+ }
317
  """
318
 
319
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as iface:
320
  gr.Markdown("# 📈 Analyse Financière Premium + Explication IA", elem_id="title")
321
+ gr.Markdown("Posez une question sur un événement économique. L'IA analyse le sentiment et explique l'impact.", elem_classes=["subtitle"])
322
 
323
  count = gr.State(0)
324
  history = gr.State([])
325
 
326
  with gr.Row(elem_classes=["economic-question-section"]):
327
+ with gr.Column(scale=2):
328
+ with gr.Column():
329
+ input_text = gr.Textbox(
330
+ lines=4,
331
+ label="Question Économique"
 
 
 
 
 
 
332
  )
333
+ prompt_display = gr.Textbox(
334
+ value="Une hausse des taux causerait-elle une récession ?",
335
+ label="Exemple de Prompt",
336
+ interactive=False,
337
+ elem_classes=["prompt-box"]
338
  )
339
+ with gr.Column(scale=1, elem_classes=["options-section"]):
340
+ mode_selector = gr.Dropdown(
341
+ choices=["Rapide", "Équilibré", "Précis"],
342
+ value="Équilibré",
343
+ label="Mode (longueur et style de réponse)"
344
+ )
345
+ detail_mode_selector = gr.Dropdown(
346
+ choices=["Normal", "Expert"],
347
+ value="Normal",
348
+ label="Niveau de détail (simplicité ou technicité)"
349
+ )
350
 
351
  with gr.Row():
352
  analyze_btn = gr.Button("Analyser")
 
355
 
356
  with gr.Row():
357
  with gr.Column(scale=1):
358
+ progress_message = gr.Textbox(label="Progression", elem_classes=["progress-message"], interactive=False)
359
+ sentiment_output = gr.Textbox(label="Sentiment Prédictif")
360
  sentiment_gauge = gr.HTML(label="Jauge de Sentiment")
361
  with gr.Column(scale=2):
362
  with gr.Row():
 
370
  analyze_btn.click(
371
  full_analysis,
372
  inputs=[input_text, mode_selector, detail_mode_selector, count, history],
373
+ outputs=[sentiment_output, explanation_output_en, explanation_output_fr, count, history, sentiment_gauge, progress_message]
374
  )
375
 
376
  download_btn.click(
 
379
  outputs=[download_file]
380
  )
381
 
382
+ iface.launch(share=True)
383
 
384
  if __name__ == "__main__":
385
  launch_app()