Skip to content

Commit 2fc907e

Browse files
authored
Merge pull request #448 from Kiln-AI/leonard/lib-docs
docs: update lib docs
2 parents c8ab341 + cbaf918 commit 2fc907e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

libs/core/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The library has a [comprehensive set of docs](https://kiln-ai.github.io/Kiln/kil
4141
- [Using your Kiln Dataset in a Notebook or Project](#using-your-kiln-dataset-in-a-notebook-or-project)
4242
- [Using Kiln Dataset in Pandas](#using-kiln-dataset-in-pandas)
4343
- [Building and Running a Kiln Task from Code](#building-and-running-a-kiln-task-from-code)
44+
- [Tagging Task Runs Programmatically](#tagging-task-runs-programmatically)
4445
- [Adding Custom Model or AI Provider from Code](#adding-custom-model-or-ai-provider-from-code)
4546
- [Full API Reference](#full-api-reference)
4647

@@ -153,7 +154,10 @@ item = kiln_ai.datamodel.TaskRun(
153154
type=kiln_ai.datamodel.DataSourceType.human,
154155
properties={"created_by": "Jane Doe"},
155156
),
156-
rating=kiln_ai.datamodel.TaskOutputRating(score=5,type="five_star"),
157+
rating=kiln_ai.datamodel.TaskOutputRating(
158+
value=5,
159+
type=kiln_ai.datamodel.datamodel_enums.five_star,
160+
),
157161
),
158162
)
159163
item.save_to_file()
@@ -244,6 +248,25 @@ for run in task.runs():
244248

245249
```
246250

251+
## Tagging Task Runs Programmatically
252+
253+
You can also tag your Kiln Task runs programmatically:
254+
255+
```py
256+
# Load your Kiln Task from disk
257+
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
258+
task = kiln_ai.datamodel.Task.load_from_file(task_path)
259+
260+
for run in task.runs():
261+
# Parse the task output from JSON
262+
output = json.loads(run.output.output)
263+
264+
# Add a tag if the punchline is unusually short
265+
if len(output["punchline"]) < 100:
266+
run.tags.append("very_short")
267+
run.save_to_file() # Persist the updated tags
268+
```
269+
247270
### Adding Custom Model or AI Provider from Code
248271

249272
You can add additional AI models and providers to Kiln.

0 commit comments

Comments
 (0)