Spaces:
Sleeping
Sleeping
Upload 10 files
Browse files- .gitignore +161 -0
- LICENSE +21 -0
- Pipfile +22 -0
- Pipfile.lock +0 -0
- README.md +12 -13
- __init__.py +0 -0
- app.png +0 -0
- requirements.txt +8 -0
- streamlit.py +67 -0
- utils.py +79 -0
.gitignore
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Byte-compiled / optimized / DLL files
|
| 2 |
+
cacert.pem
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.py[cod]
|
| 5 |
+
*$py.class
|
| 6 |
+
|
| 7 |
+
# C extensions
|
| 8 |
+
*.so
|
| 9 |
+
|
| 10 |
+
# Distribution / packaging
|
| 11 |
+
.Python
|
| 12 |
+
build/
|
| 13 |
+
develop-eggs/
|
| 14 |
+
dist/
|
| 15 |
+
downloads/
|
| 16 |
+
eggs/
|
| 17 |
+
.eggs/
|
| 18 |
+
lib/
|
| 19 |
+
lib64/
|
| 20 |
+
parts/
|
| 21 |
+
sdist/
|
| 22 |
+
var/
|
| 23 |
+
wheels/
|
| 24 |
+
share/python-wheels/
|
| 25 |
+
*.egg-info/
|
| 26 |
+
.installed.cfg
|
| 27 |
+
*.egg
|
| 28 |
+
MANIFEST
|
| 29 |
+
|
| 30 |
+
# PyInstaller
|
| 31 |
+
# Usually these files are written by a python script from a template
|
| 32 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 33 |
+
*.manifest
|
| 34 |
+
*.spec
|
| 35 |
+
|
| 36 |
+
# Installer logs
|
| 37 |
+
pip-log.txt
|
| 38 |
+
pip-delete-this-directory.txt
|
| 39 |
+
|
| 40 |
+
# Unit test / coverage reports
|
| 41 |
+
htmlcov/
|
| 42 |
+
.tox/
|
| 43 |
+
.nox/
|
| 44 |
+
.coverage
|
| 45 |
+
.coverage.*
|
| 46 |
+
.cache
|
| 47 |
+
nosetests.xml
|
| 48 |
+
coverage.xml
|
| 49 |
+
*.cover
|
| 50 |
+
*.py,cover
|
| 51 |
+
.hypothesis/
|
| 52 |
+
.pytest_cache/
|
| 53 |
+
cover/
|
| 54 |
+
|
| 55 |
+
# Translations
|
| 56 |
+
*.mo
|
| 57 |
+
*.pot
|
| 58 |
+
|
| 59 |
+
# Django stuff:
|
| 60 |
+
*.log
|
| 61 |
+
local_settings.py
|
| 62 |
+
db.sqlite3
|
| 63 |
+
db.sqlite3-journal
|
| 64 |
+
|
| 65 |
+
# Flask stuff:
|
| 66 |
+
instance/
|
| 67 |
+
.webassets-cache
|
| 68 |
+
|
| 69 |
+
# Scrapy stuff:
|
| 70 |
+
.scrapy
|
| 71 |
+
|
| 72 |
+
# Sphinx documentation
|
| 73 |
+
docs/_build/
|
| 74 |
+
|
| 75 |
+
# PyBuilder
|
| 76 |
+
.pybuilder/
|
| 77 |
+
target/
|
| 78 |
+
|
| 79 |
+
# Jupyter Notebook
|
| 80 |
+
.ipynb_checkpoints
|
| 81 |
+
|
| 82 |
+
# IPython
|
| 83 |
+
profile_default/
|
| 84 |
+
ipython_config.py
|
| 85 |
+
|
| 86 |
+
# pyenv
|
| 87 |
+
# For a library or package, you might want to ignore these files since the code is
|
| 88 |
+
# intended to run in multiple environments; otherwise, check them in:
|
| 89 |
+
# .python-version
|
| 90 |
+
|
| 91 |
+
# pipenv
|
| 92 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
| 93 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
| 94 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
| 95 |
+
# install all needed dependencies.
|
| 96 |
+
#Pipfile.lock
|
| 97 |
+
|
| 98 |
+
# poetry
|
| 99 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
| 100 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
| 101 |
+
# commonly ignored for libraries.
|
| 102 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
| 103 |
+
#poetry.lock
|
| 104 |
+
|
| 105 |
+
# pdm
|
| 106 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
| 107 |
+
#pdm.lock
|
| 108 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
| 109 |
+
# in version control.
|
| 110 |
+
# https://pdm.fming.dev/#use-with-ide
|
| 111 |
+
.pdm.toml
|
| 112 |
+
|
| 113 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
| 114 |
+
__pypackages__/
|
| 115 |
+
|
| 116 |
+
# Celery stuff
|
| 117 |
+
celerybeat-schedule
|
| 118 |
+
celerybeat.pid
|
| 119 |
+
|
| 120 |
+
# SageMath parsed files
|
| 121 |
+
*.sage.py
|
| 122 |
+
|
| 123 |
+
# Environments
|
| 124 |
+
.env
|
| 125 |
+
.venv
|
| 126 |
+
env/
|
| 127 |
+
venv/
|
| 128 |
+
ENV/
|
| 129 |
+
env.bak/
|
| 130 |
+
venv.bak/
|
| 131 |
+
|
| 132 |
+
# Spyder project settings
|
| 133 |
+
.spyderproject
|
| 134 |
+
.spyproject
|
| 135 |
+
|
| 136 |
+
# Rope project settings
|
| 137 |
+
.ropeproject
|
| 138 |
+
|
| 139 |
+
# mkdocs documentation
|
| 140 |
+
/site
|
| 141 |
+
|
| 142 |
+
# mypy
|
| 143 |
+
.mypy_cache/
|
| 144 |
+
.dmypy.json
|
| 145 |
+
dmypy.json
|
| 146 |
+
|
| 147 |
+
# Pyre type checker
|
| 148 |
+
.pyre/
|
| 149 |
+
|
| 150 |
+
# pytype static type analyzer
|
| 151 |
+
.pytype/
|
| 152 |
+
|
| 153 |
+
# Cython debug symbols
|
| 154 |
+
cython_debug/
|
| 155 |
+
|
| 156 |
+
# PyCharm
|
| 157 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
| 158 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
| 159 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
| 160 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
| 161 |
+
#.idea/
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2024 Marsiya Issah
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
Pipfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[[source]]
|
| 2 |
+
url = "https://pypi.org/simple"
|
| 3 |
+
verify_ssl = true
|
| 4 |
+
name = "pypi"
|
| 5 |
+
|
| 6 |
+
[packages]
|
| 7 |
+
openai = "*"
|
| 8 |
+
langchain = "*"
|
| 9 |
+
streamlit = "*"
|
| 10 |
+
python-dotenv = "*"
|
| 11 |
+
langchain-community = "*"
|
| 12 |
+
langchain-openai = "*"
|
| 13 |
+
sentence-transformers = "*"
|
| 14 |
+
pypdf = "*"
|
| 15 |
+
tiktoken = "*"
|
| 16 |
+
lancedb = "*"
|
| 17 |
+
bs4 = "*"
|
| 18 |
+
|
| 19 |
+
[dev-packages]
|
| 20 |
+
|
| 21 |
+
[requires]
|
| 22 |
+
python_version = "3.10"
|
Pipfile.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
### HR - Resume Screening Assistance
|
| 2 |
+
|
| 3 |
+
LangChain | Streamlit | LanceDB | Openai | load_summarize_chain
|
| 4 |
+
|
| 5 |
+

