#How to build a prompt which answers only to the context we specified

20 messages · Page 1 of 1 (latest)

clever trench
#

Answer the question only related to the topics

import openai openai.api_key="sk-xxx" response = openai.ChatCompletion.create( model='gpt-3.5-turbo', messages=[ {'role': 'system', 'content': "Answer the question only related to the topics of health if they ask outside scope queries, say That I have been trained to answer only health related queries"}, {'role': 'user', 'content': 'python code for factorial'} ], max_tokens=100, temperature=0, )

Returns python code for factorial

clever trench
#

@sweet socket @fiery kettle please advise

sweet socket
#

use the user message to make instructions I suppose

#

replace the system role with user

#

In this model the system message doesn’t weigh so much

clever trench
sweet socket
#

Maybe you can change the order of the two messages. First send the passage about which you will ask some questions

#

Then say answer the question I send you later based on the passage before. If there’s not any relevant information for the question say i don’t know

#

finally send the question

clever trench
#

could you please send the modified code

import openai openai.api_key="sk-xxx" response = openai.ChatCompletion.create( model='gpt-3.5-turbo', messages=[ {'role': 'assitant', 'content': "Answer the question only related to the topics of health if they ask outside scope queries, say That I have been trained to answer only health related queries"}, {'role': 'user', 'content': 'python code for factorial'} ], max_tokens=100, temperature=0, )

sweet socket
#

this is the part of message:

#

{'role': 'user', 'content': 'replace with your passage here'}

#

{'role': 'user', 'content': 'I will later ask you a question about the passage I sent you before. Answer the question based on the passage, if there’s nothing relevant to the question from the passage, just reply I don’t know'}

#

{'role': 'user', 'content': 'replace with your question here'}

sweet socket
clever trench
#

No luck!

import openai
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[
{'role': 'user', 'content': "Answer the question only related to the topics of health if they ask outside scope queries, say That I have been trained to answer only health related queries"},
{'role': 'user', 'content': 'I will later ask you a question about the passage I sent you before. Answer the question based on the passage, if there’s nothing relevant to the question from the passage, just reply I don’t know'},
{'role': 'user', 'content': 'python code for factorial'}
],
max_tokens=100,
temperature=0,
)

print(response)

sweet socket
#

the first user content should be the passage you ask questions about

#

So what’s the pyson code for factorial? it should be your question there i suppose

uneven oak
#

Look into the llama_index library @clever trench