File size: 2,165 Bytes
031e364
271a3d2
1222a26
24488cc
031e364
 
 
 
 
 
1222a26
031e364
 
 
 
1222a26
7d9bce7
1222a26
031e364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222a26
6f1f950
7d9bce7
 
6f1f950
d95235c
1222a26
7630108
1222a26
031e364
 
7630108
031e364
1222a26
 
031e364
 
 
 
 
 
 
 
a165270
031e364
 
1222a26
f1df67d
24488cc
2c49e69
 
 
 
 
26a0064
 
 
 
 
 
 
b6d9582
26a0064
 
 
 
 
 
 
 
 
 
 
f8a6de1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

import gradio as gr
import google.generativeai as genai

import os 
token=os.environ.get("TOKEN") 
e = ""
genai.configure(
    api_key=token
)
generation_config = {
  "temperature": 1,
  "top_p": 0.95,
  "top_k": 64,
  "max_output_tokens": 8192,
}

safety_settings = [
  {
    "category": "HARM_CATEGORY_HARASSMENT",
    "threshold": "BLOCK_NONE"
  },
  {
    "category": "HARM_CATEGORY_HATE_SPEECH",
    "threshold": "BLOCK_NONE"
  },
  {
    "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
    "threshold": "BLOCK_NONE"
  },
  {
    "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
    "threshold": "BLOCK_NONE"
  },
]






mm = """ resous cet exercice. tu répondras en détaillant au maximum ton procédé de calcul. réponse attendue uniquement en Latex 

"""
model = genai.GenerativeModel(model_name="gemini-1.5-pro",
                              generation_config=generation_config ,
                              safety_settings=safety_settings)


# Fonction pour générer le contenu
def generate_content(image):
    global e
    
    if not image:
        e =" djo"
        
    else:
        response = model.generate_content([mm,image])
        print(response.text)
        e= response.text
        
    return e

markdown = r"""
{e}
""".format(e=e)


iface = gr.Interface(
    fn=generate_content, 
    inputs=gr.Image(type='pil'),
    outputs=gr.Markdown(
        latex_delimiters=[
            {"left": "$$", "right": "$$", "display": True},
            {"left": "$", "right": "$", "display": True},
            {"left": "\chemfig{", "right": "}", "display": True},  # Modifié
            {"left": "\\(", "right": "\\)", "display": True},
            {"left": "\\begin{equation}", "right": "\\end{equation}", "display": True},
            {"left": "\\begin{align}", "right": "\\end{align}", "display": True},
            {"left": "\\begin{alignat}", "right": "\\end{alignat}", "display": True},
            {"left": "\\begin{gather}", "right": "\\end{gather}", "display": True},
            {"left": "\\begin{CD}", "right": "\\end{CD}", "display": True},
            {"left": "\\[", "right": "\\]", "display": True}
        ]
    )
)

iface.launch()