File size: 661 Bytes
902bc7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
import openai


def Question(OpenAI_Key, Ask_Question):
  # pass the generated text to audio
  openai.api_key = OpenAI_Key
  # 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=(f"{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", "text"],
    outputs="text",)

demo.launch()