Spaces:
Sleeping
Sleeping
Learner project V1
Browse files- .streamlit/secrets.toml +1 -0
- README.md +40 -13
- __pycache__/app.cpython-310.pyc +0 -0
- app.py +73 -0
- db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/data_level0.bin +3 -0
- db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/header.bin +3 -0
- db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/length.bin +3 -0
- db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/link_lists.bin +3 -0
- db/chroma.sqlite3 +0 -0
- embedchain.json +3 -0
- requirements.txt +2 -0
- sql.yaml +17 -0
.streamlit/secrets.toml
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OPENAI_API_KEY="sk-xxx"
|
README.md
CHANGED
@@ -1,13 +1,40 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Learner Bot LLM
|
2 |
+
==============================================
|
3 |
+
|
4 |
+
Learner Bot is a simple chatbot built using the Streamlit and Embedchain .This bot is able to learn new things just by adding URL of information you provide and also you able to talk with your data . This bot is build on `Mixtral-8x7B-Instruct-v0.1` LLM
|
5 |
+
|
6 |
+
Getting Started
|
7 |
+
---------------
|
8 |
+
|
9 |
+
To run the Learner Bot locally on your machine, follow these steps:
|
10 |
+
|
11 |
+
1. Clone the repository: `git clone https://github.com/Piyushlamsoge/Demo-project.git`
|
12 |
+
2. Navigate into the cloned directory: `cd Demo-project`
|
13 |
+
3. Create a virtual environment (optional but recommended): `python -m venv env && source env/bin/activate`
|
14 |
+
4. Install required packages: `pip install -r requirements.txt`
|
15 |
+
5. Run the app: `streamlit run app.py`
|
16 |
+
6. Add your `HuggingFace API` = "hf_xxxxxxxxxxxxx"
|
17 |
+
7. Interact with the chatbot by typing messages in the input box at the bottom of the page.
|
18 |
+
|
19 |
+
Project Structure
|
20 |
+
-----------------
|
21 |
+
|
22 |
+
* `app.py`: The main script that runs the Streamlit application and contains the implementation of the chatbot logic.
|
23 |
+
* `requirements.txt`: File listing dependencies needed to run the project.
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
Contributing
|
28 |
+
------------
|
29 |
+
|
30 |
+
We welcome contributions! If you find any issues or want to add new features, feel free to submit pull requests. Before contributing, please read our Contribution Guidelines available in the [CONTRIBUTING](CONTRIBUTING.md) file.
|
31 |
+
|
32 |
+
License
|
33 |
+
-------
|
34 |
+
|
35 |
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
36 |
+
|
37 |
+
Acknowledgements
|
38 |
+
----------------
|
39 |
+
|
40 |
+
This project was inspired by various online resources and tutorials related to building chatbots using Streamlit. We would like to thank those who have shared their knowledge and experience in creating such helpful content.
|
__pycache__/app.cpython-310.pyc
ADDED
Binary file (1.69 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from embedchain import App
|
4 |
+
import os
|
5 |
+
|
6 |
+
|
7 |
+
@st.cache_resource
|
8 |
+
def sql_bot():
|
9 |
+
return App.from_config(config_path="sql.yaml")
|
10 |
+
|
11 |
+
with st.sidebar:
|
12 |
+
huggingface_access_token = st.text_input("Hugging face Token", key="chatbot_api_key", type="password")
|
13 |
+
"[Get Hugging Face Access Token](https://huggingface.co/settings/tokens)"
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
st.title("Learner Chatbot")
|
19 |
+
st.caption("🚀 An app powered by Huggingface!")
|
20 |
+
if "messages" not in st.session_state:
|
21 |
+
st.session_state.messages = [
|
22 |
+
{
|
23 |
+
"role": "assistant",
|
24 |
+
"content": """
|
25 |
+
Hi! I'm a Learner Chatbot. I can answer questions and learn new things!\n
|
26 |
+
Ask me anything and if you want me to learn something do `/add <source>`.\n
|
27 |
+
I can learn mostly everything. :)
|
28 |
+
""",
|
29 |
+
}
|
30 |
+
]
|
31 |
+
|
32 |
+
for message in st.session_state.messages:
|
33 |
+
with st.chat_message(message["role"]):
|
34 |
+
st.markdown(message["content"])
|
35 |
+
|
36 |
+
if prompt := st.chat_input("Ask me anything!"):
|
37 |
+
|
38 |
+
if not st.session_state.chatbot_api_key:
|
39 |
+
st.error("Please enter your Hugging Face Access Token")
|
40 |
+
st.stop()
|
41 |
+
|
42 |
+
os.environ["HUGGINGFACE_ACCESS_TOKEN"] = st.session_state.chatbot_api_key
|
43 |
+
|
44 |
+
app = sql_bot()
|
45 |
+
|
46 |
+
if prompt.startswith("/add"):
|
47 |
+
with st.chat_message("user"):
|
48 |
+
st.markdown(prompt)
|
49 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
50 |
+
prompt = prompt.replace("/add", "").strip()
|
51 |
+
with st.chat_message("assistant"):
|
52 |
+
message_placeholder = st.empty()
|
53 |
+
message_placeholder.markdown("Adding to knowledge base...")
|
54 |
+
app.add(prompt)
|
55 |
+
message_placeholder.markdown(f"Added {prompt} to knowledge base!")
|
56 |
+
st.session_state.messages.append({"role": "assistant", "content": f"Added {prompt} to knowledge base!"})
|
57 |
+
st.stop()
|
58 |
+
|
59 |
+
with st.chat_message("user"):
|
60 |
+
st.markdown(prompt)
|
61 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
62 |
+
|
63 |
+
with st.chat_message("assistant"):
|
64 |
+
msg_placeholder = st.empty()
|
65 |
+
msg_placeholder.markdown("Thinking...")
|
66 |
+
full_response = ""
|
67 |
+
|
68 |
+
for response in app.chat(prompt):
|
69 |
+
msg_placeholder.empty()
|
70 |
+
full_response += response
|
71 |
+
|
72 |
+
msg_placeholder.markdown(full_response)
|
73 |
+
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/data_level0.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c74c887676360f808ec3b8a75a3a6bddfe962185ef42ede9cfde93634ed1a5d0
|
3 |
+
size 3212000
|
db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/header.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ec6df10978b056a10062ed99efeef2702fa4a1301fad702b53dd2517103c746
|
3 |
+
size 100
|
db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/length.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:55f0bebfd6e845a9eea654a9cc9b0d1095f061855b77712e61337f0adc54a476
|
3 |
+
size 4000
|
db/aac7dd20-43c3-4d01-98b4-1a0d07b17a28/link_lists.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
3 |
+
size 0
|
db/chroma.sqlite3
ADDED
Binary file (209 kB). View file
|
|
embedchain.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"provider": "streamlit.io"
|
3 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit==1.29.0
|
2 |
+
embedchain
|
sql.yaml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
app:
|
2 |
+
config:
|
3 |
+
name: 'streamlit-app'
|
4 |
+
|
5 |
+
llm:
|
6 |
+
provider: huggingface
|
7 |
+
config:
|
8 |
+
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1'
|
9 |
+
temperature: 0.1
|
10 |
+
max_tokens: 2500
|
11 |
+
top_p: 0.1
|
12 |
+
stream: true
|
13 |
+
|
14 |
+
embedder:
|
15 |
+
provider: huggingface
|
16 |
+
config:
|
17 |
+
model: 'sentence-transformers/all-mpnet-base-v2'
|