diff --git a/checks.sh b/checks.sh index 39fb26e7..36124e25 100755 --- a/checks.sh +++ b/checks.sh @@ -15,8 +15,8 @@ headerEnd=" ===\033[0m\n" echo "${headerStart}Checking Python: Ruff, format, check${headerEnd}" # I is import sorting -ruff check --select I -ruff format --check +uvx ruff check --select I +uvx ruff format --check . echo "${headerStart}Checking for Misspellings${headerEnd}" find . -type f | grep -v "/node_modules/" | grep -v "/\." | grep -v "/dist/" | grep -v "/desktop/build/" | xargs misspell -error diff --git a/libs/core/kiln_ai/adapters/prompt_builders.py b/libs/core/kiln_ai/adapters/prompt_builders.py index e595bd71..04d5af0c 100644 --- a/libs/core/kiln_ai/adapters/prompt_builders.py +++ b/libs/core/kiln_ai/adapters/prompt_builders.py @@ -103,7 +103,7 @@ def build_prompt(self) -> str: ) # iterate requirements, formatting them in numbereed list like 1) task.instruction\n2)... for i, requirement in enumerate(self.task.requirements): - base_prompt += f"{i+1}) {requirement.instruction}\n" + base_prompt += f"{i + 1}) {requirement.instruction}\n" return base_prompt @@ -126,12 +126,12 @@ def build_prompt(self) -> str: Returns: str: The constructed prompt string with examples. """ - base_prompt = f"# Instruction\n\n{ self.task.instruction }\n\n" + base_prompt = f"# Instruction\n\n{self.task.instruction}\n\n" if len(self.task.requirements) > 0: base_prompt += "# Requirements\n\nYour response should respect the following requirements:\n" for i, requirement in enumerate(self.task.requirements): - base_prompt += f"{i+1}) {requirement.instruction}\n" + base_prompt += f"{i + 1}) {requirement.instruction}\n" base_prompt += "\n" valid_examples = self.collect_examples() @@ -148,7 +148,7 @@ def build_prompt(self) -> str: def prompt_section_for_example(self, index: int, example: TaskRun) -> str: # Prefer repaired output if it exists, otherwise use the regular output output = example.repaired_output or example.output - return f"## Example {index+1}\n\nInput: {example.input}\nOutput: {output.output}\n\n" + return f"## Example {index + 1}\n\nInput: {example.input}\nOutput: {output.output}\n\n" def collect_examples(self) -> list[TaskRun]: valid_examples: list[TaskRun] = [] @@ -206,7 +206,7 @@ def prompt_section_for_example(self, index: int, example: TaskRun) -> str: ): return super().prompt_section_for_example(index, example) - prompt_section = f"## Example {index+1}\n\nInput: {example.input}\n\n" + prompt_section = f"## Example {index + 1}\n\nInput: {example.input}\n\n" prompt_section += ( f"Initial Output Which Was Insufficient: {example.output.output}\n\n" ) diff --git a/libs/core/kiln_ai/adapters/test_prompt_builders.py b/libs/core/kiln_ai/adapters/test_prompt_builders.py index f6d55736..f60c6993 100644 --- a/libs/core/kiln_ai/adapters/test_prompt_builders.py +++ b/libs/core/kiln_ai/adapters/test_prompt_builders.py @@ -241,14 +241,14 @@ def test_few_shot_prompt_builder(tmp_path): # Create 6 examples (2 repaired, 4 high-quality) for i in range(6): run = TaskRun( - input=f'{{"subject": "Subject {i+1}"}}', + input=f'{{"subject": "Subject {i + 1}"}}', input_source=DataSource( type=DataSourceType.human, properties={"created_by": "john_doe"}, ), parent=task, output=TaskOutput( - output=f'{{"joke": "Joke Initial Output {i+1}"}}', + output=f'{{"joke": "Joke Initial Output {i + 1}"}}', source=DataSource( type=DataSourceType.human, properties={"created_by": "john_doe"}, @@ -262,7 +262,7 @@ def test_few_shot_prompt_builder(tmp_path): update={ "repair_instructions": "Fix the joke", "repaired_output": TaskOutput( - output=f'{{"joke": "Repaired Joke {i+1}"}}', + output=f'{{"joke": "Repaired Joke {i + 1}"}}', source=DataSource( type=DataSourceType.human, properties={"created_by": "jane_doe"}, @@ -335,6 +335,9 @@ def test_prompt_builder_from_ui_name(task_with_examples): with pytest.raises(ValueError, match="Unknown prompt builder: invalid_name"): prompt_builder_from_ui_name("invalid_name", task) + with pytest.raises(ValueError, match="Prompt ID not found: 123"): + prompt_builder_from_ui_name("id::123", task) + def test_example_count(): assert FewShotPromptBuilder.example_count() == 4 diff --git a/libs/server/kiln_server/test_run_api.py b/libs/server/kiln_server/test_run_api.py index 9df600e2..ace8e13e 100644 --- a/libs/server/kiln_server/test_run_api.py +++ b/libs/server/kiln_server/test_run_api.py @@ -463,12 +463,12 @@ async def test_update_run(client, tmp_path): json=case["updates"], ) - assert ( - response.status_code == case["expected_status"] - ), f"Failed on case: {case['name']}" - assert ( - response.json()["message"] == case["expected_detail"] - ), f"Failed on case: {case['name']}" + assert response.status_code == case["expected_status"], ( + f"Failed on case: {case['name']}" + ) + assert response.json()["message"] == case["expected_detail"], ( + f"Failed on case: {case['name']}" + ) @pytest.fixture