dylanmeca commited on
Commit
e1d4f6b
·
1 Parent(s): ed3bbd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -24,6 +24,9 @@ class chatgpt:
24
  self.conversation.append({'role': response.choices[0].message.role, 'content': response.choices[0].message.content})
25
  return self.history, self.history
26
 
 
 
 
27
  def Clean(self):
28
  self.history.clear()
29
  self.conversation.clear()
@@ -38,6 +41,9 @@ with block:
38
  <p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
39
  """)
40
  api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here")
 
 
 
41
  chatbot = gr.Chatbot()
42
  message = gr.Textbox(label="Message")
43
  state = gr.State()
 
24
  self.conversation.append({'role': response.choices[0].message.role, 'content': response.choices[0].message.content})
25
  return self.history, self.history
26
 
27
+ def system_message(self, systemmessage):
28
+ self.conversation.append({"role": "system", "content": f"{systemmessage}"})
29
+
30
  def Clean(self):
31
  self.history.clear()
32
  self.conversation.clear()
 
41
  <p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
42
  """)
43
  api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here")
44
+ system = gr.Textbox(label="System message", placeholder="Example: You are a helpful assistant.")
45
+ sub = gr.Button("Send")
46
+ sub.click(chatgpt.system_message, inputs=[system])
47
  chatbot = gr.Chatbot()
48
  message = gr.Textbox(label="Message")
49
  state = gr.State()