Mahavaury2 commited on
Commit
3264612
·
verified ·
1 Parent(s): 86ef0b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -1,30 +1,36 @@
1
  import gradio as gr
2
 
3
- # Define custom CSS for a pastel gradient
4
  css = """
5
  .gradio-container {
6
  background: linear-gradient(to right, #FFDEE9, #B5FFFC);
7
  }
8
  """
9
 
10
- def respond(message):
11
- # Simple example function returning a response
12
- return f"Vous avez dit: {message}"
 
 
 
 
 
 
 
 
13
 
14
  with gr.Blocks(css=css) as demo:
15
- # Display the greeting message
16
- gr.Markdown(
17
- "<h1 style='text-align: center;'>Bonjour Dans le chat du consentement</h1>"
18
- )
19
 
20
- # Create a simple text input and output
21
  with gr.Row():
22
- user_input = gr.Textbox(label="Entrez votre message ici")
23
- btn = gr.Button("Envoyer")
24
- output = gr.Textbox(label="Réponse")
25
 
26
- # Link the button to the respond function
27
- btn.click(fn=respond, inputs=user_input, outputs=output)
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__":