Prasanna18 commited on
Commit
5257a62
·
1 Parent(s): dfdd123

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +6 -7
  2. app.py +95 -0
  3. data.csv +32 -0
  4. requirements.txt +14 -0
README.md CHANGED
@@ -1,13 +1,12 @@
1
  ---
2
- title: SujokTherapy
3
- emoji: 💻
4
- colorFrom: pink
5
- colorTo: green
6
  sdk: streamlit
7
- sdk_version: 1.27.2
8
  app_file: app.py
9
  pinned: false
10
- license: llama2
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: SuJokEase!
3
+ emoji: 🩺
4
+ colorFrom: #FF5733
5
+ colorTo: #FFBF00
6
  sdk: streamlit
7
+ sdk_version: 1.25.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
+
app.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #shree
2
+ import streamlit as st
3
+ from streamlit_chat import message
4
+ from langchain.chains import ConversationalRetrievalChain
5
+ from langchain.document_loaders import DirectoryLoader
6
+ from langchain.document_loaders import PyPDFLoader
7
+ from langchain.embeddings import HuggingFaceEmbeddings
8
+ from langchain.llms import CTransformers
9
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
10
+ from langchain.vectorstores import FAISS
11
+ from langchain.memory import ConversationBufferMemory
12
+ from langchain.document_loaders.csv_loader import CSVLoader
13
+
14
+
15
+ st.set_page_config(
16
+ page_title="SuJokEase",
17
+ page_icon="🩺",
18
+ layout="wide",
19
+ initial_sidebar_state="expanded",
20
+ )
21
+
22
+ from langchain.document_loaders.csv_loader import CSVLoader
23
+ loader = CSVLoader(file_path='data.csv')
24
+ documents = loader.load()
25
+
26
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=500,chunk_overlap=50)
27
+ text_chunks = text_splitter.split_documents(documents)
28
+
29
+ embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2",
30
+ model_kwargs={'device':"cpu"})
31
+
32
+ vector_store = FAISS.from_documents(text_chunks,embeddings)
33
+
34
+ llm = CTransformers(model="model.bin",model_type="llama",
35
+ config={'max_new_tokens':128,'temperature':0.01})
36
+
37
+ memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
38
+
39
+ chain = ConversationalRetrievalChain.from_llm(llm=llm,chain_type='stuff',
40
+ retriever=vector_store.as_retriever(search_kwargs={"k":2}),
41
+ memory=memory)
42
+
43
+ # Sidebar for user input
44
+ st.sidebar.title("SuJokEase🩺")
45
+ st.sidebar.info("A Conversational Retrieval Chain Chat-Bot for Sujok Therapy Points Conversational Retrieval Chain Chat-Bot for Sujok Therapy weather you are Students, Working Professional or in situations where you need instant relaxation. We are at your Back! ")
46
+ github_link = "[GitHub]()"
47
+ st.sidebar.info("To contribute and Sponser - " + github_link)
48
+
49
+ st.title("A Conversational Retrieval Chain Chat-Bot for Sujok Therapy Points🩺")
50
+ st.text("Your wellness companion for instant relaxation.")
51
+
52
+
53
+ def conversation_chat(query):
54
+ result = chain({"question": query, "chat_history": st.session_state['history']})
55
+ st.session_state['history'].append((query, result["answer"]))
56
+ return result["answer"]
57
+
58
+ def initialize_session_state():
59
+ if 'history' not in st.session_state:
60
+ st.session_state['history'] = []
61
+
62
+ if 'generated' not in st.session_state:
63
+ st.session_state['generated'] = ["Hello! Ask me anything about Pains"]
64
+
65
+ if 'past' not in st.session_state:
66
+ st.session_state['past'] = ["Hello!"]
67
+
68
+ def display_chat_history():
69
+ reply_container = st.container()
70
+ container = st.container()
71
+
72
+ with container:
73
+ with st.form(key='my_form', clear_on_submit=True):
74
+ user_input = st.text_input("Question:", placeholder="Ask anything about Sujok Thearpy", key='input')
75
+ submit_button = st.form_submit_button(label='Send')
76
+
77
+ if submit_button and user_input:
78
+ output = conversation_chat(user_input)
79
+
80
+ st.session_state['past'].append(user_input)
81
+ st.session_state['generated'].append(output)
82
+
83
+ if st.session_state['generated']:
84
+ with reply_container:
85
+ for i in range(len(st.session_state['generated'])):
86
+ message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="robot")
87
+ message(st.session_state["generated"][i], key=str(i), avatar_style="superhero")
88
+
89
+ # Initialize session state
90
+ initialize_session_state()
91
+ # Display chat history
92
+ display_chat_history()
93
+
94
+
95
+
data.csv ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Condition,Point
2
+ Headache,"Thumb tip, Tips of all fingers"
3
+ Eye Problems,"Index finger tip, Upper tip of the index finger"
4
+ Ear Issues,Middle finger tip
5
+ Nose and Sinus,"Ring finger tip, Base of the thumb (near the nail)"
6
+ Throat Discomfort,Little finger tip
7
+ Heart and Chest,Base of the thumb (near the wrist)
8
+ Lung and Respiratory,Upper part of the thumb (near the nail)
9
+ Stomach Disorders,Below the thumb
10
+ Liver and Gallbladder,Thumb joint area
11
+ Kidney and Urinary,Middle of the palm
12
+ Digestive Problems,Center of the palm
13
+ Back Pain,"Wrist area, Lower wrist area"
14
+ Stress and Anxiety,"Point between the thumb and index finger, Points on the palm's center"
15
+ Insomnia,"Point between the thumb and index finger, Lower wrist area"
16
+ Fatigue,"Wrist area between the thumb and wrist, Upper wrist area, Outer edge of the little finger, Base of the middle finger"
17
+ Nausea,"Point below the thumb, Tip of the middle finger"
18
+ Joint Pain,"Joints of fingers and thumb, Tip of the ring finger"
19
+ Menstrual Issues,Lower area of the thumb
20
+ Diabetes,"Tip of the thumb, Thumb joint area"
21
+ Hypertension,Middle finger joint area
22
+ Immune System,"Upper part of the index finger, Outer edge of the thumb"
23
+ Digestive Disorders,"Points along the middle finger, Base of the thumb"
24
+ Hormonal Balance,"Center of the index finger, Point between the middle and ring finger"
25
+ Constipation,Point below the middle finger
26
+ Sciatica,"Outer edge of the hand, near the little finger"
27
+ Weight Management,Upper edge of the palm
28
+ Skin Issues,Points on the palm's center and edges
29
+ Blood Circulation,"Circular motions around the palm, Point between the middle and ring finger"
30
+ Anxiety,"Point between the index and middle finger, Points on the palm's center, Base of the little finger"
31
+ Depression,Lower wrist area
32
+ Knee Pain,"Tip of the thumb and index finger, Joints of fingers and thumb"
requirements.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ langchain
2
+ torch
3
+ accelerate
4
+ #bitsandbytes
5
+ transformers
6
+ sentence_transformers
7
+ streamlit
8
+ streamlit_chat
9
+ faiss-cpu
10
+ altair
11
+ tiktoken
12
+ huggingface-hub
13
+ pypdf
14
+ ctransformers