@@ -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)
159163item.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
249272You can add additional AI models and providers to Kiln.
0 commit comments