Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ GOOGLE_API_KEY = os.environ.get("TOKEN")
|
|
25 |
genai.configure(api_key=GOOGLE_API_KEY)
|
26 |
|
27 |
# Fonction pour interroger Gemini
|
28 |
-
def query_gemini(image_path,
|
29 |
img = PIL.Image.open(image_path)
|
30 |
model = genai.GenerativeModel(
|
31 |
model_name="gemini-1.5-pro-002",
|
@@ -33,13 +33,13 @@ def query_gemini(image_path, prompt="Résous ce problème mathématiques. Je veu
|
|
33 |
safety_settings=safety_settings
|
34 |
)
|
35 |
try:
|
36 |
-
response = model.generate_content([
|
37 |
return response.text
|
38 |
except Exception as e:
|
39 |
return str(e)
|
40 |
|
41 |
# Fonction pour interroger Qwen2
|
42 |
-
def query_qwen2(image_path, question
|
43 |
try:
|
44 |
client = Client("Qwen/Qwen2.5-Math-Demo")
|
45 |
result = client.predict(
|
@@ -63,7 +63,10 @@ def upload_image():
|
|
63 |
|
64 |
file = request.files['image']
|
65 |
model_choice = request.form.get('model_choice', 'gemini') # Obtient le choix du modèle
|
|
|
66 |
|
|
|
|
|
67 |
if file.filename == '':
|
68 |
return jsonify({'error': 'Aucun fichier sélectionné'}), 400
|
69 |
|
|
|
25 |
genai.configure(api_key=GOOGLE_API_KEY)
|
26 |
|
27 |
# Fonction pour interroger Gemini
|
28 |
+
def query_gemini(image_path,prompt_gemini):
|
29 |
img = PIL.Image.open(image_path)
|
30 |
model = genai.GenerativeModel(
|
31 |
model_name="gemini-1.5-pro-002",
|
|
|
33 |
safety_settings=safety_settings
|
34 |
)
|
35 |
try:
|
36 |
+
response = model.generate_content([prompt_gemini, img], request_options={"timeout": 600})
|
37 |
return response.text
|
38 |
except Exception as e:
|
39 |
return str(e)
|
40 |
|
41 |
# Fonction pour interroger Qwen2
|
42 |
+
def query_qwen2(image_path, question):
|
43 |
try:
|
44 |
client = Client("Qwen/Qwen2.5-Math-Demo")
|
45 |
result = client.predict(
|
|
|
63 |
|
64 |
file = request.files['image']
|
65 |
model_choice = request.form.get('model_choice', 'gemini') # Obtient le choix du modèle
|
66 |
+
custom_instruction = request.form.get('custom_instruction')
|
67 |
|
68 |
+
prompt_gemini = f"Résous ce problème mathématiques. Je veux qu'en réponse tu me donnes un rendu complet en utilisant du Latex. {custom}"
|
69 |
+
question = f"Donne la réponse en français et en utilisant LaTeX.{custom_instruction}"
|
70 |
if file.filename == '':
|
71 |
return jsonify({'error': 'Aucun fichier sélectionné'}), 400
|
72 |
|