API Function Call Dynamic Condition

I’m working on openai function call, i am trying to ask chatgpt to update my table fields based on my prompt in one function.

Prompt Example:

  1. Please update all the pending tasks to completed.
  2. Please update Make payment to company task to make payment to openai.
  3. Please move the due date of all pending tasks to next week.

The prompts above show parameter which are status, name, and due date in different prompts, is there anyway i can update my task with these prompts in one function?

Try this function and just modify to your liking

{
    "name": "manage_tasks",
    "description": "Task management function that allows for various operations on tasks",
    "parameters": {
        "type": "object",
        "properties": {
            "action": {
                "type": "string",
                "description": "The action to be performed, such as 'update_status', 'update_task', or 'move_due_date'",
                "enum": [
                    "update_status",
                    "update_task",
                    "move_due_date"
                ]
            },
            "task_name": {
                "type": "string",
                "description": "Name of the task to be updated"
            },
            "new_task_name": {
                "type": "string",
                "description": "New name of the task to be updated"
            },
            "status": {
                "type": "string",
                "description": "New status for all tasks or status of tasks for which due date needs to be moved"
            },
            "new_due_date": {
                "type": "string",
                "description": "New due date for the tasks"
            }
        },
        "required": ["action"]
    }
}

Sample output

  1. Please update all the pending tasks to completed.
{
  role: 'assistant',
  content: null,
  function_call: {
    name: 'manage_tasks',
    arguments: '{\n  "action": "update_status",\n  "status": "completed"\n}'
  }
}
  1. Please update Make payment to company task to make payment to openai.
{
  role: 'assistant',
  content: null,
  function_call: {
    name: 'manage_tasks',
    arguments: '{\n' +
      '  "action": "update_task",\n' +
      '  "task_name": "Make payment to company",\n' +
      '  "new_task_name": "Make payment to OpenAI"\n' +
      '}'
  }
}
  1. Please move the due date of all pending tasks to next week.
{
  role: 'assistant',
  content: null,
  function_call: {
    name: 'manage_tasks',
    arguments: '{\n' +
      '  "action": "move_due_date",\n' +
      '  "status": "pending",\n' +
      '  "new_due_date": "next week"\n' +
      '}'
  }
}
1 Like

hey @supershaneski thanks for the reply!

I do it with 4 dynamic properties so chatgpt will classify them from my prompt

{
        "name": "update_task",
        "description": "Update the fields of single or multiple task in to-do list based on the condition given. Which field to be updated and the field value will be given.",
        "parameters": {
            "type": 'object', 
            "properties": {
                "tasks": {
                    "type": 'array', 
                    "items": {
                        "type": "object",
                        "properties": {
                            "prompt_condition_field" :{
                                "type": "string",
                                "description": "The field of task needed to be filtered"
                            },
                            "prompt_condition_value" :{
                                "type": "string",
                                "description": "The value of the field of task needed to be filtered"
                            },
                            "update_field" :{
                                "type": "string",
                                "description": "The field of task needed to be updated"
                            },
                            "update_value" :{
                                "type": "string",
                                "description": "The value of task needed to be updated"
                            },
                        },
                    }
                }
            },  
            "required": ['tasks']
        }
    },
1 Like