Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
3 |
import os
|
4 |
from PIL import Image
|
5 |
import io
|
@@ -8,10 +9,10 @@ import json
|
|
8 |
|
9 |
GOOGLE_API_KEY = os.environ.get("GEMINI_API_KEY")
|
10 |
|
11 |
-
genai.
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
|
16 |
st.title("Résolution d'exercice avec Gemini")
|
17 |
|
@@ -31,16 +32,13 @@ if uploaded_file is not None:
|
|
31 |
|
32 |
mode = 'starting'
|
33 |
try:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
"Résous cet exercice. ça doit être bien présenté et espacé afin d'être facile à lire."
|
42 |
-
],
|
43 |
-
stream=True # Activer le streaming
|
44 |
)
|
45 |
|
46 |
full_response = "" # Pour accumuler toute la réponse pour un affichage final propre
|
|
|
1 |
import streamlit as st
|
2 |
+
from google import genai
|
3 |
+
from google.genai import types
|
4 |
import os
|
5 |
from PIL import Image
|
6 |
import io
|
|
|
9 |
|
10 |
GOOGLE_API_KEY = os.environ.get("GEMINI_API_KEY")
|
11 |
|
12 |
+
client = genai.Client(
|
13 |
+
api_key=GOOGLE_API_KEY,
|
14 |
+
http_options={'api_version': 'v1alpha'},
|
15 |
+
)
|
16 |
|
17 |
st.title("Résolution d'exercice avec Gemini")
|
18 |
|
|
|
32 |
|
33 |
mode = 'starting'
|
34 |
try:
|
35 |
+
response = client.models.generate_content_stream(
|
36 |
+
model="gemini-2.0-flash-thinking-exp-01-21",
|
37 |
+
config={'thinking_config': {'include_thoughts': True}},
|
38 |
+
contents=[
|
39 |
+
{'inline_data': {'mime_type': 'image/png', 'data': img_str}},
|
40 |
+
"Resous cette exercice. ça doit être bien présentable et espacé afin d'être facile à lire."
|
41 |
+
]
|
|
|
|
|
|
|
42 |
)
|
43 |
|
44 |
full_response = "" # Pour accumuler toute la réponse pour un affichage final propre
|