Create Custom Jobs
Create custom jobs and run them on your messages with phospho
phospho comes with several built-in jobs that you can use to process your messages: zero-shot evaluation, classification based evaluation, event detection…
But you can also create your own jobs and run them on your messages. This is what we call a custom job.
Creating a custom job function
To create a custom job function, you need to create a function that:
- takes a
lab.Message
as input - can take additional parameters if needed (they will be passed as
JobConfig
) - returns a
lab.JobResult
. Thelab.JobResult
should contain the result of the job function and the type of the result.
For instance, to define a simple job that checks if a message contains a forbidden word, you can create a Job function like this:
Running a custom job
Once you have defined your custom job function, you can create a Job in your workload that will run this job function on your messages.
You need to pass the function in the job_function
of the lab.Job
object.
In our example:
This workload can then be run on your messages using the async_run
method.
Was this page helpful?