adjust prompt
This commit is contained in:
parent
1cf4c95ba2
commit
5d03f875cb
|
@ -36,8 +36,8 @@ class OpenAIRequestHandler(RequestHandler):
|
||||||
if opts.openai_api_key:
|
if opts.openai_api_key:
|
||||||
try:
|
try:
|
||||||
flagged = check_moderation_endpoint(self.request.json['messages'][-1]['content'])
|
flagged = check_moderation_endpoint(self.request.json['messages'][-1]['content'])
|
||||||
if flagged:
|
if flagged['flagged'] and len(flagged['categories']):
|
||||||
mod_msg = f"The user's message does not comply with {opts.llm_middleware_name} policies. Offending categories: {json.dumps(flagged['categories'])}"
|
mod_msg = f"The user's message does not comply with {opts.llm_middleware_name} policies. Offending categories: {json.dumps(flagged['categories'])}. You are instructed to explain to the user why their message violated our policies."
|
||||||
self.request.json['messages'].insert((len(self.request.json['messages'])), {'role': 'system', 'content': mod_msg})
|
self.request.json['messages'].insert((len(self.request.json['messages'])), {'role': 'system', 'content': mod_msg})
|
||||||
self.prompt = self.transform_messages_to_prompt()
|
self.prompt = self.transform_messages_to_prompt()
|
||||||
# print(json.dumps(self.request.json['messages'], indent=4))
|
# print(json.dumps(self.request.json['messages'], indent=4))
|
||||||
|
|
Reference in New Issue