Maths12
Maths12

Reputation: 989

How can i embed multiple system prompts into my chatbot?

I am using openai and am defining system prompts in my messages.

If i want to add more than one system prompt such as following:

  1. your response must be limited to 2 line
  2. your response must not be rude
  3. your repsonse must be in english or German depening on language from query

how can i incorporate such system prompts below?

Query = 'What are the top 3 dress designs?'

messages = [{"role": "system", "content": "You are a creative fashion designer."},
              {"role": "user", "content": Query},
              {"role": "assistant", "content": "1. Tunic dress 2. Tea dress 3. Kimono dress..."},
              {"role": "user", "content": "continue"}]

I don't understand the role of 'assistant' ; what exactly is meant to go here, when the chatbot can have more than one response and user can more than one query? I have put an example of a query there but this will be dynamic.

Upvotes: 1

Views: 2360

Answers (1)

emrhzc
emrhzc

Reputation: 1480

you don't have to prompt 3 separate system prompts, instead you could just create a single one concatenating all 3 commands, but if you must, you can do it like:

messages = [
    {"role": "system", "content": "Your response must be limited to 2 lines."},
    {"role": "system", "content": "Your response must not be rude."},
    {"role": "system", "content": "Your response must be in English or German depending on the language from the query."},
    {"role": "system", "content": "You are a creative fashion designer."},
    {"role": "user", "content": "what is what?"},
]

assistant is the role of ai, so the response will have a final element with the role of assistant.

you can check it out here: https://platform.openai.com/docs/api-reference/making-requests

Upvotes: 2

Related Questions