Spaces:
Runtime error
Runtime error
Danil
commited on
Commit
·
f6af407
1
Parent(s):
4d56776
Add token that indicate the end of the generation
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ 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,
|
|
@@ -16,7 +16,8 @@ def happytt(temperature,max_tokens,text):
|
|
| 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
|
|
@@ -39,5 +40,7 @@ https://beta.openai.com/examples?category=code'''
|
|
| 39 |
|
| 40 |
iface = gr.Interface( happytt,[ gr.inputs.Slider(0, 1, step=0.1),gr.inputs.Slider(150, 4000, step=1),
|
| 41 |
gr.inputs.Textbox(type='str',
|
| 42 |
-
label="input prompt")
|
|
|
|
|
|
|
| 43 |
iface.launch(debug=True)
|
|
|
|
| 7 |
engine = os.environ["engine"]
|
| 8 |
|
| 9 |
|
| 10 |
+
def happytt(temperature,max_tokens,text,stop):
|
| 11 |
|
| 12 |
response = openai.Completion.create(
|
| 13 |
engine=engine,
|
|
|
|
| 16 |
max_tokens=max_tokens,
|
| 17 |
top_p=1,
|
| 18 |
frequency_penalty=0,
|
| 19 |
+
presence_penalty=0,
|
| 20 |
+
stop=[stop]
|
| 21 |
)
|
| 22 |
|
| 23 |
return response.choices[0].text
|
|
|
|
| 40 |
|
| 41 |
iface = gr.Interface( happytt,[ gr.inputs.Slider(0, 1, step=0.1),gr.inputs.Slider(150, 4000, step=1),
|
| 42 |
gr.inputs.Textbox(type='str',
|
| 43 |
+
label="input prompt"),
|
| 44 |
+
gr.inputs.Textbox(type='str',
|
| 45 |
+
label="Token that indicate the end of the generation")],"text", title = title, description = description )
|
| 46 |
iface.launch(debug=True)
|