dylanmeca commited on
Commit
2c753a3
·
1 Parent(s): 0352c7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -24,11 +24,10 @@ 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 system_message(self, systemm):
28
- self.history.clear()
29
  self.conversation.clear()
 
30
  self.conversation = [{"role": "system", "content": f"{systemm}"},]
31
- return self.history, self.history
32
 
33
  def Clean(self):
34
  self.history.clear()
@@ -45,9 +44,10 @@ with block:
45
  <p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
46
  """)
47
  api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here", placeholder="sk-...0VYO")
 
48
  systemm = gr.Textbox(label="System message", placeholder="You are a helpful assistant.")
49
  submit_system = gr.Button("Send")
50
- submit_system.click(chatgpt.system_message, inputs=[systemm], outputs=[chatbot, state])
51
  chatbot = gr.Chatbot()
52
  message = gr.Textbox(label="Message", placeholder="Hi, how are things ?")
53
  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, modelid, systemm):
 
28
  self.conversation.clear()
29
+ self.model_id = str(modelid)
30
  self.conversation = [{"role": "system", "content": f"{systemm}"},]
 
31
 
32
  def Clean(self):
33
  self.history.clear()
 
44
  <p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
45
  """)
46
  api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here", placeholder="sk-...0VYO")
47
+ modelid = gr.Textbox(label="Model ID", placeholder="gpt-3.5-turbo")
48
  systemm = gr.Textbox(label="System message", placeholder="You are a helpful assistant.")
49
  submit_system = gr.Button("Send")
50
+ submit_system.click(chatgpt.system_message, inputs=[modelid, systemm])
51
  chatbot = gr.Chatbot()
52
  message = gr.Textbox(label="Message", placeholder="Hi, how are things ?")
53
  state = gr.State()