mehmet0001 commited on
Commit
ec16604
·
verified ·
1 Parent(s): 3c03a29

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +44 -40
main.py CHANGED
@@ -1,41 +1,45 @@
1
- from openai import OpenAI
2
- import crawl_the_site
3
- import create_database
4
-
5
- api_key = input("enter your OpenRouter api key : ")
6
- start = input("enter the documentation link : ")
7
- limit = int(input("enter the limit for crawling (how many links before stopping) : "))
8
-
9
- print("")
10
- txt = crawl_the_site.crawl(start,limit)
11
- collection = create_database.create_database(txt)
12
-
13
- openai_client = OpenAI(base_url="https://openrouter.ai/api/v1",api_key=api_key)
14
-
15
- prompt_template = """Answer the question only according to the information provided below. Answer only the user's question, dont give additional information.
16
- ## Information :
17
- {}
18
-
19
- ## Question :
20
- # {}"""
21
-
22
- while True:
23
- q = input("prompt : ")
24
-
25
- results = collection.query(query_texts=[q],n_results=5)
26
- infos = results["documents"][0]
27
-
28
- info_text = ""
29
- for info in infos:
30
- info_text += info + "\n---\n"
31
- info_text = info_text.strip()
32
-
33
- prompt = prompt_template.format(info_text,q)
34
-
35
- completion = openai_client.chat.completions.create(
36
- extra_headers={},
37
- extra_body={},
38
- model="deepseek/deepseek-r1:free",
39
- messages=[{"role":"user","content":prompt}])
40
-
 
 
 
 
41
  print((completion.choices[0].message.content)[7:-1])
 
1
+ from openai import OpenAI
2
+ 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 :")
9
+
10
+ start = "asdf"
11
+ limit = 100
12
+
13
+ print("")
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
+
19
+ prompt_template = """Answer the question only according to the information provided below. Answer only the user's question, dont give additional information.
20
+ ## Information :
21
+ {}
22
+
23
+ ## Question :
24
+ # {}"""
25
+
26
+ while True:
27
+ q = input("prompt : ")
28
+
29
+ results = collection.query(query_texts=[q],n_results=5)
30
+ infos = results["documents"][0]
31
+
32
+ info_text = ""
33
+ for info in infos:
34
+ info_text += info + "\n---\n"
35
+ info_text = info_text.strip()
36
+
37
+ prompt = prompt_template.format(info_text,q)
38
+
39
+ completion = openai_client.chat.completions.create(
40
+ extra_headers={},
41
+ extra_body={},
42
+ model="deepseek/deepseek-r1:free",
43
+ messages=[{"role":"user","content":prompt}])
44
+
45
  print((completion.choices[0].message.content)[7:-1])