Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow controls: Loop #1726

Open
ivicac opened this issue Nov 12, 2024 · 0 comments
Open

Flow controls: Loop #1726

ivicac opened this issue Nov 12, 2024 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@ivicac
Copy link
Contributor

ivicac commented Nov 12, 2024

Wireframe: https://balsamiq.cloud/spslzug/ph7qmda/rDCD5

Image

Sample workflow:

{
    "label": "Find new free appointments v2",
    "description": "",
    "inputs": [],
    "triggers": [
        {
            "label": "Gmail",
            "name": "trigger_1",
            "type": "googleMail/v1/newEmail"
        }
    ],
    "tasks": [
        {
            "label": "Google Mail",
            "name": "googleMail_1",
            "parameters": {
                "format": "simple",
                "id": "${trigger_1.id}"
            },
            "type": "googleMail/v1/getMail",
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {}
                }
            }
        },
        {
            "label": "OpenAI",
            "name": "openai_1",
            "parameters": {
                "responseFormat": 1,
                "n": 1,
                "temperature": 1,
                "topP": 1,
                "frequencyPenalty": 0,
                "presencePenalty": 0,
                "model": "gpt-4",
                "messages": [
                    {
                        "content": "${googleMail_1.bodyPlain} Can you conclude from this message if someone is requesting an appointment? Who wants to schedule the appointment? On which day? At what time does the patient want to make the appointment?",
                        "role": "user"
                    },
                    {
                        "role": "system",
                        "content": "{\"patientName\" : \"name of the patient\",\n\"patientMail\" : \"email of the patient\",\n\"typeOfDoctor\" : \"type of the doctor patient wants to see\",\"appointementDate\" : \"day when patient wants to make appointment\",\"dateTimePeriod\" : {\"startDateTime\": \"start date time when patient wants to make appointment in \"yyyy-MM-ddThh:mm\" format\"\",\"endDateTime\" : \"end date time when patient wants to make appointment in \"yyyy-MM-ddThh:mm\" format\"}}"
                    }
                ]
            },
            "type": "openai/v1/ask",
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {}
                }
            }
        },
        {
            "label": "Google Calendar",
            "name": "googleCalendar_1",
            "type": "googleCalendar/v1/getFreeTimeSlots",
            "parameters": {
                "maxResults": 250,
                "calendarId": "",
                "dateRange": {
                    "from": "${openai_1.dateTimePeriod.startDateTime}",
                    "to": "${openai_1.dateTimePeriod.endDateTime}"
                }
            },
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {}
                }
            }
        },
        {
            "type": "loop/v1",
            "name": "loop_1",
            "parameters": {
                "items": "${googleCalendar_1}",
                "iteratee": [
                    {
                        "label": "Date Helper",
                        "name": "dateHelper_1",
                        "parameters": {
                            "unit": "minute",
                            "startDate": "${loop_1.item.startTime}",
                            "endDate": "${loop_1.item.endTime}"
                        },
                        "type": "dateHelper/v1/dateDifference",
                        "metadata": {
                            "ui": {
                                "dynamicPropertyTypes": {}
                            }
                        }
                    },
                    {
                        "label": "If a time slot is longer than 45 minutes",
                        "name": "condition_1",
                        "type": "condition/v1",
                        "parameters": {
                            "rawExpression": true,
                            "expression": "${dateHelper_1} >= 45",
                            "caseTrue": [
                                {
                                    "label": "Data Storage",
                                    "name": "dataStorage_1",
                                    "parameters": {
                                        "scope": "CURRENT_EXECUTION",
                                        "key": "validTimeSlots",
                                        "type": 8,
                                        "value": "${loop_1.item}"
                                    },
                                    "type": "dataStorage/v1/appendValueToList",
                                    "metadata": {
                                        "ui": {
                                            "dynamicPropertyTypes": {}
                                        }
                                    }
                                }
                            ],
                            "caseFalse": [
                                {
                                    "label": "Log Warning",
                                    "name": "logEntryWarn1",
                                    "parameters": {
                                        "text": " ${loop_1.item} is NOT valid"
                                    },
                                    "type": "logger/v1/warn"
                                }
                            ]
                        }
                    }
                ]
            }
        },
        {
            "label": "Data Storage",
            "name": "dataStorage_2",
            "type": "dataStorage/v1/getValue",
            "parameters": {
                "key": "validTimeSlots",
                "scope": "CURRENT_EXECUTION",
                "type": 8,
                "defaultValue": {
                    "startTime": "2024-09-15T08:29",
                    "endTime": "2024-09-16T08:29"
                }
            },
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {
                        "defaultValue.startTime": "DATE_TIME",
                        "defaultValue.endTime": "DATE_TIME"
                    }
                }
            }
        },
        {
            "label": "OpenAI",
            "name": "openai_2",
            "parameters": {
                "responseFormat": 0,
                "n": 1,
                "temperature": 1,
                "topP": 1,
                "frequencyPenalty": 0,
                "presencePenalty": 0,
                "model": "gpt-4",
                "messages": [
                    {
                        "content": "${dataStorage_2} Can you look at the start and end times of all these free time slots? Can you suggest a list of appointments in this free time? Each appointment lasts 45 minutes and can start at every quarter of an hour at 00, 15, 30, and 45. Appointments cannot overlap. Pay attention to the fact that appointments can start and end only in my free time.Provide response like list in this format \"1. date of appointment start time - end time in this format September 5, 2024: 7:00 Am - 7:45 am\" and so on. Do not include any additional explanation.",
                        "role": "user"
                    }
                ]
            },
            "type": "openai/v1/ask",
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {}
                }
            }
        },
        {
            "label": "Google Mail",
            "name": "googleMail_2",
            "type": "googleMail/v1/replyToEmail",
            "parameters": {
                "body": "Here are all the available appointments: ${openai_2} Would you like to schedule any of these appointments?",
                "id": "${googleMail_1.id}",
                "bcc": "${googleMail_1.bcc}",
                "cc": "${googleMail_1.cc}",
                "to": [
                    "${googleMail_1.from}"
                ]
            },
            "metadata": {
                "ui": {
                    "dynamicPropertyTypes": {
                        "to[0]": "STRING"
                    }
                }
            }
        }
    ]
}
@ivicac ivicac added bug Something isn't working enhancement New feature or request labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: V 0.1
Development

No branches or pull requests

2 participants