Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import requests
|
| 2 |
import json
|
| 3 |
-
import os
|
|
|
|
| 4 |
|
| 5 |
api_token = os.environ.get("TOKEN")
|
| 6 |
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
|
|
@@ -37,7 +38,7 @@ assistant
|
|
| 37 |
response = output[0].get('generated_text', '').strip().lower()
|
| 38 |
|
| 39 |
questions = response.count('questions')
|
| 40 |
-
|
| 41 |
other = response.count('other')
|
| 42 |
image_generation = response.count("image_generation")
|
| 43 |
fine_tuning = response.count("fine_tuning")
|
|
@@ -49,9 +50,9 @@ assistant
|
|
| 49 |
|
| 50 |
if questions == 2:
|
| 51 |
return 'questions'
|
| 52 |
-
elif
|
| 53 |
return 'Chat Model/LLM'
|
| 54 |
-
elif other == 2:
|
| 55 |
return "Other"
|
| 56 |
elif image_generation == 2:
|
| 57 |
return "Image Generation"
|
|
@@ -71,11 +72,11 @@ assistant
|
|
| 71 |
return f"Erreur: Réponse ambiguë - '{response}'"
|
| 72 |
|
| 73 |
# URL de base de l'API
|
| 74 |
-
base_url = "https://huggingface.co/api/posts
|
| 75 |
|
| 76 |
# Paramètres pour la pagination
|
| 77 |
skip = 0 # Nombre d'éléments à sauter
|
| 78 |
-
limit =
|
| 79 |
|
| 80 |
# Liste pour stocker tous les posts avec leur texte
|
| 81 |
all_posts_with_text = []
|
|
@@ -113,8 +114,16 @@ while True:
|
|
| 113 |
|
| 114 |
# Maintenant, all_posts_with_text contient tous les posts récupérés avec leur texte
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
# Appliquer votre algorithme d'analyse à tous les posts
|
| 120 |
for i, post in enumerate(all_posts_with_text, 1):
|
|
@@ -124,40 +133,36 @@ for i, post in enumerate(all_posts_with_text, 1):
|
|
| 124 |
# Appeler votre algorithme d'analyse
|
| 125 |
resultat = analyze_sentiment(text)
|
| 126 |
|
| 127 |
-
# Incrémenter les compteurs en fonction du résultat
|
| 128 |
if resultat == 'questions':
|
| 129 |
questions_count += 1
|
| 130 |
elif resultat == "Chat Model/LLM":
|
| 131 |
-
|
| 132 |
elif resultat == 'Other':
|
| 133 |
-
|
| 134 |
elif resultat == "Image Generation":
|
| 135 |
-
|
| 136 |
elif resultat == "Fine-tuning":
|
| 137 |
-
|
| 138 |
elif resultat == "Ethics and Bias":
|
| 139 |
-
|
| 140 |
elif resultat == 'Datasets':
|
| 141 |
-
|
| 142 |
elif resultat == 'Tools and Libraries':
|
| 143 |
-
|
| 144 |
elif resultat == "Tutorials and Guides":
|
| 145 |
-
|
| 146 |
elif resultat == "Debugging":
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
#
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
f"Debugging: {Debugging_count}"
|
| 162 |
-
|
| 163 |
-
)
|
|
|
|
| 1 |
import requests
|
| 2 |
import json
|
| 3 |
+
import os
|
| 4 |
+
import gradio as gr
|
| 5 |
|
| 6 |
api_token = os.environ.get("TOKEN")
|
| 7 |
API_URL = "https://api-inference.huggingface.co/models/meta-llama/Meta-Llama-3-8B-Instruct"
|
|
|
|
| 38 |
response = output[0].get('generated_text', '').strip().lower()
|
| 39 |
|
| 40 |
questions = response.count('questions')
|
| 41 |
+
chat_model_llm = response.count('chatmodel/llm')
|
| 42 |
other = response.count('other')
|
| 43 |
image_generation = response.count("image_generation")
|
| 44 |
fine_tuning = response.count("fine_tuning")
|
|
|
|
| 50 |
|
| 51 |
if questions == 2:
|
| 52 |
return 'questions'
|
| 53 |
+
elif chat_model_llm == 2:
|
| 54 |
return 'Chat Model/LLM'
|
| 55 |
+
elif other == 2:
|
| 56 |
return "Other"
|
| 57 |
elif image_generation == 2:
|
| 58 |
return "Image Generation"
|
|
|
|
| 72 |
return f"Erreur: Réponse ambiguë - '{response}'"
|
| 73 |
|
| 74 |
# URL de base de l'API
|
| 75 |
+
base_url = "https://huggingface.co/api/posts"
|
| 76 |
|
| 77 |
# Paramètres pour la pagination
|
| 78 |
skip = 0 # Nombre d'éléments à sauter
|
| 79 |
+
limit = 100 # Nombre maximal d'éléments à récupérer par requête
|
| 80 |
|
| 81 |
# Liste pour stocker tous les posts avec leur texte
|
| 82 |
all_posts_with_text = []
|
|
|
|
| 114 |
|
| 115 |
# Maintenant, all_posts_with_text contient tous les posts récupérés avec leur texte
|
| 116 |
|
| 117 |
+
questions_count = 0
|
| 118 |
+
chat_model_llm_count = 0
|
| 119 |
+
other_count = 0
|
| 120 |
+
image_generation_count = 0
|
| 121 |
+
fine_tuning_count = 0
|
| 122 |
+
ethics_and_bias_count = 0
|
| 123 |
+
datasets_count = 0
|
| 124 |
+
tools_and_libraries_count = 0
|
| 125 |
+
tutorials_and_guides_count = 0
|
| 126 |
+
debugging_count = 0
|
| 127 |
|
| 128 |
# Appliquer votre algorithme d'analyse à tous les posts
|
| 129 |
for i, post in enumerate(all_posts_with_text, 1):
|
|
|
|
| 133 |
# Appeler votre algorithme d'analyse
|
| 134 |
resultat = analyze_sentiment(text)
|
| 135 |
|
|
|
|
| 136 |
if resultat == 'questions':
|
| 137 |
questions_count += 1
|
| 138 |
elif resultat == "Chat Model/LLM":
|
| 139 |
+
chat_model_llm_count += 1
|
| 140 |
elif resultat == 'Other':
|
| 141 |
+
other_count += 1
|
| 142 |
elif resultat == "Image Generation":
|
| 143 |
+
image_generation_count += 1
|
| 144 |
elif resultat == "Fine-tuning":
|
| 145 |
+
fine_tuning_count += 1
|
| 146 |
elif resultat == "Ethics and Bias":
|
| 147 |
+
ethics_and_bias_count += 1
|
| 148 |
elif resultat == 'Datasets':
|
| 149 |
+
datasets_count += 1
|
| 150 |
elif resultat == 'Tools and Libraries':
|
| 151 |
+
tools_and_libraries_count += 1
|
| 152 |
elif resultat == "Tutorials and Guides":
|
| 153 |
+
tutorials_and_guides_count += 1
|
| 154 |
elif resultat == "Debugging":
|
| 155 |
+
debugging_count += 1
|
| 156 |
+
|
| 157 |
+
# Vous pouvez adapter votre algorithme d'analyse selon vos besoins spécifiques
|
| 158 |
+
|
| 159 |
+
print(f"Questions: {questions_count}")
|
| 160 |
+
print(f"Chat Model/LLM: {chat_model_llm_count}")
|
| 161 |
+
print(f"Other: {other_count}")
|
| 162 |
+
print(f"Image Generation: {image_generation_count}")
|
| 163 |
+
print(f"Fine-tuning: {fine_tuning_count}")
|
| 164 |
+
print(f"Ethics and Bias: {ethics_and_bias_count}")
|
| 165 |
+
print(f"Datasets: {datasets_count}")
|
| 166 |
+
print(f"Tools and Libraries: {tools_and_libraries_count}")
|
| 167 |
+
print(f"Tutorials and Guides: {tutorials_and_guides_count}")
|
| 168 |
+
print(f"Debugging: {debugging_count}")
|
|
|
|
|
|
|
|
|