import openai import gradio as gr import time def Question(Ask_Question): # pass the generated text to audio openai.api_key = "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" # Set up the model and prompt model_engine = "text-davinci-003" #prompt = "who is alon musk?" # Generate a response completion = openai.Completion.create( engine=model_engine, prompt=Ask_Question, max_tokens=1024, n=1, stop=None, temperature=0.5,) response = completion.choices[0].text #out_result=resp['message'] return response demo = gr.Interface( title='OpenAI ChatGPT Application', fn=Question, inputs="text", outputs="text") demo.launch(share=true)