mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 22:42:05 +00:00
Prompt from file proof of concept using plain text (#127)
This is a simple proof of concept of using external files as templates. I'm still feeling my way around the codebase. As a user, I want to use files as prompts, so it will be easier to manage and test prompts. The future direction is to use a template engine, most likely Mako.
This commit is contained in:
2
tests/unit_tests/data/prompt_file.txt
Normal file
2
tests/unit_tests/data/prompt_file.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Question: {question}
|
||||
Answer:
|
@@ -77,3 +77,11 @@ def test_prompt_invalid_template_format() -> None:
|
||||
Prompt(
|
||||
input_variables=input_variables, template=template, template_format="bar"
|
||||
)
|
||||
|
||||
|
||||
def test_prompt_from_file() -> None:
|
||||
"""Test prompt can be successfully constructed from a file."""
|
||||
template_file = "tests/unit_tests/data/prompt_file.txt"
|
||||
input_variables = ["question"]
|
||||
prompt = Prompt.from_file(template_file, input_variables)
|
||||
assert prompt.template == "Question: {question}\nAnswer:"
|
||||
|
Reference in New Issue
Block a user