Spaces:
Runtime error
Runtime error
charlesfrye
commited on
Commit
•
7be50ca
1
Parent(s):
41d9b0f
adds a dummy openai api call
Browse files
app.py
CHANGED
@@ -1,8 +1,22 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
|
4 |
def greet(name):
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
8 |
|
|
|
1 |
+
import logging
|
2 |
+
import os
|
3 |
+
|
4 |
import gradio as gr
|
5 |
+
import openai
|
6 |
|
7 |
|
8 |
def greet(name):
|
9 |
+
|
10 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
11 |
+
result = openai.Completion.create(
|
12 |
+
model="text-davinci-003",
|
13 |
+
prompt="Say this is a test",
|
14 |
+
max_tokens=7,
|
15 |
+
temperature=0
|
16 |
+
)
|
17 |
+
logging.info(result)
|
18 |
+
model_response = result["choices"][0]["text"]
|
19 |
+
return "Hello " + name + "!!" + "\n\n" + model_response
|
20 |
|
21 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
22 |
|