sauvivek commited on
Commit
a351891
·
verified ·
1 Parent(s): 10de357

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the two mental health chatbots (models)
5
+ # Model 1: PsychGPT
6
+ model1 = pipeline("text-generation", model="thrishala/mental_health_chatbot")
7
+
8
+ # Model 2: Mental Health Chatbot from Hugging Face (replace with the actual model you're using)
9
+ model2 = pipeline("text-generation", model="thrishala/mental_health_chatbot") # Update with actual model name
10
+
11
+ # Define a function that takes user input and gets responses from both models
12
+ def compare_models(input_text):
13
+ response1 = model1(input_text, max_length=100)[0]["generated_text"]
14
+ response2 = model2(input_text, max_length=100)[0]["generated_text"]
15
+ return response1, response2
16
+
17
+ # Create Gradio interface for comparison
18
+ iface = gr.Interface(fn=compare_models,
19
+ inputs="text",
20
+ outputs=["text", "text"],
21
+ live=True,
22
+ title="Mental Health Chatbot Comparison",
23
+ description="Compare responses from two different Mental Health Chatbot models")
24
+
25
+ # Launch the interface
26
+ iface.launch()