Spaces:
Sleeping
Sleeping
amirhoseinsedaghati
commited on
Commit
•
b9ccae3
1
Parent(s):
e18c727
Upload main.py
Browse files
main.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from tools.chatbot import QuestionAnswering
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
models = {
|
7 |
+
'llama-3.1-405b-instruct' : 'meta/llama-3.1-405b-instruct',
|
8 |
+
'gemma-2-27b-it' : 'google/gemma-2-27b-it',
|
9 |
+
'mistral-nemo-12b-instruct' : 'nv-mistralai/mistral-nemo-12b-instruct',
|
10 |
+
'nemotron-4-340b-instruct' : 'nvidia/nemotron-4-340b-instruct',
|
11 |
+
'phi-3-medium-128k-instruct' : 'microsoft/phi-3-medium-128k-instruct',
|
12 |
+
'arctic' : 'snowflake/arctic'
|
13 |
+
}
|
14 |
+
|
15 |
+
def main():
|
16 |
+
st.header("🤖 Your Native Chatbot is ready to help")
|
17 |
+
st.markdown("**It helps you write and talk like a native speaker. So, What are you waiting for ? Let's go 😀**")
|
18 |
+
|
19 |
+
model_key = st.sidebar.selectbox('Powered by', list(models.keys()))
|
20 |
+
model_value = models[model_key]
|
21 |
+
memory = []
|
22 |
+
chatbot = QuestionAnswering(model_name=model_value, memory=memory)
|
23 |
+
|
24 |
+
curr_question = st.text_area(
|
25 |
+
'enter your prompt',
|
26 |
+
placeholder="Talk to your Native Chatbot!",
|
27 |
+
label_visibility="hidden"
|
28 |
+
)
|
29 |
+
|
30 |
+
if st.button("Generate Answer"):
|
31 |
+
try:
|
32 |
+
chatbot.generate_answer(curr_question)
|
33 |
+
except:
|
34 |
+
st.warning(body="Refresh the page or Try it again later.", icon="🤖")
|
35 |
+
|
36 |
+
main()
|
37 |
+
|