This is the code snippet:
`
def data_ingestion_indexing(directory_path):
#constraint parameters
max_input_size = 4096
num_outputs = 512
max_chunk_overlap = 20
chunk_size_limit = 600
#allows the user to explicitly set certain constraint parameters
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
#LLMPredictor is a wrapper class around LangChain's LLMChain that allows easy integration into LlamaIndex
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.5, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
#loads data from the specified directory path
documents = SimpleDirectoryReader(directory_path).load_data()
#constructs service_context
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor, prompt_helper=prompt_helper)
#when first building the index
index = GPTVectorStoreIndex.from_documents(
documents, service_context=service_context
)
#persist index to disk, default "storage" folder
index.storage_context.persist()
return index
def data_querying(input_text):
#rebuild storage context
storage_context = StorageContext.from_defaults(persist_dir="./storage")
#loads index from storage
index = load_index_from_storage(storage_context)
#queries the index with the input text
response = index.as_query_engine().query(input_text)
return response.response