I have this code where I am passing file path as input. I want you to convert this code into a function. So that I can use that function to give another file path as input. And based new file input all the new embeddings and everything should be created..

import bs4
from langchain import hub
from langchain_chroma import Chroma
from langchain_community.document_loaders import WebBaseLoader
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnablePassthrough
from langchain_openai import OpenAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
import os
from langchain.document_loaders import PyPDFLoader
from langchain.document_loaders import PyPDFDirectoryLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
SentenceTransformerEmbeddings = HuggingFaceEmbeddings
from langchain.vectorstores import Chroma
from langchain_groq.chat_models import ChatGroq
from langchain import HuggingFacePipeline, PromptTemplate
from langchain.chains import RetrievalQA


pdf_folder_path = '/home/ritik1s/Downloads/Assessment/Exercise1/'
loader = PyPDFDirectoryLoader(pdf_folder_path)
docs = loader.load()

text_splitter = RecursiveCharacterTextSplitter(
    chunk_size=1000, chunk_overlap=200, add_start_index=True
)
all_splits = text_splitter.split_documents(docs)

embedding = SentenceTransformerEmbeddings(model_name= "all-MiniLM-L12-v1")

persist_directory = "vector_db"

vectordb = Chroma.from_documents(documents=all_splits, embedding=embedding, persist_directory=persist_directory)

llm = ChatGroq(
    model_name="llama-3.1-70b-versatile", 
    api_key = "<TRUFFLEHOG_REDACTED_GROQ>",max_tokens=2000)


DEFAULT_SYSTEM_PROMPT = """
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.

If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
""".strip()


def generate_prompt(prompt: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT) -> str:
    return f"""

 <>
{system_prompt}
<>

{prompt} 

""".strip()

SYSTEM_PROMPT = """
You are provided with financial documents containing various financial entities related to investments, fees, expenses, and returns. Your task is to extract specific fields related to the Investor/LP share, not the total or fund amounts. The fields to be extracted are listed below, along with specific instructions for each.

Fields to Extract:

Investments (Investor/LP share, not total nor fund):
Extract the amount related to the investor's share.
If multiple investments are present, use nested JSON format.
If the word "investments" is not explicitly mentioned, look for the amount in "capital call."
Management Fee (Investor/LP share, not total nor fund):
Extract the amount where the term "management" explicitly appears.
If multiple management fees are present, extract each one.
Partnership Expenses (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Travel & Entertainment (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Legal (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Accounting, Administration or IT (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Organization Costs (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Bank Fees (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Due Diligence (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Custody Fees (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Other (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Partnership Expenses - Audit & Tax Preparatory (Investor/LP share, not total nor fund):
Extract the amount where the term "partnership" explicitly appears.
Placement Agent Fees (Investor/LP share, not total nor fund):
Extract the amount related to placement agent fees.
Subsequent Close Interest (Investor/LP share, not total nor fund):
Extract the amount related to subsequent close interest.
Working Capital (Investor/LP share, not total nor fund):
Extract the amount related to working capital.
Deemed GP Contribution (Investor/LP share, not total nor fund):
Extract the amount related to deemed GP contribution.
Carry (Investor/LP share, not total nor fund):
Extract the amount related to carry.
Clawback (Investor/LP share, not total nor fund):
Extract the amount related to clawback.
Income/Dividends (Investor/LP share, not total nor fund):
Extract the amount related to income or dividends.
Realized Gain/Loss for Cash (Investor/LP share, not total nor fund):
Extract the amount related to realized gain/loss for cash.
If cash is not explicitly provided, assume cash.
Realized Gain/Loss for Stock (Investor/LP share, not total nor fund):
Extract the amount related to realized gain/loss for stock.
If stock is not explicitly provided, say "NOT FOUND."
Return of Capital for Cash (Investor/LP share, not total nor fund):
Extract the amount related to return of capital for cash.
If cash is not explicitly provided, assume cash.
Return of Capital for Management Fees (Investor/LP share, not total nor fund):
Extract the amount related to return of capital for management fees.
If management is not explicitly provided, say "NOT FOUND."
Return of Capital for Partnership Expenses (Investor/LP share, not total nor fund):
Extract the amount related to return of capital for partnership expenses.
If partnership is not explicitly provided, say "NOT FOUND."
Return of Capital for Stock (Investor/LP share, not total nor fund):
Extract the amount related to return of capital for stock.
If stock is not explicitly provided, say "NOT FOUND."
Excess Capital (Investor/LP share, not total nor fund):
Extract the amount related to excess capital.
Tax Withheld (Investor/LP share, not total nor fund):
Extract the amount related to tax withheld.
Temporary Return of Capital for Management Fees (Investor/LP share, not total nor fund):
Extract the amount related to temporary return of capital for management fees.
Temporary Return of Capital for Partnership Expenses (Investor/LP share, not total nor fund):
Extract the amount related to temporary return of capital for partnership expenses.
Temporary Return of Capital for Investment (Investor/LP share, not total nor fund):
Extract the amount related to temporary return of capital for investment.
Recallable (Investor/LP share, not total nor fund):
Extract the amount related to recallable capital.
Instructions:

Ensure that each extracted field is specific to the Investor/LP share.
Use nested JSON format for multiple entries under the same category.
Follow the specific instructions for each field to ensure accurate extraction.
"""

template = generate_prompt(
    """
{context}

Question: {question}
""",
    system_prompt=SYSTEM_PROMPT,
)

prompt = PromptTemplate(template=template, input_variables=["context", "question"])
qa_chain = RetrievalQA.from_chain_type(
    llm=llm,
    chain_type="stuff",
    retriever=vectordb.as_retriever(search_kwargs={"k": 5}),
    return_source_documents=True,
    chain_type_kwargs={"prompt": prompt},
)

result = qa_chain("""Process the document and extract all the given entities. for null values set as Not found""")
result['result']