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 f121ce4 commit 90ca92b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions libs/core/kiln_ai/adapters/test_prompt_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ def test_prompt_builder_from_ui_name(task_with_examples):
with pytest.raises(ValueError, match="Prompt ID not found: 123"):
prompt_builder_from_ui_name("id::123", task)

prompt = Prompt(
name="test_prompt_name",
prompt="test_prompt",
chain_of_thought_instructions="coti",
parent=task,
)
prompt.save_to_file()
pb = prompt_builder_from_ui_name("id::" + prompt.id, task)
assert isinstance(pb, SavedPromptBuilder)
assert pb.prompt_id() == prompt.id
assert pb.build_prompt() == "test_prompt"
assert pb.chain_of_thought_prompt() == "coti"


def test_example_count():
assert FewShotPromptBuilder.example_count() == 4
Expand Down
3 changes: 2 additions & 1 deletion libs/core/kiln_ai/adapters/test_saving_adapter_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def adapter_info(self) -> AdapterInfo:
model_name="mock_model",
model_provider="mock_provider",
prompt_builder_name="mock_prompt_builder",
prompt_id="mock_prompt_id",
)


Expand Down Expand Up @@ -91,7 +92,7 @@ def test_save_run_isolation(test_task):
reloaded_output.source.properties["prompt_builder_name"]
== "mock_prompt_builder"
)

assert reloaded_output.source.properties["prompt_id"] == "mock_prompt_id"
# Run again, with same input and different output. Should create a new TaskRun.
different_run_output = RunOutput(
output="Different output", intermediate_outputs=None
Expand Down
1 change: 0 additions & 1 deletion libs/server/kiln_server/test_run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from kiln_server.custom_errors import connect_custom_errors
from kiln_server.run_api import (
RunSummary,
RunTaskRequest,
connect_run_api,
deep_update,
run_from_id,
Expand Down

0 comments on commit 90ca92b

Please sign in to comment.