Lookimi commited on
Commit
db98017
1 Parent(s): e59aac1

Update ChatGPT_app.py

Browse files
Files changed (1) hide show
  1. ChatGPT_app.py +15 -2
ChatGPT_app.py CHANGED
@@ -1,6 +1,12 @@
 
 
1
  import openai
2
  import gradio as gr
3
  import time
 
 
 
 
4
  def Question(Ask_Question):
5
  # pass the generated text to audio
6
  openai.api_key = "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"
@@ -11,16 +17,23 @@ def Question(Ask_Question):
11
  completion = openai.Completion.create(
12
  engine=model_engine,
13
  prompt=Ask_Question,
14
- max_tokens=1024,
15
  n=1,
16
  stop=None,
17
  temperature=0.5,)
18
  response = completion.choices[0].text
19
  #out_result=resp['message']
 
 
20
  return response
 
 
21
  demo = gr.Interface(
22
  title='OpenAI ChatGPT Application',
23
  fn=Question,
24
  inputs="text", outputs="text")
 
 
25
 
26
- demo.launch(share=true)
 
 
1
+
2
+ # Rewritten Code
3
  import openai
4
  import gradio as gr
5
  import time
6
+
7
+ # keep track of responses
8
+ responses = []
9
+
10
  def Question(Ask_Question):
11
  # pass the generated text to audio
12
  openai.api_key = "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"
 
17
  completion = openai.Completion.create(
18
  engine=model_engine,
19
  prompt=Ask_Question,
20
+ max_tokens=2056,
21
  n=1,
22
  stop=None,
23
  temperature=0.5,)
24
  response = completion.choices[0].text
25
  #out_result=resp['message']
26
+ # add response to the responses list
27
+ responses.append(response)
28
  return response
29
+
30
+ # Create interface
31
  demo = gr.Interface(
32
  title='OpenAI ChatGPT Application',
33
  fn=Question,
34
  inputs="text", outputs="text")
35
+ # Create a secondary window with history of responses
36
+ gr.Interface(title="History", fn=lambda: responses, inputs=None, outputs=None, live=False).launch(share=True)
37
 
38
+ # Launch interface
39
+ demo.launch(share=true)