I have two apps that use the same code and the same ‘requirements.txt’ and ‘packages.txt’ files. One is working well, but the other has an error while I don’t use pytesseract in the code.
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your PATH. See README file for more information.
Then I tried to follow instruction to add tesseract-ocr tesseract-ocr-por to packages.txt , it took so long time (several hours to a day) for the app to deploy and after that it stopped
Besides that , I don’t use tesseract in my code , why this error exist ? And why the other application works well without adding tesseract-ocr to packages.txt file while I use the same code and requirements.txt file for 2 applications?
This is my code :
def load_data():
with st.spinner(text=“Loading information – hang tight! This should take 1-2 minutes.”):
loader = DirectoryLoader(“SOURCE_DOCUMENTS/”)
index = VectorstoreIndexCreator().from_loaders([loader])
return index
index = load_data()
if question := st.chat_input(“Your question”):
st.session_state.messages.append({“role”: “user”, “content”: question})
for message in st.session_state.messages:
with st.chat_message(message[“role”]):
st.write(message[“content”])
if st.session_state.messages[-1][“role”] != “assistant”:
with st.chat_message(“assistant”):
with st.spinner(“Thinking…”):
prompt = f"User Query: {question}\n\nContext: Give long and more detailed answer "
response = index.query(prompt, llm = ChatOpenAI(model=“gpt-4-1106-preview”))
engine_link = “https://api.openai.com/v1/chat/completions”
headers = {“Authorization”: f"Bearer {api_key}“}
prompt = f”… \n\nQuestion: {question}\nAnswer:"
payload = {
“messages”: [
{“role”: “system”, “content”: f"OpenAI/gpt-4-1106-preview"},
{“role”: “user”, “content”: prompt}
],
“model”: “gpt-4-1106-preview”,
}
response2 = requests.post(engine_link, headers=headers, json=payload)
if response2.status_code == 200:
response_data = response2.json()
response = response_data[“choices”][0][“message”][“content”]
st.write(response)
message = {“role”: “assistant”, “content”: response}
else:
st.error(f"Error: {response.status_code} - {response.reason}")
st.write(response)
message = {“role”: “assistant”, “content”: response}
st.session_state.messages.append(message)