Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
def greet(
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import openai as ai
|
3 |
+
import os
|
4 |
+
import requests
|
5 |
|
6 |
+
def greet(prompt):
|
7 |
+
ai.api_key = os.environ.get("KEY")
|
8 |
+
response = ai.Completion.create(
|
9 |
+
engine="text-davinci-003",
|
10 |
+
prompt=query,
|
11 |
+
temperature=0,
|
12 |
+
max_tokens=2000,
|
13 |
+
top_p=1,
|
14 |
+
frequency_penalty=0,
|
15 |
+
presence_penalty=0)
|
16 |
+
response = response['choices'][0]['text']
|
17 |
+
response = response.strip()
|
18 |
+
response = "\n",response,"\n"
|
19 |
+
return response
|
20 |
|
21 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
22 |
iface.launch()
|