awacke1 commited on
Commit
e9775b3
·
1 Parent(s): b3966ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py CHANGED
@@ -8,6 +8,52 @@ API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "
8
  OPENAI_API_KEY= os.environ["HF_TOKEN"] # Add a token to this space . Then copy it to the repository secret in this spaces settings panel. os.environ reads from there.
9
  # Keys for Open AI ChatGPT API usage are created from here: https://platform.openai.com/account/api-keys
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]): #repetition_penalty, top_k
12
 
13
  # 1. Set up a payload
 
8
  OPENAI_API_KEY= os.environ["HF_TOKEN"] # Add a token to this space . Then copy it to the repository secret in this spaces settings panel. os.environ reads from there.
9
  # Keys for Open AI ChatGPT API usage are created from here: https://platform.openai.com/account/api-keys
10
 
11
+
12
+ def get_wiki_summary(search):
13
+ wiki_wiki = wikipediaapi.Wikipedia('en')
14
+ page = wiki_wiki.page(search)
15
+
16
+ isExist = page.exists()
17
+ if not isExist:
18
+ return isExist, "Not found", "Not found", "Not found", "Not found"
19
+
20
+ pageurl = page.fullurl
21
+ pagetitle = page.title
22
+ pagesummary = page.summary[0:60]
23
+ pagetext = get_pagetext(page.text)
24
+
25
+ backlinks = page.backlinks
26
+ linklist = ""
27
+ for link in backlinks.items():
28
+ pui = link[0]
29
+ linklist += pui + " , "
30
+ a=1
31
+
32
+ categories = page.categories
33
+ categorylist = ""
34
+ for category in categories.items():
35
+ pui = category[0]
36
+ categorylist += pui + " , "
37
+ a=1
38
+
39
+ links = page.links
40
+ linklist2 = ""
41
+ for link in links.items():
42
+ pui = link[0]
43
+ linklist2 += pui + " , "
44
+ a=1
45
+
46
+ sections = page.sections
47
+
48
+ ex_dic = {
49
+ 'Entity' : ["URL","Title","Summary", "Text", "Backlinks", "Links", "Categories"],
50
+ 'Value': [pageurl, pagetitle, pagesummary, pagetext, linklist,linklist2, categorylist ]
51
+ }
52
+
53
+ df = pd.DataFrame(ex_dic)
54
+
55
+ return df
56
+
57
  def predict(inputs, top_p, temperature, chat_counter, chatbot=[], history=[]): #repetition_penalty, top_k
58
 
59
  # 1. Set up a payload