I have an issue, I want my chatbot to display a welcome message in the output textbox when the user arrive on the website. Everything else work great, but just that message don't display itself. I'm using VSCode, python and the OpenAI API for a simple chatbot to help my gran'ma.
Here's my actual code :
messages = [
{"role": "system", "content": "assistant", "content": "Welcome, I am an assistant"}
]
def CustomChatGPT(users_input):
if not messages:
messages.append({"role": "system", "content": "assistant", "content": "Welcome I'm an assistant"})
return messages[0]["content"]
messages.append({"role": "user", "content": users_input})
response = openai.Completion.create(
model="gpt-3.5-turbo",
messages=messages
)
ChatGPT_reply = response.choices[0].message.content
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
demo = gradio.Interface(fn=CustomChatGPT, inputs = gradio.outputs.Textbox(label="Posez votre question ici"), outputs=gradio.outputs.Textbox(label="Votre réponse"), title = "FraudAlert")
demo.launch(share=True)
The place where the output is and the welcome message should be
What can be wrong, got no error, everything seems okay... Thanks