File size: 947 Bytes
cea6169
 
 
 
 
51f7da7
 
 
 
 
 
 
 
cea6169
51f7da7
cea6169
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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