Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,6 +35,56 @@ GOOGLE_API_KEY = os.environ.get("TOKEN")
|
|
| 35 |
|
| 36 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
@app.route('/')
|
| 39 |
def index():
|
| 40 |
return render_template('histoire.html')
|
|
@@ -135,6 +185,8 @@ def submit_histoire():
|
|
| 135 |
return jsonify({"error": "Tous les champs sont obligatoires"}), 400
|
| 136 |
|
| 137 |
try:
|
|
|
|
|
|
|
| 138 |
# Génération de l'introduction
|
| 139 |
dissertation = generer_introduction(sujet,points, "histoire")
|
| 140 |
dissertation += "\n\n"
|
|
@@ -148,7 +200,8 @@ def submit_histoire():
|
|
| 148 |
|
| 149 |
# Génération de la conclusion
|
| 150 |
dissertation += generer_conclusion(sujet, dissertation, "histoire")
|
| 151 |
-
|
|
|
|
| 152 |
return jsonify({"output": dissertation}), 200
|
| 153 |
|
| 154 |
except Exception as e:
|
|
|
|
| 35 |
|
| 36 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 37 |
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def rediger_tout(theme, point):
|
| 42 |
+
"""Génère une section de dissertation d'histoire."""
|
| 43 |
+
prompt = f"""
|
| 44 |
+
je souhaite faire mon travail d'histoire. le thème c'est {thème} et les différents point a détaillé sont : {point}
|
| 45 |
+
|
| 46 |
+
Voici la méthodologie que tu devras scrupuleusement respecté pour la dissertation :
|
| 47 |
+
|
| 48 |
+
Introduction
|
| 49 |
+
Amorce
|
| 50 |
+
Problématique
|
| 51 |
+
Annonce du plan(les points )
|
| 52 |
+
|
| 53 |
+
Développement(il y a trois points et donc une partie pour chaque points )
|
| 54 |
+
|
| 55 |
+
1er partie
|
| 56 |
+
|
| 57 |
+
Phrase chapeau
|
| 58 |
+
Argument 1
|
| 59 |
+
Argument 2
|
| 60 |
+
Transition
|
| 61 |
+
|
| 62 |
+
2eme partie
|
| 63 |
+
|
| 64 |
+
Phrase chapeau
|
| 65 |
+
Argument 1+ explication+ exemple
|
| 66 |
+
Argument 2 + explication + exemple
|
| 67 |
+
Transition
|
| 68 |
+
|
| 69 |
+
3eme partie
|
| 70 |
+
|
| 71 |
+
Phrase chapeau
|
| 72 |
+
Argument 1+ explication + exemple
|
| 73 |
+
Argument 2 + explication + exemple
|
| 74 |
+
|
| 75 |
+
Conclusion
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
model = genai.GenerativeModel('gemini-exp-1206',generation_config=generation_config, safety_settings=safety_settings)
|
| 81 |
+
response = model.generate_content([prompt, img], request_options={"timeout": 600})
|
| 82 |
+
return response.text
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
@app.route('/')
|
| 89 |
def index():
|
| 90 |
return render_template('histoire.html')
|
|
|
|
| 185 |
return jsonify({"error": "Tous les champs sont obligatoires"}), 400
|
| 186 |
|
| 187 |
try:
|
| 188 |
+
|
| 189 |
+
"""
|
| 190 |
# Génération de l'introduction
|
| 191 |
dissertation = generer_introduction(sujet,points, "histoire")
|
| 192 |
dissertation += "\n\n"
|
|
|
|
| 200 |
|
| 201 |
# Génération de la conclusion
|
| 202 |
dissertation += generer_conclusion(sujet, dissertation, "histoire")
|
| 203 |
+
"""
|
| 204 |
+
dissertation = rediger_tout(sujet,points)
|
| 205 |
return jsonify({"output": dissertation}), 200
|
| 206 |
|
| 207 |
except Exception as e:
|