Skip to main content

NL2Flow: A PDDL interface to flow construction

Project description

NL2Flow: A PDDL Interface to Flow Construction

IBM image image AI

This package allows developers to easily integrate automated planning applications into their systems. Migrating research efforts to product creates knowledge gaps and blindspots, along with requirements for long-term support which often cannot be followed through. Particularly, the adoption of automated planners into products requires developers to get familiar with declarative modeling and understand the requirements of the PDDL syntax. This package mitigates this need by creating an abstraction around the underlying formal representation so that anyone can use automated planners to create workflows through a Python API, with their desired specifications.

🤓 Read more about our work on natural language to workflow construction here.

Getting Started

Clone the repository

user:~$ git clone git@github.com:IBM/nl2flow.git
user:~$ cd nl2flow

Change to a virtual environment

We also strongly recommend using a virtual environment, such as anaconda, for development.

user:~$ conda create --name nl2flow
user:~$ conda activate nl2flow

Install Dependencies

(nl2flow) user:~$ pip install -e .

If you want to contribute code, check here

Example of an NL2Flow Domain

An NL2Flow domain is a mixture of service compostiion and goal-oriented conversation. A typical plan includes elements of API calls, systems calls, and interactions with the user, in pursuit of a higher level goal. The following is an example of a plan helping an user with a trip approval process involving flight and hotel bookings, taxi services to and from airports and location of the event, and subprocesses involving conference registration, visa approval, etc. handed off to the corresponding agents. Notice the information gathering actions, either directly from the user or from other services, performed by the system to facilitate the above requirements of the goal.

[0] ask(conference name)
[1] ask(w3)
[2] list of papers = Author Workbench(w3, conference name)
[3] ask(username)
[4] invoice = Registration Bot(conference name, list of papers, username)
[5] map(invoice, conference registration)
[6] name, address, Employee ID, Passport = W3 Agent(w3)
[7] name, address, Employer Letter = Workday(Employee ID)
[8] visa = Visa Application(Passport, address, Employer Letter)
[9] ask(start date)
[10] ask(end date)
[11] map(home, address)
[12] map(BOS, destination)
[13] booking = Taxi(date, address, destination)
[14] map(LAX, address)
[15] map(JW Marriott Los Angeles LA 900 W Olympic Blvd, destination)
[16] booking = Taxi(date, address, destination)
[17] map(end date, date)
[18] map(JW Marriott Los Angeles LA 900 W Olympic Blvd, address)
[19] map(LAX, destination)
[20] booking = Taxi(date, address, destination)
[21] map(BOS, address)
[22] map(destination, home)
[23] booking = Taxi(date, address, destination)
[24] assert eval(is a business trip)
[25] flight_ticket, hotel_booking = Concur(start date, end date, home, destination)
[26] map(flight_ticket, ticket to conference)
[27] assert $hotel_booking.price + $flight_ticket.price < 1500
[28] approval = Trip Approval(ticket to conference, conference registration)

Usage

Get started with constructing a simple flow where you have two operators, one target operator and another one which provides required items for the target operator.

from nl2flow.compile.flow import Flow
from nl2flow.compile.operators import ClassicalOperator as Operator
from nl2flow.compile.schemas import SignatureItem, GoalItem, GoalItems

new_flow = Flow("Basic Test")

find_errors_api = Operator("Find Errors")
find_errors_api.add_input(SignatureItem(parameters=["database link"]))
find_errors_api.add_output(SignatureItem(parameters=["list of errors"]))

fix_errors_api = Operator("Fix Errors")
fix_errors_api.add_input(SignatureItem(parameters=["list of errors"]))

new_flow.add([find_errors_api, fix_errors_api])

goal = GoalItems(goals=GoalItem(goal_name="Fix Errors"))
new_flow.add(goal)

pddl, _ = new_flow.compile_to_pddl() # if you want the PDDL only
parsed_plans = new_flow.plan_it(planner) # if you want the plans

print(planner.pretty_print(parsed_plans))
---- Plan #0 ----
Cost: 501.0, Length: 2.0

Step 0: ask, Inputs: list of errors (generic), Outputs: None
Step 1: Fix Errors, Inputs: list of errors (generic), Outputs: None


---- Plan #1 ----
Cost: 502.0, Length: 3.0

Step 0: ask, Inputs: database link (generic), Outputs: None
Step 1: Find Errors, Inputs: database link (generic), Outputs: list of errors (generic)
Step 2: Fix Errors, Inputs: list of errors (generic), Outputs: None

Citation

If you end up using this code, you can cite us using the following BibTex entry. Our general focus on natural language processing pipelines for workflow construction applications is documented in that paper.

@inproceedings{chakraborti2022natural,
  title={From Natural Language to Workflows: Towards Emergent Intelligence in Robotic Process Automation},
  author={Tathagata Chakraborti and Yara Rizk and Vatche Isahagian and Burak Aksar and Francesco Fuggitti},
  booktitle={BPM RPA Forum},
  year={2022},
}

Acknowledgements

This package depends heavily on Tarski, our favorite PDDL parser. Give them lots of :heart: :heart:.

github docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nl2flow-0.0.18.dev0.tar.gz (119.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nl2flow-0.0.18.dev0-py3-none-any.whl (99.5 kB view details)

Uploaded Python 3

File details

Details for the file nl2flow-0.0.18.dev0.tar.gz.

File metadata

  • Download URL: nl2flow-0.0.18.dev0.tar.gz
  • Upload date:
  • Size: 119.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for nl2flow-0.0.18.dev0.tar.gz
Algorithm Hash digest
SHA256 5679c811f233f91b2bdfd336ad52bffee5c4200d04669f4a98437240cd016ecb
MD5 abd74d41f4aa560ca50e0c0fbff4697c
BLAKE2b-256 3eafa94f8dbf74098879455677a78e79f8880f6ab0c1bb0b74bca8a61dfe5e9f

See more details on using hashes here.

File details

Details for the file nl2flow-0.0.18.dev0-py3-none-any.whl.

File metadata

  • Download URL: nl2flow-0.0.18.dev0-py3-none-any.whl
  • Upload date:
  • Size: 99.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for nl2flow-0.0.18.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae0758939e2f70ed5f6a40bfdf995421334a04a603cb87b310bc0f4d6bd1c5b
MD5 abaac68b9628f3c9d3a7a21b0c1c3f2d
BLAKE2b-256 b611994dcdfcba679a7874829a39ae5badbec404291e9bf9eca23498e01c9cba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page