Skip to main content
1

Create a new task

Type workflowai task new into the terminal and press enter
2

Enter a description for your task

Enter a description of the task that defines the inputs and outputs for the task.In this context, the input is the information and data you will give you the AI, and the output is what the AI will give back to you.
To make sure that the input and output is defined correctly, note the following in your description:
  • What would you give to the task as input?
  • What do you expect as output?
  • Are there any edge cases or constraints to be mindful of?
Given a city, output the country that city exists within
For more example tasks check out our task of the week blog posts
3

Review the generated task

  1. WorkflowAI will generate a class for both the input and output (as well as a class for the task description).
from pydantic import Field                                                                                
from core.domain import AbstractTaskIO, Task                                                              
                                                                                              
"""This code was originally generated by Workflow AI based on the following task description:             
'Given a city output the country that city exists within'"""                                              

class CityToCountryTaskInput(AbstractTaskIO):
city: str = Field(
description='The name of the city for which the country is to be determined',
examples=['Paris', 'Tokyo', 'New York'],
)

class CityToCountryTaskOutput(AbstractTaskIO):
country: str = Field(
description='The country in which the specified city is located',
examples=['France', 'Japan', 'United States'],
) 

                                                                                                                           
class CityToCountryTask(Task[CityToCountryTaskInput, CityToCountryTaskOutput]):                                                   
input_class: type[CityToCountryTaskInput] = CityToCountryTaskInput                                                            
output_class: type[CityToCountryTaskOutput] = CityToCountryTaskOutput                                                         
instructions: str = """To complete the task, you need to determine the country in which a specified city is located. You will 
receive an input JSON object containing a single field named 'city', which is a string representing the name of the city. Your    
output should be a JSON object with a single field named 'country', which is a string representing the name of the country where  
the city exists. For example, if the input is {"city": "Paris"}, the output should be {"country": "France"}. Ensure that the      
output strictly adheres to the provided output JSON schema."""                                                                    
                                                                                                                      
  1. Review, the input and output for the task:
    • If you are happy with the generated task, enter Y to save
    • If not, enter n and start at step 1
Note: itโ€™s more important to make sure the input and output are correct at this stage. The task description is less important for now.
4

(Optional) Refine your task description

Here are some steps to refine your description to get better results
  1. a
  2. b
  3. c
  4. d
  5. e