Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| # from mistralai import Mistral, UserMessage | |
| from chatbot_gaia.src.main_flow import kickoff | |
| import pandas as pd | |
| import os | |
| from func_utils import * | |
| from summary_test import generate_irradiance_trend, get_mocked_summary | |
| def go_to_page_1(): | |
| return gr.Column(visible=True), gr.Column(visible=False) | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| page_1 = gr.Column(visible=True) | |
| with page_1: | |
| gr.HTML( | |
| """ | |
| <style> | |
| /* Custom style for a specific row */ | |
| .box { | |
| background-color: #90909b; | |
| border-radius: 10px; | |
| display: flex; | |
| align-content: center; | |
| padding: 20px; | |
| } | |
| .culture_box { | |
| background-color: #52525b; | |
| border-radius: 10px; | |
| display: flex; | |
| align-content: center; | |
| } | |
| .summary { | |
| border: solid 1px; | |
| border-radius: 10px; | |
| padding: 20px; | |
| } | |
| .padding.svelte-phx28p{ | |
| padding: 0px; | |
| } | |
| </style> | |
| """ | |
| ) | |
| demo.title = "Démo GAIA - Les bénéfices de l'ombrage" | |
| gr.HTML("<h1 style='text-align: center;'>Les bénéfices de l'ombrage</h1>") | |
| gr.HTML( | |
| "<p style=''>Découvrez le potentiel de l'ombrage sur votre exploitation !</p>" | |
| ) | |
| with gr.Blocks() as infos: | |
| infos.title = "Informations sur votre exploitation" | |
| gr.HTML("<h2>Renseignez les informations relatives à votre projet</h2>") | |
| with gr.Row(equal_height=True): | |
| with gr.Column(variant="panel", scale=1): | |
| with gr.Row(equal_height=True, elem_classes="box"): | |
| with gr.Tab(label="Adresse", scale=1): | |
| address = gr.Textbox( | |
| label="Addresse", | |
| info="Adresse de votre projet", | |
| ) | |
| with gr.Tab(label="Coordonnées GPS", scale=1): | |
| lat = gr.Number( | |
| label="Latitude", | |
| info="Latitude de votre projet", | |
| ) | |
| lon = gr.Number( | |
| label="Longitude", | |
| info="Longitude de votre projet", | |
| ) | |
| place_btn = gr.Button( | |
| value="Valider la localisation", size="sm" | |
| ) | |
| place_cancel_btn = gr.Button( | |
| value="Réinitialiser la localisation", size="sm" | |
| ) | |
| with gr.Row(elem_classes="box"): | |
| culture = gr.Dropdown( | |
| label="Culture", scale=1, elem_classes="culture_box", choices=["Blé", "Colza", "Orge"] | |
| ) | |
| with gr.Column(variant="panel", scale=3): | |
| map = gr.HTML() | |
| simulation_btn = gr.Button(value="Lancer la simulation", size="lg") | |
| go_to_page_2_btn = gr.Button("Aller aux résultats", visible=False) | |
| page_2 = gr.Column(visible=False) | |
| with page_2: | |
| with gr.Blocks() as results: | |
| results.title = "Résultats" | |
| gr.HTML("<h2>Résultats de la simulation</h2>") | |
| with gr.Row(equal_height=True, elem_classes="box"): | |
| with gr.Tab(label="Analyse générale", scale=1): | |
| with gr.Row(elem_classes="box"): | |
| with gr.Column(): | |
| gr.HTML( | |
| "<h2>Synthèse des Prévisions Météorologiques selon le Scénario Pessimiste</h2>" | |
| ) | |
| current_situation_summary = gr.Markdown( | |
| elem_classes="summary" | |
| ) | |
| with gr.Row(elem_classes="box"): | |
| with gr.Column(): | |
| gr.HTML("<h2>Déficit hydrique</h2>") | |
| gr.Plot() | |
| with gr.Column(): | |
| gr.HTML("<h2>Rendements</h2>") | |
| gr.Plot() | |
| with gr.Column(elem_classes="box"): | |
| with gr.Row(): | |
| gr.HTML("<h2>Bilan climatique</h2>") | |
| with gr.Row(): | |
| plot_1 = gr.Plot() | |
| plot_2 = gr.Plot() | |
| with gr.Row(): | |
| plot_3 = gr.Plot() | |
| with gr.Tab(label="Analyse avec AgriPv", scale=1): | |
| with gr.Row(elem_classes="box"): | |
| with gr.Column(): | |
| gr.HTML("<h2>Synthèse des bénéfices avec ombrage</h2>") | |
| agripv_summary = gr.Markdown(elem_classes="summary") | |
| with gr.Row(elem_classes="box"): | |
| with gr.Column(): | |
| gr.HTML("<h2>Déficit hydrique</h2>") | |
| gr.Plot() | |
| with gr.Column(): | |
| gr.HTML("<h2>Rendements</h2>") | |
| gr.Plot() | |
| go_to_page_1_btn = gr.Button( | |
| value="Revenir aux informations du projet", size="lg" | |
| ) | |
| demo.load(on_init, [lat, lon, address], [lat, lon, map]) | |
| place_btn.click(on_init, [lat, lon, address], [lat, lon, map]) | |
| place_cancel_btn.click(on_delete, [lat, lon, map], [lat, lon, address, map]) | |
| go_to_page_2_btn.click( | |
| fn=go_to_page_2, | |
| inputs="", | |
| outputs=[page_1, page_2], | |
| ) | |
| go_to_page_1_btn.click( | |
| fn=go_to_page_1, | |
| inputs="", | |
| outputs=[page_1, page_2], | |
| ) | |
| simulation_btn.click( | |
| launch_simulation, | |
| [lat, lon, address, culture], | |
| [ | |
| current_situation_summary, | |
| agripv_summary, | |
| plot_1, | |
| plot_2, | |
| plot_3, | |
| page_1, | |
| page_2, | |
| go_to_page_2_btn, | |
| ], | |
| ) | |
| demo.title = "Démo GAIA - Les bénéfices de l'ombrage" | |
| demo.launch() | |