Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,6 +24,12 @@ 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()
|
|
@@ -39,6 +45,9 @@ with block:
|
|
| 39 |
<p><center>ChatGPT-Assistant is a chatbot that uses the gpt-3.5-turbo model</center></p>
|
| 40 |
""")
|
| 41 |
api_key = gr.Textbox(type="password", label="Enter your OpenAI API key here", placeholder="sk-...0VYO")
|
|
|
|
|
|
|
|
|
|
| 42 |
chatbot = gr.Chatbot()
|
| 43 |
message = gr.Textbox(label="Message", placeholder="Hi, how are things ?")
|
| 44 |
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, 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()
|
| 35 |
self.conversation.clear()
|
|
|
|
| 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()
|