dylanmeca commited on
Commit
2c34c42
Β·
1 Parent(s): 8797447

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -16,16 +16,22 @@ def answer_chatgpt(api_key, message, history):
16
  ]
17
  )
18
  # Displaying the answer on the screen
19
- answer = response["choices"][0]["message"]["content"]
20
  history.append((message, answer))
21
  return history, history
22
 
23
  # User input
24
- chatbot = gr.Interface(
25
- fn=answer_chatgpt,
26
- inputs=["text", "text", "state"],
27
- outputs=["chatbot", "state"],
28
- title="πŸ€– ChatGPT-Assistant 🐍",
29
- description="<center> ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model <center>",
30
- )
31
- chatbot.launch(debug=True)
 
 
 
 
 
 
 
16
  ]
17
  )
18
  # Displaying the answer on the screen
19
+ answer = response["choices"][0]["message"]["content"]
20
  history.append((message, answer))
21
  return history, history
22
 
23
  # User input
24
+ block = gr.Blocks()
25
+
26
+ with block:
27
+ gr.Markdown("""<h1><center>πŸ€– ChatGPT-Assistant 🐍</center></h1>
28
+ <p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
29
+ """)
30
+ api_key = gr.Textbox(placeholder="api_key")
31
+ chatbot = gr.Chatbot()
32
+ message = gr.Textbox(placeholder="message")
33
+ state = gr.State()
34
+ submit = gr.Button("Send")
35
+ submit.click(answer_chatgpt, inputs=[api_key, message, state], outputs=[chatbot, state])
36
+
37
+ block.launch(debug=True)