awacke1 Sanyam0605 commited on
Commit
68d93a6
β€’
0 Parent(s):

Duplicate from Sanyam0605/Chatbot

Browse files

Co-authored-by: Sanyam Jain <Sanyam0605@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +13 -0
  3. app.py +67 -0
  4. main.py +67 -0
  5. requirements.txt +4 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Chatbot
3
+ emoji: πŸƒ
4
+ colorFrom: pink
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.19.0
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from: Sanyam0605/Chatbot
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_chat import message
3
+ from streamlit_extras.colored_header import colored_header
4
+ from streamlit_extras.add_vertical_space import add_vertical_space
5
+ from hugchat import hugchat
6
+
7
+ st.set_page_config(page_title="HugChat - An LLM-powered Streamlit app")
8
+
9
+ # image = "0_AI4xFlr8mYASsylX.png" # Replace with the actual path to your image
10
+ # st.image(image, caption="Robotic Llama", use_column_width=1)
11
+
12
+ with st.sidebar:
13
+ st.title('πŸ€—πŸ’¬ HugChat App')
14
+ st.markdown('''
15
+ ## About
16
+ This app is an LLM-powered chatbot built using:
17
+ - [Streamlit](<https://streamlit.io/>)
18
+ - [HugChat](<https://github.com/Soulter/hugging-chat-api>)
19
+ - [OpenAssistant/oasst-sft-6-llama-30b-xor](<https://huggingface.co/OpenAssistant/oasst-sft-6-llama-30b-xor>) LLM model
20
+
21
+ πŸ’‘ Note: No API key required!
22
+ ''')
23
+ add_vertical_space(5)
24
+ st.write('Thanks Meta for LLAMA and hugging face- hugchat')
25
+
26
+ if 'generated' not in st.session_state:
27
+ st.session_state['generated'] = ["I'm HugChat [created by Sanyam] , How may I help you?"]
28
+ if 'past' not in st.session_state:
29
+ st.session_state['past'] = ['Hi!']
30
+
31
+ input_container = st.container()
32
+ colored_header(label='', description='', color_name='blue-70')
33
+ response_container = st.container()
34
+
35
+
36
+ # User input
37
+ ## Function for taking user provided prompt as input
38
+ def get_text():
39
+ input_text = st.text_input("You: ", "", key="input")
40
+ return input_text
41
+
42
+
43
+ ## Applying the user input box
44
+ with input_container:
45
+ user_input = get_text()
46
+
47
+
48
+ # Response output
49
+ ## Function for taking user prompt as input followed by producing AI generated responses
50
+ def generate_response(prompt):
51
+ chatbot = hugchat.ChatBot()
52
+ response = chatbot.chat(prompt)
53
+ return response
54
+
55
+
56
+ ## Conditional display of AI generated responses as a function of user provided prompts
57
+ with response_container:
58
+ if user_input:
59
+ response = generate_response(user_input)
60
+ st.session_state.past.append(user_input)
61
+ st.session_state.generated.append(response)
62
+
63
+ if st.session_state['generated']:
64
+ for i in range(len(st.session_state['generated'])):
65
+ message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')
66
+ message(st.session_state['generated'][i], key=str(i))
67
+
main.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_chat import message
3
+ from streamlit_extras.colored_header import colored_header
4
+ from streamlit_extras.add_vertical_space import add_vertical_space
5
+ from hugchat import hugchat
6
+
7
+ st.set_page_config(page_title="HugChat - An LLM-powered Streamlit app")
8
+
9
+ # image = "0_AI4xFlr8mYASsylX.png" # Replace with the actual path to your image
10
+ # st.image(image, caption="Robotic Llama", use_column_width=1)
11
+
12
+ with st.sidebar:
13
+ st.title('πŸ€—πŸ’¬ HugChat App')
14
+ st.markdown('''
15
+ ## About
16
+ This app is an LLM-powered chatbot built using:
17
+ - [Streamlit](<https://streamlit.io/>)
18
+ - [HugChat](<https://github.com/Soulter/hugging-chat-api>)
19
+ - [OpenAssistant/oasst-sft-6-llama-30b-xor](<https://huggingface.co/OpenAssistant/oasst-sft-6-llama-30b-xor>) LLM model
20
+
21
+ πŸ’‘ Note: No API key required!
22
+ ''')
23
+ add_vertical_space(5)
24
+ st.write('Thanks Meta for LLAMA and hugging face- hugchat')
25
+
26
+ if 'generated' not in st.session_state:
27
+ st.session_state['generated'] = ["I'm HugChat, How may I help you?"]
28
+ if 'past' not in st.session_state:
29
+ st.session_state['past'] = ['Hi!']
30
+
31
+ input_container = st.container()
32
+ colored_header(label='', description='', color_name='blue-70')
33
+ response_container = st.container()
34
+
35
+
36
+ # User input
37
+ ## Function for taking user provided prompt as input
38
+ def get_text():
39
+ input_text = st.text_input("You: ", "", key="input")
40
+ return input_text
41
+
42
+
43
+ ## Applying the user input box
44
+ with input_container:
45
+ user_input = get_text()
46
+
47
+
48
+ # Response output
49
+ ## Function for taking user prompt as input followed by producing AI generated responses
50
+ def generate_response(prompt):
51
+ chatbot = hugchat.ChatBot()
52
+ response = chatbot.chat(prompt)
53
+ return response
54
+
55
+
56
+ ## Conditional display of AI generated responses as a function of user provided prompts
57
+ with response_container:
58
+ if user_input:
59
+ response = generate_response(user_input)
60
+ st.session_state.past.append(user_input)
61
+ st.session_state.generated.append(response)
62
+
63
+ if st.session_state['generated']:
64
+ for i in range(len(st.session_state['generated'])):
65
+ message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')
66
+ message(st.session_state['generated'][i], key=str(i))
67
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ hugchat
3
+ streamlit-chat
4
+ streamlit-extras