From 1835e8a6812e52aacdc50cfe60e2192a7f172b3a Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Mon, 14 Nov 2022 21:30:33 -0800 Subject: [PATCH] prompt nit (#141) doing some cleanup, and i think this just simplifies things... --- langchain/prompts/prompt.py | 3 +-- tests/unit_tests/test_prompt.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/langchain/prompts/prompt.py b/langchain/prompts/prompt.py index b84b771814..f27c678f04 100644 --- a/langchain/prompts/prompt.py +++ b/langchain/prompts/prompt.py @@ -94,8 +94,7 @@ class Prompt(BaseModel, BasePrompt): Returns: The final prompt generated. """ - example_str = example_separator.join(examples) - template = prefix + example_str + suffix + template = example_separator.join([prefix, *examples, suffix]) return cls(input_variables=input_variables, template=template) @classmethod diff --git a/tests/unit_tests/test_prompt.py b/tests/unit_tests/test_prompt.py index 80a7fca4a7..7265cae347 100644 --- a/tests/unit_tests/test_prompt.py +++ b/tests/unit_tests/test_prompt.py @@ -51,8 +51,8 @@ Question: {question} Answer:""" input_variables = ["question"] example_separator = "\n\n" - prefix = """Test Prompt:\n\n""" - suffix = """\n\nQuestion: {question}\nAnswer:""" + prefix = """Test Prompt:""" + suffix = """Question: {question}\nAnswer:""" examples = [ """Question: who are you?\nAnswer: foo""", """Question: what are you?\nAnswer: bar""",