Last active
December 10, 2024 16:58
-
-
Save scosman/2fff1a10e8a88e151cb072bd80e7cbae to your computer and use it in GitHub Desktop.
Kiln Data Load Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install kiln-ai | |
import kiln_ai | |
import kiln_ai.datamodel | |
# Created a project and task via the UI and put its path here | |
task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln" | |
task = kiln_ai.datamodel.Task.load_from_file(task_path) | |
# Add data to the task - loop over you dataset and run this for each item | |
item = kiln_ai.datamodel.TaskRun( | |
parent=task, | |
input='{"topic": "AI"}', | |
input_source=kiln_ai.datamodel.DataSource( | |
type=kiln_ai.datamodel.DataSourceType.human, | |
properties={"created_by": "John Doe"}, | |
), | |
output=kiln_ai.datamodel.TaskOutput( | |
output='{"setup": "What is AI?", "punchline": "content_here"}', | |
source=kiln_ai.datamodel.DataSource( | |
type=kiln_ai.datamodel.DataSourceType.human, | |
properties={"created_by": "John Doe"}, | |
), | |
), | |
) | |
item.save_to_file() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment