EngrZiaQazi commited on
Commit
6e617c3
1 Parent(s): 894ceac

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+
4
+
5
+ def Question(OpenAI_Key, Ask_Question):
6
+ # pass the generated text to audio
7
+ openai.api_key = OpenAI_Key
8
+ # Set up the model and prompt
9
+ model_engine = "text-davinci-003"
10
+ #prompt = "who is alon musk?"
11
+ # Generate a response
12
+ completion = openai.Completion.create(
13
+ engine=model_engine,
14
+ prompt=(f"{Ask_Question}"),
15
+ max_tokens=1024,
16
+ n=1,
17
+ stop=None,
18
+ temperature=0.5,)
19
+ response = completion.choices[0].text
20
+ #out_result=resp['message']
21
+ return response
22
+
23
+
24
+ demo = gr.Interface(
25
+ title='OpenAI ChatGPT Application',
26
+ fn=Question,
27
+ inputs=["text", "text"],
28
+ outputs="text",)
29
+
30
+ demo.launch()