kpkishankrishna commited on
Commit
e4e0c90
1 Parent(s): 9cecb1c

First commit

Browse files
Files changed (2) hide show
  1. app.py +30 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import newspaper
2
+ from newspaper import*
3
+ import gradio as gr
4
+ import openai
5
+ openai.api_key = "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"
6
+ import validators
7
+ def predict(url_or_text, prompt, temperature, max_tokens):
8
+ text = url_or_text
9
+ if validators.url(url_or_text):
10
+ article = Article(url="%s" % (url_or_text), language='en')
11
+ article.download()
12
+ article.parse()
13
+ text = article.text
14
+ response = openai.Completion.create(
15
+ model="text-davinci-003",
16
+ prompt = text + "\n"+ prompt,
17
+ temperature=int(temperature),
18
+ max_tokens=int(max_tokens),
19
+ top_p=1,
20
+ frequency_penalty=0.0,
21
+ presence_penalty=1
22
+ )
23
+ return response.choices[0].text
24
+ intr = gr.Interface(predict, [gr.Textbox(value="https://www.datasciencecentral.com/will-chatgpt-make-fraud-easier/"),gr.Textbox(value="tl:dr"),gr.Number(value=0.7), gr.Number(value=100)],
25
+ "text", title = "Summmarizer", description = "For default summarizer give prompt as tl:dr, and temprature 0-1, higher the value, the more random will be the output. "
26
+ ,examples=[['https://www.datasciencecentral.com/will-chatgpt-make-fraud-easier/', 'Get the gist of the article',0.7, 100],
27
+ ["A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei."
28
+ ,"tl:dr",0.5, 50],
29
+ ['https://www.datasciencecentral.com/enriching-customer-service-using-sentiment-analysis/','Summerize the crux of the above article for a linkedin post', 0.3,100]])
30
+ intr.launch(inline = False)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ newspaper3k
2
+ openai
3
+ gradio
4
+ validators