Spaces:
Runtime error
Runtime error
kpkishankrishna
commited on
Commit
•
613919d
1
Parent(s):
bba8ea3
Adding model in dropdown
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ 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')
|
@@ -12,7 +12,7 @@ def predict(url_or_text, prompt, temperature, max_tokens):
|
|
12 |
article.parse()
|
13 |
text = article.text
|
14 |
response = openai.Completion.create(
|
15 |
-
model=
|
16 |
prompt = text + "\n"+ prompt,
|
17 |
temperature=int(temperature),
|
18 |
max_tokens=int(max_tokens),
|
@@ -21,10 +21,10 @@ def predict(url_or_text, prompt, temperature, max_tokens):
|
|
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 |
-
|
30 |
intr.launch(inline = False)
|
|
|
4 |
import openai
|
5 |
openai.api_key = "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"
|
6 |
import validators
|
7 |
+
def predict(model, 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')
|
|
|
12 |
article.parse()
|
13 |
text = article.text
|
14 |
response = openai.Completion.create(
|
15 |
+
model=model,
|
16 |
prompt = text + "\n"+ prompt,
|
17 |
temperature=int(temperature),
|
18 |
max_tokens=int(max_tokens),
|
|
|
21 |
presence_penalty=1
|
22 |
)
|
23 |
return response.choices[0].text
|
24 |
+
intr = gr.Interface(predict, [gr.Dropdown(["text-curie-001", "text-davinci-003"], value = "text-curie-001"), 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=[["text-curie-001",'https://www.datasciencecentral.com/will-chatgpt-make-fraud-easier/', 'Get the gist of the article',0.7, 100],
|
27 |
+
["text-curie-001","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 |
+
["text-davinci-003",'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)
|