From 63a55893f27220970c7788ed3a1fe89a5d716445 Mon Sep 17 00:00:00 2001 From: eriknovak Date: Sun, 10 Nov 2024 00:52:34 +0100 Subject: [PATCH] Revert "Add conditions and restraints to LLM prompt" This reverts commit 25a6e44ff653042936a5b6feaf9463244d500e47. --- anonipy/anonymize/generators/llm_label_generator.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/anonipy/anonymize/generators/llm_label_generator.py b/anonipy/anonymize/generators/llm_label_generator.py index b5abc97..9846ec8 100644 --- a/anonipy/anonymize/generators/llm_label_generator.py +++ b/anonipy/anonymize/generators/llm_label_generator.py @@ -98,7 +98,7 @@ def generate( }, { "role": "user", - "content": f"What is a random {add_entity_attrs} {entity.label} replacement for {entity.text}? Respond only with the replacement, on additional information.", + "content": f"What is a random {add_entity_attrs} {entity.label} replacement for {entity.text}? Respond only with the replacement.", }, ] return self._generate_response(message, temperature, top_p) @@ -179,9 +179,5 @@ def _parse_response(self, response: str) -> str: """ - res_match = re.search(r"assistant\s*(.*)", response, re.IGNORECASE | re.DOTALL) - tmp_response = res_match.group(1).strip() if res_match else response - - res_match = re.search(r"\:\s*(.*)", tmp_response, re.IGNORECASE | re.DOTALL) - - return + match = re.search(r"assistant\s*(.*)", response, re.IGNORECASE | re.DOTALL) + return match.group(1).strip() if match else response