Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,36 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
#
|
| 4 |
css = """
|
| 5 |
.gradio-container {
|
| 6 |
background: linear-gradient(to right, #FFDEE9, #B5FFFC);
|
| 7 |
}
|
| 8 |
"""
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks(css=css) as demo:
|
| 15 |
-
#
|
| 16 |
-
gr.Markdown(
|
| 17 |
-
"<h1 style='text-align: center;'>Bonjour Dans le chat du consentement</h1>"
|
| 18 |
-
)
|
| 19 |
|
| 20 |
-
# Create
|
| 21 |
with gr.Row():
|
| 22 |
-
user_input = gr.Textbox(label="Entrez votre message ici")
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
# Link the button to
|
| 27 |
-
|
| 28 |
|
| 29 |
# Launch the app
|
| 30 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Custom CSS for pastel gradient
|
| 4 |
css = """
|
| 5 |
.gradio-container {
|
| 6 |
background: linear-gradient(to right, #FFDEE9, #B5FFFC);
|
| 7 |
}
|
| 8 |
"""
|
| 9 |
|
| 10 |
+
# Load the Mistral-7B-Instruct-v0.3 model via Gradio's load function
|
| 11 |
+
model = gr.load("models/mistralai/Mistral-7B-Instruct-v0.3")
|
| 12 |
+
|
| 13 |
+
def inference_fn(prompt):
|
| 14 |
+
"""
|
| 15 |
+
This function calls the loaded model with the user's prompt.
|
| 16 |
+
gr.load(...) returns a Gradio interface object, so we can call it like a function.
|
| 17 |
+
"""
|
| 18 |
+
# If the loaded model is a pipeline or interface, calling it directly returns the response.
|
| 19 |
+
response = model(prompt)
|
| 20 |
+
return response
|
| 21 |
|
| 22 |
with gr.Blocks(css=css) as demo:
|
| 23 |
+
# Greeting at the top
|
| 24 |
+
gr.Markdown("<h1 style='text-align: center;'>Bonjour Dans le chat du consentement</h1>")
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
# Create the input/output layout
|
| 27 |
with gr.Row():
|
| 28 |
+
user_input = gr.Textbox(label="Entrez votre message ici:", lines=3)
|
| 29 |
+
output = gr.Textbox(label="Réponse du Modèle Mistral-7B-Instruct:", lines=5)
|
| 30 |
+
send_button = gr.Button("Envoyer")
|
| 31 |
|
| 32 |
+
# Link the button to inference_fn
|
| 33 |
+
send_button.click(fn=inference_fn, inputs=user_input, outputs=output)
|
| 34 |
|
| 35 |
# Launch the app
|
| 36 |
if __name__ == "__main__":
|