I ran the following code which is based on Langchain and Chroma and it is supposed to be functioning in a production environment with users as a client facing chat bot so I expect it or maybe I should rather say I desire that it should run in one or two seconds but I instead found that it takes about half a minute just for this portion to run and that is way too slow for my use case and if you have any advice I would really appreciate that to make it quicker thank you so much for your very valuable time and assistance!
def generate_chain():
chain = load_qa_with_sources_chain(
OpenAI(temperature=0, openai_api_key=openai.api_key),
chain_type="map_reduce"
)
return chain
def ask_docs(relevant_documents, query):
chain = generate_chain()
sourced_answer_obj = chain(
{"input_documents": [relevant_document[0] for relevant_document in relevant_documents],
"question": query}, return_only_outputs=True)
sourced_answer_str = sourced_answer_obj['output_text'].strip()
return sourced_answer_str
I tried the code above I expected it to take about a second or less and it ended up taking half a minute