Spaces:
Running
Running
#pip install openai | |
import openai | |
import gradio as gr | |
openai.api_key = ('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') | |
def generate_text(prompt): | |
completions = openai.Completion.create( | |
engine="text-ada-001", | |
prompt=prompt, | |
max_tokens=256, | |
n=1, | |
stop=None, | |
temperature=0.5, | |
) | |
message = completions.choices[0].text | |
return message.strip() | |
def greet(ask): | |
return generate_text(ask) | |
print(greet) | |
#demo = gr.Interface(fn=greet,inputs=gr.Textbox(lines=5, placeholder="想问什么?"),outputs=gr.Textbox(lines=3, placeholder="等待问答。。。"),) + gr.Accordion("欢迎━(*`∀´*)ノ亻!!") + gr.Markdown("这是随作闲出p做的网站,会特别特别慢!随便用吧。。。") | |
with gr.Blocks() as demo: | |
gr.Markdown("你好") | |
with gr.Tab("Text"): | |
text_input = gr.Textbox(lines=5, placeholder="想问什么?") | |
text_output = gr.Textbox(lines=3, placeholder="等待问答。。。") | |
text_button = gr.Button("Flip") | |
with gr.Accordion("欢迎━(*`∀´*)ノ亻!!"): | |
gr.Markdown("ps:这是随作闲出p做的网站,会特别特别慢!随便用吧。。。") | |
text_button.click(fn=greet,inputs=text_input, outputs=text_output) | |
demo.launch() | |