mehmet0001 commited on
Commit
f1d619d
·
verified ·
1 Parent(s): c93dc3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -5,17 +5,17 @@ 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 :")
9
-
10
- if config:
11
- pass
12
-
13
- start = "asdf"
14
- limit = 100
15
-
16
- print("")
17
- txt = crawl_the_site.crawl(start,limit)
18
- collection = create_database.create_database(txt)
19
 
20
  openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
21
 
@@ -26,10 +26,10 @@ prompt_template = """Answer the question only according to the information provi
26
  ## Question :
27
  # {}"""
28
 
29
- while True:
30
- q = input("prompt : ")
31
 
32
- results = collection.query(query_texts=[q],n_results=5)
 
33
  infos = results["documents"][0]
34
 
35
  info_text = ""
@@ -37,7 +37,7 @@ while True:
37
  info_text += info + "\n---\n"
38
  info_text = info_text.strip()
39
 
40
- prompt = prompt_template.format(info_text,q)
41
 
42
  completion = openai_client.chat.completions.create(
43
  extra_headers={},
@@ -45,4 +45,4 @@ while True:
45
  model="deepseek/deepseek-r1:free",
46
  messages=[{"role":"user","content":prompt}])
47
 
48
- print((completion.choices[0].message.content)[7:-1])
 
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
+ btn = st.button("Start crawling!")
10
+
11
+ if config and btn:
12
+ start = config.split(",")[0]
13
+ limit = int(config.split(",")[1])
14
+
15
+ print("")
16
+ txt = crawl_the_site.crawl(start,limit)
17
+ collection = create_database.create_database(txt)
18
+ st.write("Crawling is done.")
19
 
20
  openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
21
 
 
26
  ## Question :
27
  # {}"""
28
 
29
+ prompt = st.text_area("Enter a prompt (after the crawling is done):")
 
30
 
31
+ if prompt:
32
+ results = collection.query(query_texts=[prompt],n_results=5)
33
  infos = results["documents"][0]
34
 
35
  info_text = ""
 
37
  info_text += info + "\n---\n"
38
  info_text = info_text.strip()
39
 
40
+ prompt = prompt_template.format(info_text,prompt)
41
 
42
  completion = openai_client.chat.completions.create(
43
  extra_headers={},
 
45
  model="deepseek/deepseek-r1:free",
46
  messages=[{"role":"user","content":prompt}])
47
 
48
+ st.write((completion.choices[0].message.content)[7:-1])