File size: 1,080 Bytes
825dc04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a2f664
 
 
 
a926c23
 
825dc04
 
6a2f664
825dc04
 
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
26
27
28
29
30
31
32
33
34
import openai
import numpy as np
import os
import gradio as gr
 
openai.api_key = os.environ["api_key"]
engine = os.environ["engine"]


def happytt(temperature,max_tokens,text): 

  response = openai.Completion.create(
    engine=engine,
    prompt=text,
    temperature=temperature,
    max_tokens=max_tokens,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0
  )

  return response.choices[0].text


title = "GPT-J-6B"
description = "Gradio Demo for GPT-J 6B, a transformer model trained using Ben Wang's Mesh Transformer JAX. 'GPT-J' refers to the class of model, while '6B' represents the number of trainable parameters. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."

 
 
iface = gr.Interface( happytt,[ gr.inputs.Slider(0, 1, step=0.1),gr.inputs.Slider(1, 4000, step=1),
                               gr.inputs.Textbox(type='str',   
                                                 label="input prompt")], title = title, description = description,
                     "text")
iface.launch(debug=True)