File size: 933 Bytes
5ce61ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44

import gradio as gr
import openai


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(
#    model="text-davinci-003",
#    prompt=Ask_Question,
#    temperature=0.9,
#    max_tokens=2048,
#    top_p=1,
#    frequency_penalty=0,
#    presence_penalty=0.6,
#    stop=[" Human:", " AI:"]
#    )

  completion = openai.Completion.create(
  engine=model_engine,
  prompt=Ask_Question,
  max_tokens=2048,
  n=1,
  top_p=1,
  stop=None,
  temperature=0.9,)
  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()