lei'ga
lei'ga

Reputation: 1

Extremely slow Langchain WebBaseLoader in the Streamlit built app

I have a problem with Langchain WebBaseLoader in Streamlit. In the following control code, the webpage from the specified URL is read in 0.15 seconds.

from langchain_community.document_loaders import WebBaseLoader
import time

loader = WebBaseLoader("https://joint-research-centre.ec.europa.eu/welcome-jec-website/reference-regulatory-framework/renewable-energy-recast-2030-red-ii_en")
tic = time.perf_counter()
data = loader.load()
tac = time.perf_counter()

print(data)
print(f"Load time = {tac - tic:0.3f}.")

But, when I just initialize the Streamlit app window, the loader.load() takes 10 minutes!

import streamlit as st
from langchain_community.document_loaders import WebBaseLoader
import time

loader = WebBaseLoader("https://joint-research-centre.ec.europa.eu/welcome-jec-website/reference-regulatory-framework/renewable-energy-recast-2030-red-ii_en")
tic = time.perf_counter()
data = loader.load()
tac = time.perf_counter()

st.set_page_config(page_title="Test loader.load() & Streamlit", page_icon="spider")
st.title(f"Load time = {tac - tic:0.3f}.")

The app opens in Firefox, iMac, osx 10.15. Does anyone have an idea what might be going on here? Cheers.

I did the same exercise with Chainlit package and it loads the data with the expected speed. I set up different localhost channels with no success.

Upvotes: 0

Views: 713

Answers (1)

AshhadDevLab
AshhadDevLab

Reputation: 536

Description:

The issue you are facing is quite a unique one, for me its working just fine with or without Streamlit, there might be an issue with Streamlit files or required packages I will suggest you to try and reinstall it once and then repeat the procedure.

Suggested Solution:

for reinstalling a package you first have to uninstall it:

pip uninstall streamlit

after the uninstall is successful reinstall it using:

pip install streamlit

you can also try to upgrade streamlit using:

pip install --upgrade streamlit

Note:

This solution may or may not work, the possible cause of the issue is still not known so no hopes for that.

Upvotes: 0

Related Questions