Docfile commited on
Commit
daa7bc0
·
verified ·
1 Parent(s): 713fb15

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -4,6 +4,9 @@ import time
4
  import os
5
  from datetime import datetime
6
  from google import genai
 
 
 
7
  import uuid
8
 
9
  app = Flask(__name__)
@@ -14,6 +17,26 @@ MODEL_ID = "gemini-2.5-flash-preview-05-20" # Ou le modèle que vous utilisez
14
  UPLOAD_FOLDER = 'uploads'
15
  RESULTS_FOLDER = 'results'
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # Créer les dossiers s'ils n'existent pas
18
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
19
  os.makedirs(RESULTS_FOLDER, exist_ok=True)
@@ -81,7 +104,10 @@ def generate_synthetic_data(file_path, task_id):
81
  # Faire la requête
82
  response = client.models.generate_content(
83
  model=MODEL_ID,
84
- contents=[file_ref, prompt]
 
 
 
85
  )
86
 
87
  # Écrire la réponse dans le fichier
 
4
  import os
5
  from datetime import datetime
6
  from google import genai
7
+ from google.genai import types
8
+
9
+
10
  import uuid
11
 
12
  app = Flask(__name__)
 
17
  UPLOAD_FOLDER = 'uploads'
18
  RESULTS_FOLDER = 'results'
19
 
20
+ safety_settings = [
21
+ types.SafetySetting(
22
+ category="HARM_CATEGORY_HARASSMENT",
23
+ threshold="BLOCK_NONE",
24
+ ),
25
+ types.SafetySetting(
26
+ category="HARM_CATEGORY_HATE_SPEECH",
27
+ threshold="BLOCK_NONE",
28
+ ),
29
+ types.SafetySetting(
30
+ category="HARM_CATEGORY_SEXUALLY_EXPLICIT",
31
+ threshold="BLOCK_NONE",
32
+ ),
33
+ types.SafetySetting(
34
+ category="HARM_CATEGORY_DANGEROUS_CONTENT",
35
+ threshold="BLOCK_NONE",
36
+ ),
37
+ ]
38
+
39
+
40
  # Créer les dossiers s'ils n'existent pas
41
  os.makedirs(UPLOAD_FOLDER, exist_ok=True)
42
  os.makedirs(RESULTS_FOLDER, exist_ok=True)
 
104
  # Faire la requête
105
  response = client.models.generate_content(
106
  model=MODEL_ID,
107
+ contents=[file_ref, prompt],
108
+ config=types.GenerateContentConfig(
109
+ safety_settings=safety_settings,
110
+ )
111
  )
112
 
113
  # Écrire la réponse dans le fichier