mehmet0001 commited on
Commit
8fe87ce
·
verified ·
1 Parent(s): afb3636

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -3,16 +3,20 @@ import crawl_the_site
3
  import create_database
4
  import streamlit as st
5
 
 
 
6
  api_key = "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"
7
 
8
  config = st.text_area("Enter the start URL and the limit of crawling (in this format : URL,limit):")
9
  config_btn = st.button("Start crawling!")
10
 
11
- start = "https://sern.dev/v4/cli/about/"
12
- limit = 10
13
-
14
- txt = crawl_the_site.crawl(start,limit)
15
- collection = create_database.create_database(txt)
 
 
16
 
17
  openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
18
 
@@ -27,7 +31,7 @@ prompt = st.text_area("Enter a prompt (after the crawling is done):")
27
  prompt_btn = st.button("Enter")
28
 
29
  if prompt and prompt_btn:
30
- results = collection.query(query_texts=[prompt],n_results=5)
31
  infos = results["documents"][0]
32
 
33
  info_text = ""
 
3
  import create_database
4
  import streamlit as st
5
 
6
+ st.session_state.collection = None
7
+
8
  api_key = "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"
9
 
10
  config = st.text_area("Enter the start URL and the limit of crawling (in this format : URL,limit):")
11
  config_btn = st.button("Start crawling!")
12
 
13
+ if config and config_btn:
14
+ start = config.split(",")[0]
15
+ limit = int(config.split(",")[1])
16
+
17
+ txt = crawl_the_site.crawl(start,limit)
18
+ st.session_state.collection = create_database.create_database(txt)
19
+ st.write("Crawling is done.")
20
 
21
  openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
22
 
 
31
  prompt_btn = st.button("Enter")
32
 
33
  if prompt and prompt_btn:
34
+ results = st.session_state.collection.query(query_texts=[prompt],n_results=5)
35
  infos = results["documents"][0]
36
 
37
  info_text = ""