MXNXVMadman commited on
Commit
bf2c8c1
1 Parent(s): 3210e94
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ data/MINI[[:space:]]PROJECT[[:space:]]REPORT_finallllll.pdf filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_chat import message
3
+ from langchain.chains import ConversationalRetrievalChain
4
+ from langchain.document_loaders import PyPDFLoader, DirectoryLoader
5
+ from langchain.embeddings import HuggingFaceEmbeddings
6
+ from langchain.llms import CTransformers
7
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
8
+ from langchain.vectorstores import FAISS
9
+ from langchain.memory import ConversationBufferMemory
10
+
11
+
12
+ loader = DirectoryLoader('data/',glob="*.pdf",loader_cls=PyPDFLoader)
13
+ documents = loader.load()
14
+
15
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=500,chunk_overlap=50)
16
+ text_chunks = text_splitter.split_documents(documents)
17
+
18
+ embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2",
19
+ model_kwargs={'device':"cpu"})
20
+
21
+ #vectorstore
22
+ vector_store = FAISS.from_documents(text_chunks,embeddings)
23
+
24
+ #create llm
25
+ llm = CTransformers(model="llama-2-7b-chat.ggmlv3.q2_K.bin",model_type="llama",
26
+ config={'max_new_tokens':128,'temperature':0.01})
27
+
28
+ memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
29
+
30
+ chain = ConversationalRetrievalChain.from_llm(llm=llm,chain_type='stuff',
31
+ retriever=vector_store.as_retriever(search_kwargs={"k":2}),
32
+ memory=memory)
33
+
34
+ st.title("HealthCare ChatBot 🧑🏽‍⚕️")
35
+ def conversation_chat(query):
36
+ result = chain({"question": query, "chat_history": st.session_state['history']})
37
+ st.session_state['history'].append((query, result["answer"]))
38
+ return result["answer"]
39
+
40
+ def initialize_session_state():
41
+ if 'history' not in st.session_state:
42
+ st.session_state['history'] = []
43
+
44
+ if 'generated' not in st.session_state:
45
+ st.session_state['generated'] = ["Hello! Ask me anything about 🤗"]
46
+
47
+ if 'past' not in st.session_state:
48
+ st.session_state['past'] = ["Hey! 👋"]
49
+
50
+ def display_chat_history():
51
+ reply_container = st.container()
52
+ container = st.container()
53
+
54
+ with container:
55
+ with st.form(key='my_form', clear_on_submit=True):
56
+ user_input = st.text_input("Question:", placeholder="Ask about your Mental Health", key='input')
57
+ submit_button = st.form_submit_button(label='Send')
58
+
59
+ if submit_button and user_input:
60
+ output = conversation_chat(user_input)
61
+
62
+ st.session_state['past'].append(user_input)
63
+ st.session_state['generated'].append(output)
64
+
65
+ if st.session_state['generated']:
66
+ with reply_container:
67
+ for i in range(len(st.session_state['generated'])):
68
+ message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="thumbs")
69
+ message(st.session_state["generated"][i], key=str(i), avatar_style="fun-emoji")
70
+
71
+ # Initialize session state
72
+ initialize_session_state()
73
+ # Display chat history
74
+ display_chat_history()
data/MINI PROJECT REPORT_finallllll.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d5bbae2477549080967c1caf11ab6b5bfee926e1fd224a0d2aa79e177d8111b
3
+ size 1618297
requirements.txt ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==0.23.0
2
+ aiohttp==3.8.5
3
+ aiosignal==1.3.1
4
+ altair==5.1.1
5
+ annotated-types==0.5.0
6
+ async-timeout==4.0.3
7
+ attrs==23.1.0
8
+ blinker==1.6.2
9
+ cachetools==5.3.1
10
+ certifi==2023.7.22
11
+ charset-normalizer==3.2.0
12
+ click==8.1.7
13
+ colorama==0.4.6
14
+ ctransformers==0.2.27
15
+ dataclasses-json==0.5.14
16
+ faiss-cpu==1.7.4
17
+ filelock==3.12.4
18
+ frozenlist==1.4.0
19
+ fsspec==2023.9.1
20
+ gitdb==4.0.10
21
+ GitPython==3.1.36
22
+ greenlet==2.0.2
23
+ huggingface-hub==0.17.1
24
+ idna==3.4
25
+ importlib-metadata==6.8.0
26
+ Jinja2==3.1.2
27
+ joblib==1.3.2
28
+ jsonschema==4.19.0
29
+ jsonschema-specifications==2023.7.1
30
+ langchain==0.0.292
31
+ langsmith==0.0.38
32
+ markdown-it-py==3.0.0
33
+ MarkupSafe==2.1.3
34
+ marshmallow==3.20.1
35
+ mdurl==0.1.2
36
+ mpmath==1.3.0
37
+ multidict==6.0.4
38
+ mypy-extensions==1.0.0
39
+ networkx==3.1
40
+ nltk==3.8.1
41
+ numexpr==2.8.6
42
+ numpy==1.26.0
43
+ packaging==23.1
44
+ pandas==2.1.0
45
+ Pillow==9.5.0
46
+ protobuf==4.24.3
47
+ psutil==5.9.5
48
+ py-cpuinfo==9.0.0
49
+ pyarrow==13.0.0
50
+ pydantic==2.3.0
51
+ pydantic_core==2.6.3
52
+ pydeck==0.8.0
53
+ Pygments==2.16.1
54
+ Pympler==1.0.1
55
+ pypdf==3.16.1
56
+ python-dateutil==2.8.2
57
+ pytz==2023.3.post1
58
+ pytz-deprecation-shim==0.1.0.post0
59
+ PyYAML==6.0.1
60
+ referencing==0.30.2
61
+ regex==2023.8.8
62
+ requests==2.31.0
63
+ rich==13.5.3
64
+ rpds-py==0.10.3
65
+ safetensors==0.3.3
66
+ scikit-learn==1.3.0
67
+ scipy==1.11.2
68
+ sentence-transformers==2.2.2
69
+ sentencepiece==0.1.99
70
+ six==1.16.0
71
+ smmap==5.0.1
72
+ SQLAlchemy==2.0.20
73
+ streamlit==1.26.0
74
+ streamlit-chat==0.1.1
75
+ sympy==1.12
76
+ tenacity==8.2.3
77
+ threadpoolctl==3.2.0
78
+ tiktoken==0.5.1
79
+ tokenizers==0.13.3
80
+ toml==0.10.2
81
+ toolz==0.12.0
82
+ torch==2.0.1
83
+ torchvision==0.15.2
84
+ tornado==6.3.3
85
+ tqdm==4.66.1
86
+ transformers==4.33.2
87
+ typing-inspect==0.9.0
88
+ typing_extensions==4.8.0
89
+ tzdata==2023.3
90
+ tzlocal==4.3.1
91
+ urllib3==2.0.4
92
+ validators==0.22.0
93
+ watchdog==3.0.0
94
+ yarl==1.9.2
95
+ zipp==3.16.2