Enoch1359 commited on
Commit
acd1740
·
verified ·
1 Parent(s): cb638c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -33,22 +33,34 @@ st.title("URL ANALYSER🔗")
33
  st.sidebar.title("Give your URls🔗?")
34
  mp=st.empty()
35
 
 
 
 
 
36
 
37
- url1=st.sidebar.text_input(f"URL 1🔗")
38
- url2=st.sidebar.text_input(f"URL 2🔗")
39
- url3=st.sidebar.text_input(f"URL 3🔗")
40
 
41
 
42
- purs=st.button("gotcha")
43
  if purs:
44
 
45
- st.write(url1)
46
- st.write(url2)
47
- st.write(url3)
48
  mp.text("Loading..URl..Loader....☑️☑️☑️")
49
- sic=UnstructuredURLLoader(urls=[url1,url2,url3])
50
- docs=sic.load()
51
- st.write(len(docs))
 
 
 
 
 
 
 
 
 
 
 
 
52
  mp.text("Loading..txt..splitter....☑️☑️☑️")
53
  tot=RecursiveCharacterTextSplitter.from_tiktoken_encoder(encoding_name="cl100k_base",chunk_size=512,chunk_overlap=16)
54
  doccs=tot.split_documents(docs)
 
33
  st.sidebar.title("Give your URls🔗?")
34
  mp=st.empty()
35
 
36
+ urs=[]
37
+ for i in range(3):
38
+ url=st.sidebar.text_input(f"URL {i+1}🔗")
39
+ urs.append(url)
40
 
 
 
 
41
 
42
 
43
+ purs=st.button("gotcha", disabled=not any(url.strip() for url in urs))
44
  if purs:
45
 
46
+ urs = [url.strip() for url in urs if url.strip()]
47
+ st.write(urs)
 
48
  mp.text("Loading..URl..Loader....☑️☑️☑️")
49
+ valid_urls = [url for url in urs if url.strip()]
50
+ if not valid_urls:
51
+ st.warning("⚠️ No valid URLs entered.")
52
+ st.stop()
53
+ try:
54
+ sic = UnstructuredURLLoader(urls=valid_urls)
55
+ docs = sic.load()
56
+ except Exception as e:
57
+ st.error(f"❌ Failed to load URLs: {e}")
58
+ st.stop()
59
+ if not docs:
60
+ st.warning("⚠️ No content loaded from URLs. This might be due to network restrictions or invalid URLs.")
61
+ st.stop()
62
+ st.write(len(docs))
63
+
64
  mp.text("Loading..txt..splitter....☑️☑️☑️")
65
  tot=RecursiveCharacterTextSplitter.from_tiktoken_encoder(encoding_name="cl100k_base",chunk_size=512,chunk_overlap=16)
66
  doccs=tot.split_documents(docs)