NL2Flow: A PDDL interface to flow construction
Project description
NL2Flow: A PDDL Interface to Flow Construction
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:.
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
Built Distribution
File details
Details for the file nl2flow-0.0.6.tar.gz
.
File metadata
- Download URL: nl2flow-0.0.6.tar.gz
- Upload date:
- Size: 73.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c74782ed868bdae16c99d6c9ce1c85ee3643df3affc87dbc50d356f453a74155 |
|
MD5 | f1891c3461759bfa4671986041312a28 |
|
BLAKE2b-256 | d18d6df43091a792939054bee9030c96cbec1988b509a61ada3929e6567004b2 |
File details
Details for the file nl2flow-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: nl2flow-0.0.6-py3-none-any.whl
- Upload date:
- Size: 95.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dfd45f8887cadd61ecf95e7d942fbbbf19e1c6715e2a392133797773a9a3b25 |
|
MD5 | b6fcb13ec1a67fc6cc7e9b9a3521a389 |
|
BLAKE2b-256 | 2d21e1ea71e39974876cd643e28443b2d12271109be77636c3b31da92373d833 |