Upload app.py
Browse files
app.py
CHANGED
@@ -61,15 +61,36 @@ def generate_response(prompt, chat_history, max_new_tokens):
|
|
61 |
response = generated_text.strip()
|
62 |
yield response
|
63 |
|
64 |
-
#
|
65 |
st.sidebar.header("Chatbot Configuration")
|
66 |
max_tokens = st.sidebar.slider("Maximum new tokens", min_value=8, max_value=256, value=64, help="Larger values result in longer responses.")
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
st.subheader("Chat with the Amharic Chatbot")
|
69 |
chat_history = st.session_state.get("chat_history", [])
|
70 |
|
|
|
|
|
|
|
71 |
# User Input
|
72 |
-
user_input = st.text_input("Your message:", placeholder="Type your message here...")
|
73 |
|
74 |
if st.button("Send"):
|
75 |
if user_input:
|
@@ -83,7 +104,7 @@ if st.button("Send"):
|
|
83 |
for response in responses:
|
84 |
final_response = response
|
85 |
st.session_state.chat_history[-1] = (user_input, final_response)
|
86 |
-
st.
|
87 |
|
88 |
# Display Chat History
|
89 |
if "chat_history" in st.session_state:
|
|
|
61 |
response = generated_text.strip()
|
62 |
yield response
|
63 |
|
64 |
+
# Sidebar: Configuration
|
65 |
st.sidebar.header("Chatbot Configuration")
|
66 |
max_tokens = st.sidebar.slider("Maximum new tokens", min_value=8, max_value=256, value=64, help="Larger values result in longer responses.")
|
67 |
|
68 |
+
# Examples
|
69 |
+
examples = [
|
70 |
+
"แฐแแแฃ แฅแแดแต แแ
?",
|
71 |
+
"แจแขแตแฎแตแซ แแ แจแฐแ แตแ แแแตแ แแ?",
|
72 |
+
"แจแขแตแฎแตแซ แจแแจแจแปแ แแแต แแ แแ แฉ?",
|
73 |
+
"แจแ แแญแ แแฅแ แแแแ",
|
74 |
+
"แฐแจแต แแแจแ\n\nแ
แฅแ แ แแ แณ",
|
75 |
+
"แ แแต แ แตแแ แแแต แแแจแ",
|
76 |
+
"แจแฐแฐแ แ แฝแแ แ แตแฐแซแจแต แแ แ แญแแต แแ? 'แ แแแณแ'แฃ 'แ แแณแ' แแญแ 'แแแแฐแ' แจแแ แแแฝ แตแฅแข 'แ แชแ แแแ แแ แญ'",
|
77 |
+
"แจแแจแแณแญ แแ แจแฐแ แตแ แแแตแ แแ?",
|
78 |
+
"แ แแ แจแ แแชแซ แแฌแแณแแต แแ แแ?",
|
79 |
+
"แถแตแต แจแ แแชแซ แแแซแต แฅแแตแแ",
|
80 |
+
"3 แจแ แแชแซ แแชแแฝแ แตแ แฅแแต",
|
81 |
+
"5 แจแ แแชแซ แจแฐแแแฝแ แฅแแต",
|
82 |
+
"แ แแตแต แจแ แแฎแ แแแฎแฝแ แฅแแตแแ",
|
83 |
+
"แ แแแ แแญ แซแแตแ 7 แ แ
แแซแต แแแจแ"
|
84 |
+
]
|
85 |
+
|
86 |
st.subheader("Chat with the Amharic Chatbot")
|
87 |
chat_history = st.session_state.get("chat_history", [])
|
88 |
|
89 |
+
# Example selector
|
90 |
+
example = st.selectbox("Choose an example:", ["Type your own message"] + examples)
|
91 |
+
|
92 |
# User Input
|
93 |
+
user_input = st.text_input("Your message:", value=example if example != "Type your own message" else "", placeholder="Type your message here...")
|
94 |
|
95 |
if st.button("Send"):
|
96 |
if user_input:
|
|
|
104 |
for response in responses:
|
105 |
final_response = response
|
106 |
st.session_state.chat_history[-1] = (user_input, final_response)
|
107 |
+
st.rerun()
|
108 |
|
109 |
# Display Chat History
|
110 |
if "chat_history" in st.session_state:
|