Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load GPT-2 model for responses
|
| 5 |
+
chatbot = pipeline("text-generation", model="gpt2")
|
| 6 |
+
|
| 7 |
+
def get_response(user_input, mode="honest"):
|
| 8 |
+
if mode == "honest":
|
| 9 |
+
# Regular chatbot response
|
| 10 |
+
response = chatbot(user_input, max_length=50, do_sample=True, top_k=50)
|
| 11 |
+
return response[0]["generated_text"]
|
| 12 |
+
|
| 13 |
+
elif mode == "echo":
|
| 14 |
+
# Echo chamber mode - agrees with user input
|
| 15 |
+
return f"You're absolutely right! {user_input}"
|
| 16 |
+
|
| 17 |
+
# Streamlit UI
|
| 18 |
+
st.title("Echo Chamber AI vs Honest AI")
|
| 19 |
+
|
| 20 |
+
# User input
|
| 21 |
+
user_input = st.text_input("Ask me anything:")
|
| 22 |
+
|
| 23 |
+
# Mode selection
|
| 24 |
+
mode = st.radio("Choose AI Mode:", ["Honest AI", "Echo Chamber AI"])
|
| 25 |
+
|
| 26 |
+
# Generate response
|
| 27 |
+
if user_input:
|
| 28 |
+
response = get_response(user_input, mode="echo" if mode == "Echo Chamber AI" else "honest")
|
| 29 |
+
st.write(f"**AI Response:** {response}")
|