Docfile commited on
Commit
cac21d1
·
verified ·
1 Parent(s): 59dac18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -17,6 +17,7 @@ from gradio_client import Client,handle_file
17
  from functools import wraps
18
  import os
19
  from google import genai
 
20
  import textwrap
21
  import PIL.Image
22
  from werkzeug.utils import secure_filename
@@ -42,26 +43,28 @@ generation_config = {
42
  }
43
 
44
  safety_settings = [
45
- {
46
- "category": "HARM_CATEGORY_HARASSMENT",
47
- "threshold": "BLOCK_NONE"
48
- },
49
- {
50
- "category": "HARM_CATEGORY_HATE_SPEECH",
51
- "threshold": "BLOCK_NONE"
52
- },
53
- {
54
- "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
55
- "threshold": "BLOCK_NONE"
56
- },
57
- {
58
- "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
59
- "threshold": "BLOCK_NONE"
60
- },
61
  ]
62
 
63
 
64
 
 
 
65
  client = genai.Client(
66
  api_key=GOOGLE_API_KEY,
67
  )
@@ -406,7 +409,12 @@ La conclusion répond à la question critique posée en introduction, en s'appuy
406
 
407
  response = client.models.generate_content(
408
  model=MODEL_ID,
 
409
  contents=prompt,
 
 
 
 
410
  )
411
 
412
  dissertation = response.text
@@ -708,7 +716,9 @@ La conclusion répond à la question critique posée en introduction, en s'appuy
708
 
709
  response = client.models.generate_content(
710
  model=MODEL_ID,
711
- contents=prompt, )
 
 
712
 
713
  dissertation = response.text
714
  return jsonify({"response": dissertation}), 200
 
17
  from functools import wraps
18
  import os
19
  from google import genai
20
+ from google.genai import types
21
  import textwrap
22
  import PIL.Image
23
  from werkzeug.utils import secure_filename
 
43
  }
44
 
45
  safety_settings = [
46
+ types.SafetySetting(
47
+ category="HARM_CATEGORY_HARASSMENT",
48
+ threshold="BLOCK_NONE",
49
+ ),
50
+ types.SafetySetting(
51
+ category="HARM_CATEGORY_HATE_SPEECH",
52
+ threshold="BLOCK_NONE",
53
+ ),
54
+ types.SafetySetting(
55
+ category="HARM_CATEGORY_SEXUALLY_EXPLICIT",
56
+ threshold="BLOCK_NONE",
57
+ ),
58
+ types.SafetySetting(
59
+ category="HARM_CATEGORY_DANGEROUS_CONTENT",
60
+ threshold="BLOCK_NONE",
61
+ ),
62
  ]
63
 
64
 
65
 
66
+
67
+
68
  client = genai.Client(
69
  api_key=GOOGLE_API_KEY,
70
  )
 
409
 
410
  response = client.models.generate_content(
411
  model=MODEL_ID,
412
+
413
  contents=prompt,
414
+ config=types.GenerateContentConfig(
415
+ safety_settings=safety_settings,
416
+ ),
417
+
418
  )
419
 
420
  dissertation = response.text
 
716
 
717
  response = client.models.generate_content(
718
  model=MODEL_ID,
719
+ contents=prompt,config=types.GenerateContentConfig(
720
+ safety_settings=safety_settings,
721
+ ), )
722
 
723
  dissertation = response.text
724
  return jsonify({"response": dissertation}), 200