Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Jan 9, 2025
1 parent c676131 commit 6e7384e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions libs/core/kiln_ai/adapters/test_prompt_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
MultiShotChainOfThoughtPromptBuilder,
MultiShotPromptBuilder,
RepairsPromptBuilder,
SavedPromptBuilder,
SimpleChainOfThoughtPromptBuilder,
SimplePromptBuilder,
chain_of_thought_prompt,
Expand All @@ -20,6 +21,7 @@
DataSource,
DataSourceType,
Project,
Prompt,
Task,
TaskOutput,
TaskOutputRating,
Expand Down Expand Up @@ -433,3 +435,38 @@ def test_build_prompt_for_ui(tmp_path):
assert custom_cot_builder.build_prompt() in ui_prompt_custom
assert "# Thinking Instructions" in ui_prompt_custom
assert custom_instruction in ui_prompt_custom


def test_saved_prompt_builder(tmp_path):
task = build_test_task(tmp_path)

prompt = Prompt(
name="test_prompt_name",
prompt="test_prompt",
parent=task,
)
prompt.save_to_file()

builder = SavedPromptBuilder(task=task, prompt_id=prompt.id)
assert builder.build_prompt() == "test_prompt"
assert builder.chain_of_thought_prompt() is None
assert builder.build_prompt_for_ui() == "test_prompt"
assert builder.prompt_id() == prompt.id


def test_saved_prompt_builder_with_chain_of_thought(tmp_path):
task = build_test_task(tmp_path)

prompt = Prompt(
name="test_prompt_name",
prompt="test_prompt",
chain_of_thought_instructions="Think step by step",
parent=task,
)
prompt.save_to_file()

builder = SavedPromptBuilder(task=task, prompt_id=prompt.id)
assert builder.build_prompt() == "test_prompt"
assert builder.chain_of_thought_prompt() == "Think step by step"
assert "Think step by step" in builder.build_prompt_for_ui()
assert builder.prompt_id() == prompt.id

0 comments on commit 6e7384e

Please sign in to comment.