ArdaSaygan commited on
Commit
3033903
·
1 Parent(s): 5ef7b4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -21,15 +21,15 @@ def chatWithGPT(chatHistory):
21
  return chatHistory
22
 
23
  with gr.Blocks() as demo:
24
- chatHistory = []
25
 
26
- def generateResponse(message):
27
  completion = GPTCompletion(system="You are an AI chatting with a human.", max_tokens=2048, temperature=1.5)
28
  gptResponse = completion.chatComplete(chatHistory,message)
29
  chatHistory.append((message, gptResponse))
30
  return chatHistory
31
 
32
- def pollinize():
33
 
34
  chatList = []
35
  for log in chatHistory:
@@ -47,11 +47,11 @@ with gr.Blocks() as demo:
47
  chatbot = gr.Chatbot().style(height=460)
48
  input = gr.Textbox(label="Messeage")
49
  nextBtn = gr.Button("Send message")
50
- nextBtn.click(generateResponse, input, chatbot, scroll_to_output=True, show_progress=True)
51
 
52
  debatePoll = gr.Textbox(label="Poll")
53
  pollinizeButton = gr.Button("Create a poll")
54
- pollinizeButton.click(pollinize,None, debatePoll, scroll_to_output=True, show_progress=True)
55
 
56
  apikey = gr.Textbox(label="API Key")
57
  apiUpload = gr.Button("Upload custom api key")
 
21
  return chatHistory
22
 
23
  with gr.Blocks() as demo:
24
+ chatHistory = gr.State(value = [])
25
 
26
+ def generateResponse(message, chatHistory):
27
  completion = GPTCompletion(system="You are an AI chatting with a human.", max_tokens=2048, temperature=1.5)
28
  gptResponse = completion.chatComplete(chatHistory,message)
29
  chatHistory.append((message, gptResponse))
30
  return chatHistory
31
 
32
+ def pollinize(chatHistory):
33
 
34
  chatList = []
35
  for log in chatHistory:
 
47
  chatbot = gr.Chatbot().style(height=460)
48
  input = gr.Textbox(label="Messeage")
49
  nextBtn = gr.Button("Send message")
50
+ nextBtn.click(generateResponse, [input, chatHistory], chatbot, scroll_to_output=True, show_progress=True)
51
 
52
  debatePoll = gr.Textbox(label="Poll")
53
  pollinizeButton = gr.Button("Create a poll")
54
+ pollinizeButton.click(pollinize,chatHistory, debatePoll, scroll_to_output=True, show_progress=True)
55
 
56
  apikey = gr.Textbox(label="API Key")
57
  apiUpload = gr.Button("Upload custom api key")