|
| 6 |
+
|
| 7 |
+
## To run this app locally, follow these steps:
|
| 8 |
+
|
| 9 |
+
- Clone the repository
|
| 10 |
+
- `pipenv shell`
|
| 11 |
+
- `pipenv install -r requirement.txt`
|
| 12 |
+
- `streamlit run streamlit.py`
|
|
|
__init__.py
ADDED
|
File without changes
|
app.png
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openai
|
| 2 |
+
langchain
|
| 3 |
+
streamlit
|
| 4 |
+
langchain-community
|
| 5 |
+
sentence-transformers
|
| 6 |
+
tiktoken
|
| 7 |
+
python-dotenv
|
| 8 |
+
pinecone-client
|
streamlit.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
from utils import *
|
| 4 |
+
import uuid
|
| 5 |
+
|
| 6 |
+
#Creating session variables
|
| 7 |
+
if 'unique_id' not in st.session_state:
|
| 8 |
+
st.session_state['unique_id'] =''
|
| 9 |
+
|
| 10 |
+
def main():
|
| 11 |
+
load_dotenv()
|
| 12 |
+
|
| 13 |
+
st.set_page_config(page_title="Resume Screening Assistance", page_icon="📝")
|
| 14 |
+
st.title("HR - Resume Screening Assistance...")
|
| 15 |
+
# st.subheader("I can help you in resume screening process")
|
| 16 |
+
|
| 17 |
+
job_description = st.text_area("Please paste the 'JOB DESCRIPTION' here...", key="desc")
|
| 18 |
+
document_count = st.text_input("Enter the no.of resumes to return",key="count")
|
| 19 |
+
# Upload the Resumes (pdf files)
|
| 20 |
+
pdf = st.file_uploader("Upload resumes here, only PDF files allowed", type=["pdf"], accept_multiple_files=True)
|
| 21 |
+
|
| 22 |
+
submit=st.button("Screen")
|
| 23 |
+
|
| 24 |
+
if submit:
|
| 25 |
+
with st.spinner('Wait for it...'):
|
| 26 |
+
|
| 27 |
+
#Creating a unique ID, so that we can use to query and get only the user uploaded documents from PINECONE vector store
|
| 28 |
+
st.session_state['unique_id']=uuid.uuid4().hex
|
| 29 |
+
|
| 30 |
+
#Create a documents list out of all the user uploaded pdf files
|
| 31 |
+
final_docs_list=create_docs(pdf,st.session_state['unique_id'])
|
| 32 |
+
|
| 33 |
+
#Displaying the count of resumes that have been uploaded
|
| 34 |
+
st.write("*Resumes uploaded* :"+str(len(final_docs_list)))
|
| 35 |
+
|
| 36 |
+
#Create embeddings instance
|
| 37 |
+
embeddings=create_embeddings_load_data()
|
| 38 |
+
|
| 39 |
+
#Push data to PINECONE
|
| 40 |
+
# using already created index automatic-ticket-tool
|
| 41 |
+
table = push_to_lancedb(embeddings)
|
| 42 |
+
|
| 43 |
+
#Fecth relavant documents from LanceDB
|
| 44 |
+
relavant_docs = similar_docs_lancedb(job_description,table,embeddings,final_docs_list)
|
| 45 |
+
|
| 46 |
+
#st.write(relavant_docs)
|
| 47 |
+
|
| 48 |
+
#Introducing a line separator
|
| 49 |
+
st.write(":heavy_minus_sign:" * 30)
|
| 50 |
+
st.success(f"Find below the {document_count} Resumes")
|
| 51 |
+
|
| 52 |
+
# For each item in relavant docs - we are displaying some info of it on the UI
|
| 53 |
+
for idx, resume in enumerate(relavant_docs[:int(document_count)]):
|
| 54 |
+
st.subheader("👉 Resume "+str(idx+1))
|
| 55 |
+
# st.write(resume.page_content)
|
| 56 |
+
|
| 57 |
+
#Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain
|
| 58 |
+
summary = get_summary(relavant_docs[idx])
|
| 59 |
+
print([relavant_docs[idx]])
|
| 60 |
+
st.write("**Summary** : "+summary)
|
| 61 |
+
|
| 62 |
+
st.success("Hope I was able to save your time❤️")
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
#Invoking main function
|
| 66 |
+
if __name__ == '__main__':
|
| 67 |
+
main()
|
utils.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain.vectorstores import LanceDB, Pinecone as pc
|
| 2 |
+
from langchain.llms import OpenAI
|
| 3 |
+
from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
|
| 4 |
+
from langchain.schema import Document
|
| 5 |
+
from pypdf import PdfReader
|
| 6 |
+
from langchain.llms.openai import OpenAI
|
| 7 |
+
from langchain.chains.summarize import load_summarize_chain
|
| 8 |
+
from langchain.llms import HuggingFaceHub
|
| 9 |
+
import lancedb
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
#Extract Information from PDF file
|
| 13 |
+
def get_pdf_text(pdf_doc):
|
| 14 |
+
text = ""
|
| 15 |
+
pdf_reader = PdfReader(pdf_doc)
|
| 16 |
+
for page in pdf_reader.pages:
|
| 17 |
+
text += page.extract_text()
|
| 18 |
+
return text
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
# iterate over files in
|
| 23 |
+
# that user uploaded PDF files, one by one
|
| 24 |
+
def create_docs(user_pdf_list, unique_id):
|
| 25 |
+
docs=[]
|
| 26 |
+
# each pdf file is a doc. We are creating our own Document with it
|
| 27 |
+
for filename in user_pdf_list:
|
| 28 |
+
|
| 29 |
+
chunks=get_pdf_text(filename)
|
| 30 |
+
|
| 31 |
+
#Adding items to our list - Adding data & its metadata
|
| 32 |
+
docs.append(Document(
|
| 33 |
+
page_content=chunks,
|
| 34 |
+
metadata={"name": filename.name,"id":filename.file_id,"type=":filename.type,"size":filename.size,"unique_id":unique_id},
|
| 35 |
+
))
|
| 36 |
+
|
| 37 |
+
return docs # Document chunks list
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
#Create embeddings instance
|
| 41 |
+
def create_embeddings_load_data():
|
| 42 |
+
#embeddings = OpenAIEmbeddings()
|
| 43 |
+
embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
| 44 |
+
return embeddings
|
| 45 |
+
|
| 46 |
+
# push to lancedb
|
| 47 |
+
def push_to_lancedb(embeddings):
|
| 48 |
+
db = lancedb.connect("/lancedb")
|
| 49 |
+
# sample data which will be overwritten when ne dos are uploaded
|
| 50 |
+
table = db.create_table(
|
| 51 |
+
"resumes",
|
| 52 |
+
data=[
|
| 53 |
+
{
|
| 54 |
+
"vector": embeddings.embed_query("Hello World"),
|
| 55 |
+
"text": "Hello World",
|
| 56 |
+
"id": "1",
|
| 57 |
+
}
|
| 58 |
+
],
|
| 59 |
+
mode="overwrite",
|
| 60 |
+
)
|
| 61 |
+
return table
|
| 62 |
+
|
| 63 |
+
def pull_from_lancedb(table, embeddings, docs):
|
| 64 |
+
docsearch = LanceDB.from_documents(documents=docs, embedding = embeddings, connection=table)
|
| 65 |
+
return docsearch
|
| 66 |
+
|
| 67 |
+
def similar_docs_lancedb(query, table, embeddings, docs):
|
| 68 |
+
docsearch = pull_from_lancedb(table, embeddings, docs)
|
| 69 |
+
similar_docs = docsearch.similarity_search(query)
|
| 70 |
+
return similar_docs
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
# Helps us get the summary of a document
|
| 74 |
+
def get_summary(current_doc):
|
| 75 |
+
llm = OpenAI(temperature=0)
|
| 76 |
+
#llm = HuggingFaceHub(repo_id="bigscience/bloom", model_kwargs={"temperature":1e-10})
|
| 77 |
+
chain = load_summarize_chain(llm, chain_type="map_reduce")
|
| 78 |
+
summary = chain.run([current_doc])
|
| 79 |
+
return summary
|