Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
import os
|
4 |
+
|
5 |
+
openai.api_key = os.environ["OPENAI_KEY"]
|
6 |
+
|
7 |
+
def answer_question(question):
|
8 |
+
response = openai.Completion.create(
|
9 |
+
engine="text-davinci-002",
|
10 |
+
prompt="Make a step by step how to based on the prompt: " + question,
|
11 |
+
max_tokens=1024,
|
12 |
+
n=1,
|
13 |
+
stop=None,
|
14 |
+
temperature=0.5,
|
15 |
+
).get("choices")[0].text
|
16 |
+
return response
|
17 |
+
|
18 |
+
iface = gr.Interface(answer_question,
|
19 |
+
gr.inputs.Textbox(lines=5, default="How do i use GPT3?"),
|
20 |
+
gr.outputs.Textbox(),
|
21 |
+
title="How to generator",
|
22 |
+
description="Make how tos from any prompt.")
|
23 |
+
|
24 |
+
iface.launch()
|