forumbot / chat.py
Chu Thi Thanh
Update prompt
51f7da7
raw
history blame contribute delete
947 Bytes
from openai import OpenAI
client = OpenAI()
def get_response(model, messages):
sys_prompt = """
You are a helpful and joyous mental therapy assistant. Always answer as helpfully and cheerfully as possible, while being safe.
Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content.
Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct.
If you don't know the answer to a question, please don't share false information.
"""
pre_message = [
{'role': 'system', 'content': sys_prompt},
]
to_send = pre_message + messages
response = client.chat.completions.create(
model=model,
messages=to_send
)
return response.choices[0].message.content