Docfile commited on
Commit
2af7dad
·
verified ·
1 Parent(s): faa1717

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
- import google.generativeai as genai
 
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.configure(api_key=GOOGLE_API_KEY)
12
- client = genai.GenerativeModel("gemini-2.0-flash-thinking-exp-01-21")
13
- client.http_options = {'api_version': 'v1alpha'}
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
- responses = client.generate_content(
35
- model="gemini-2.0-flash-thinking-exp-01-21",
36
- generation_config=genai.types.GenerationConfig(
37
- include_thoughts=True
38
- ),
39
- contents=[
40
- {'inline_data': {'mime_type': 'image/png', 'data': img_str}},
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