|
import gradio as gr |
|
import openai |
|
import os |
|
|
|
openai.api_key = os.environ['openai'] |
|
|
|
|
|
def describe(names): |
|
print(f"hi{names}") |
|
completion = openai.Completion.create( |
|
engine='text-davinci-003', |
|
prompt=names, |
|
max_tokens=210, |
|
temperature=0.97, |
|
frequency_penalty=0.2, |
|
presence_penalty= 0.25, |
|
top_p=1) |
|
|
|
result =completion.choices[0].text |
|
if not result : |
|
result = "Could you be any more boring?" |
|
|
|
return result |
|
|
|
|
|
|
|
iface = gr.Interface(fn=describe, inputs=gr.Textbox(label="Your DND character",show_label=True), |
|
outputs=gr.Textbox(label="The character",show_label=True)) |
|
iface.launch() |