Lookimi commited on
Commit
5ce61ea
1 Parent(s): fdf80dc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ import openai
4
+
5
+
6
+ def Question(Ask_Question):
7
+ # pass the generated text to audio
8
+ openai.api_key = "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"
9
+ # Set up the model and prompt
10
+ model_engine = "text-davinci-003"
11
+ #prompt = "who is alon musk?"
12
+ # Generate a response
13
+
14
+
15
+ # completion = openai.Completion.create(
16
+ # model="text-davinci-003",
17
+ # prompt=Ask_Question,
18
+ # temperature=0.9,
19
+ # max_tokens=2048,
20
+ # top_p=1,
21
+ # frequency_penalty=0,
22
+ # presence_penalty=0.6,
23
+ # stop=[" Human:", " AI:"]
24
+ # )
25
+
26
+ completion = openai.Completion.create(
27
+ engine=model_engine,
28
+ prompt=Ask_Question,
29
+ max_tokens=2048,
30
+ n=1,
31
+ top_p=1,
32
+ stop=None,
33
+ temperature=0.9,)
34
+ response = completion.choices[0].text
35
+ #out_result=resp['message']
36
+ return response
37
+
38
+ demo = gr.Interface(
39
+ title='OpenAI ChatGPT Application',
40
+ fn=Question,
41
+ inputs="text", outputs="text")
42
+
43
+ demo.launch()