From 5d03f875cb73e06a3e38a97bea6323d26af27fd0 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 14 Sep 2023 15:43:04 -0600 Subject: [PATCH] adjust prompt --- llm_server/routes/openai_request_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llm_server/routes/openai_request_handler.py b/llm_server/routes/openai_request_handler.py index 6fab1e2..3c9b341 100644 --- a/llm_server/routes/openai_request_handler.py +++ b/llm_server/routes/openai_request_handler.py @@ -36,8 +36,8 @@ class OpenAIRequestHandler(RequestHandler): if opts.openai_api_key: try: flagged = check_moderation_endpoint(self.request.json['messages'][-1]['content']) - if flagged: - mod_msg = f"The user's message does not comply with {opts.llm_middleware_name} policies. Offending categories: {json.dumps(flagged['categories'])}" + 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'])}. 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.prompt = self.transform_messages_to_prompt() # print(json.dumps(self.request.json['messages'], indent=4))