Xhaheen commited on
Commit
c7da8c9
1 Parent(s): bbd3783

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import numpy as np
3
+ import os
4
+ import gradio as gr
5
+
6
+ openai.api_key = os.environ["api_key"]
7
+ engine = os.environ["engine"]
8
+
9
+
10
+ def happytt(temperature,max_tokens,text):
11
+
12
+ response = openai.Completion.create(
13
+ engine=engine,
14
+ prompt=text,
15
+ temperature=temperature,
16
+ max_tokens=max_tokens,
17
+ top_p=1,
18
+ frequency_penalty=0,
19
+ presence_penalty=0
20
+ )
21
+
22
+ return response.choices[0].text
23
+
24
+
25
+ iface = gr.Interface( happytt,[ gr.inputs.Slider(0, 1, step=0.1),gr.inputs.Slider(1, 4000, step=1),
26
+ gr.inputs.Textbox(type='str',
27
+ label="input prompt")],
28
+ "text")
29
+ iface.launch(debug=True)