Update app.py
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ genai.configure(api_key=api_key)
|
|
| 17 |
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 18 |
|
| 19 |
# Configure page
|
| 20 |
-
st.set_page_config(page_title="
|
| 21 |
|
| 22 |
# Custom CSS for better styling
|
| 23 |
st.markdown("""
|
|
@@ -57,23 +57,23 @@ st.markdown("""
|
|
| 57 |
if "messages" not in st.session_state:
|
| 58 |
st.session_state["messages"] = []
|
| 59 |
|
| 60 |
-
# Chatbot function
|
| 61 |
def chatbot_response(user_input):
|
| 62 |
# Check if the user called the bot "bhai"
|
| 63 |
if "bhai" in user_input.lower():
|
| 64 |
# Replace "bhai" with the chatbot's name
|
| 65 |
bot_name = "bhai"
|
| 66 |
-
response_prefix = f"
|
| 67 |
else:
|
| 68 |
response_prefix = ""
|
| 69 |
-
|
| 70 |
-
# Ensure response is generated in Urdu
|
| 71 |
-
prompt = f"{response_prefix}
|
| 72 |
|
| 73 |
# Get AI-generated response
|
| 74 |
response = model.generate_content(prompt)
|
| 75 |
|
| 76 |
-
# Modify the response to be
|
| 77 |
return response.text
|
| 78 |
|
| 79 |
# Callback function to handle input and clear it
|
|
@@ -101,7 +101,7 @@ def send_message():
|
|
| 101 |
st.session_state.input = ""
|
| 102 |
|
| 103 |
# UI Layout
|
| 104 |
-
st.title("🤖
|
| 105 |
|
| 106 |
# Display chat history
|
| 107 |
for message in st.session_state["messages"]:
|
|
@@ -111,4 +111,4 @@ for message in st.session_state["messages"]:
|
|
| 111 |
st.markdown(f'<div class="message bot_message">{message["content"]}<div class="timestamp">{message["time"]}</div></div>', unsafe_allow_html=True)
|
| 112 |
|
| 113 |
# User input with callback
|
| 114 |
-
st.text_input("
|
|
|
|
| 17 |
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 18 |
|
| 19 |
# Configure page
|
| 20 |
+
st.set_page_config(page_title="Bhai Bot", page_icon="🤖", layout="centered")
|
| 21 |
|
| 22 |
# Custom CSS for better styling
|
| 23 |
st.markdown("""
|
|
|
|
| 57 |
if "messages" not in st.session_state:
|
| 58 |
st.session_state["messages"] = []
|
| 59 |
|
| 60 |
+
# Chatbot function to respond in informal Roman Urdu
|
| 61 |
def chatbot_response(user_input):
|
| 62 |
# Check if the user called the bot "bhai"
|
| 63 |
if "bhai" in user_input.lower():
|
| 64 |
# Replace "bhai" with the chatbot's name
|
| 65 |
bot_name = "bhai"
|
| 66 |
+
response_prefix = f"Haan {bot_name}, "
|
| 67 |
else:
|
| 68 |
response_prefix = ""
|
| 69 |
+
|
| 70 |
+
# Ensure response is generated in informal Roman Urdu
|
| 71 |
+
prompt = f"{response_prefix}apni baat sirf Roman Urdu mein bata: {user_input}"
|
| 72 |
|
| 73 |
# Get AI-generated response
|
| 74 |
response = model.generate_content(prompt)
|
| 75 |
|
| 76 |
+
# Modify the response to be informal in Roman Urdu
|
| 77 |
return response.text
|
| 78 |
|
| 79 |
# Callback function to handle input and clear it
|
|
|
|
| 101 |
st.session_state.input = ""
|
| 102 |
|
| 103 |
# UI Layout
|
| 104 |
+
st.title("🤖 Bhai Bot (Roman Urdu)")
|
| 105 |
|
| 106 |
# Display chat history
|
| 107 |
for message in st.session_state["messages"]:
|
|
|
|
| 111 |
st.markdown(f'<div class="message bot_message">{message["content"]}<div class="timestamp">{message["time"]}</div></div>', unsafe_allow_html=True)
|
| 112 |
|
| 113 |
# User input with callback
|
| 114 |
+
st.text_input("Likho apni baat...", key="input", on_change=send_message)
|