Skip to content

Commit f121ce4

Browse files
committed
Formatting fix.
Also update checks.sh to use the same command as CI, locking the ruff version
1 parent 6e7384e commit f121ce4

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

checks.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ headerEnd=" ===\033[0m\n"
1515

1616
echo "${headerStart}Checking Python: Ruff, format, check${headerEnd}"
1717
# I is import sorting
18-
ruff check --select I
19-
ruff format --check
18+
uvx ruff check --select I
19+
uvx ruff format --check .
2020

2121
echo "${headerStart}Checking for Misspellings${headerEnd}"
2222
find . -type f | grep -v "/node_modules/" | grep -v "/\." | grep -v "/dist/" | grep -v "/desktop/build/" | xargs misspell -error

libs/core/kiln_ai/adapters/prompt_builders.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def build_prompt(self) -> str:
103103
)
104104
# iterate requirements, formatting them in numbereed list like 1) task.instruction\n2)...
105105
for i, requirement in enumerate(self.task.requirements):
106-
base_prompt += f"{i+1}) {requirement.instruction}\n"
106+
base_prompt += f"{i + 1}) {requirement.instruction}\n"
107107

108108
return base_prompt
109109

@@ -126,12 +126,12 @@ def build_prompt(self) -> str:
126126
Returns:
127127
str: The constructed prompt string with examples.
128128
"""
129-
base_prompt = f"# Instruction\n\n{ self.task.instruction }\n\n"
129+
base_prompt = f"# Instruction\n\n{self.task.instruction}\n\n"
130130

131131
if len(self.task.requirements) > 0:
132132
base_prompt += "# Requirements\n\nYour response should respect the following requirements:\n"
133133
for i, requirement in enumerate(self.task.requirements):
134-
base_prompt += f"{i+1}) {requirement.instruction}\n"
134+
base_prompt += f"{i + 1}) {requirement.instruction}\n"
135135
base_prompt += "\n"
136136

137137
valid_examples = self.collect_examples()
@@ -148,7 +148,7 @@ def build_prompt(self) -> str:
148148
def prompt_section_for_example(self, index: int, example: TaskRun) -> str:
149149
# Prefer repaired output if it exists, otherwise use the regular output
150150
output = example.repaired_output or example.output
151-
return f"## Example {index+1}\n\nInput: {example.input}\nOutput: {output.output}\n\n"
151+
return f"## Example {index + 1}\n\nInput: {example.input}\nOutput: {output.output}\n\n"
152152

153153
def collect_examples(self) -> list[TaskRun]:
154154
valid_examples: list[TaskRun] = []
@@ -206,7 +206,7 @@ def prompt_section_for_example(self, index: int, example: TaskRun) -> str:
206206
):
207207
return super().prompt_section_for_example(index, example)
208208

209-
prompt_section = f"## Example {index+1}\n\nInput: {example.input}\n\n"
209+
prompt_section = f"## Example {index + 1}\n\nInput: {example.input}\n\n"
210210
prompt_section += (
211211
f"Initial Output Which Was Insufficient: {example.output.output}\n\n"
212212
)

libs/core/kiln_ai/adapters/test_prompt_builders.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ def test_few_shot_prompt_builder(tmp_path):
241241
# Create 6 examples (2 repaired, 4 high-quality)
242242
for i in range(6):
243243
run = TaskRun(
244-
input=f'{{"subject": "Subject {i+1}"}}',
244+
input=f'{{"subject": "Subject {i + 1}"}}',
245245
input_source=DataSource(
246246
type=DataSourceType.human,
247247
properties={"created_by": "john_doe"},
248248
),
249249
parent=task,
250250
output=TaskOutput(
251-
output=f'{{"joke": "Joke Initial Output {i+1}"}}',
251+
output=f'{{"joke": "Joke Initial Output {i + 1}"}}',
252252
source=DataSource(
253253
type=DataSourceType.human,
254254
properties={"created_by": "john_doe"},
@@ -262,7 +262,7 @@ def test_few_shot_prompt_builder(tmp_path):
262262
update={
263263
"repair_instructions": "Fix the joke",
264264
"repaired_output": TaskOutput(
265-
output=f'{{"joke": "Repaired Joke {i+1}"}}',
265+
output=f'{{"joke": "Repaired Joke {i + 1}"}}',
266266
source=DataSource(
267267
type=DataSourceType.human,
268268
properties={"created_by": "jane_doe"},
@@ -335,6 +335,9 @@ def test_prompt_builder_from_ui_name(task_with_examples):
335335
with pytest.raises(ValueError, match="Unknown prompt builder: invalid_name"):
336336
prompt_builder_from_ui_name("invalid_name", task)
337337

338+
with pytest.raises(ValueError, match="Prompt ID not found: 123"):
339+
prompt_builder_from_ui_name("id::123", task)
340+
338341

339342
def test_example_count():
340343
assert FewShotPromptBuilder.example_count() == 4

libs/server/kiln_server/test_run_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,12 @@ async def test_update_run(client, tmp_path):
463463
json=case["updates"],
464464
)
465465

466-
assert (
467-
response.status_code == case["expected_status"]
468-
), f"Failed on case: {case['name']}"
469-
assert (
470-
response.json()["message"] == case["expected_detail"]
471-
), f"Failed on case: {case['name']}"
466+
assert response.status_code == case["expected_status"], (
467+
f"Failed on case: {case['name']}"
468+
)
469+
assert response.json()["message"] == case["expected_detail"], (
470+
f"Failed on case: {case['name']}"
471+
)
472472

473473

474474
@pytest.fixture

0 commit comments

Comments
 (0)