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