Spaces:
Sleeping
Sleeping
| 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() |