File size: 697 Bytes
3fca12f
 
 
 
 
 
 
 
 
 
 
 
 
ee45ce7
3fca12f
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
import openai
import os

openai.api_key = os.environ["OPENAI_KEY"]

def answer_question(question):
    response = openai.Completion.create(
        engine="text-davinci-002",
        prompt="Make a step by step how to based on the prompt: " + question,
        max_tokens=1024,
        n=1,
        stop=None,
        temperature=0.7,
    ).get("choices")[0].text
    return response

iface = gr.Interface(answer_question, 
                     gr.inputs.Textbox(lines=5, default="How do i use GPT3?"),
                     gr.outputs.Textbox(), 
                     title="How to generator", 
                     description="Make how tos from any prompt.")

iface.launch()