Spaces:
Runtime error
Runtime error
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) | |