Spaces:
Runtime error
Runtime error
File size: 1,093 Bytes
1d465c4 3b1ef6f 1d465c4 3b1ef6f 1d465c4 3b1ef6f 1d465c4 3b1ef6f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import openai
import gradio as gr
def metadata_generator(api, text):
openai.api_key = api
response = openai.Completion.create(
engine="text-davinci-003",
prompt="{}\n\nPlease provide 6 semantically similar phrases for the phrase above mentioned".format(
text),
temperature=0.9,
max_tokens=800,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.0
)
resumo = response["choices"][0].text
return resumo
demo = gr.Interface(fn=metadata_generator, inputs=[gr.inputs.Textbox(label='ENTER OPEN AI API KEY'),
gr.inputs.Textbox(label='ENTER A PHRASE FOR SEMANTIC SIMILARITY - Click *Clear* before adding new input')],
outputs=gr.outputs.Textbox(
label='SEMANTIC SIMILAR PHRASES'),
css='div {margin-left: auto; margin-right: auto; width: 100%;\
background-image: url("https://drive.google.com/uc?export=view&id=1KNnISAUcvh2Pt08f-EJZJYCIgkrKw3PI"); repeat 0 0;}').launch(share=False)
|