diff --git a/examples/llm/PET/doc-1.1 b/examples/llm/PET/doc-1.1 new file mode 100644 index 000000000..ca1e6f794 --- /dev/null +++ b/examples/llm/PET/doc-1.1 @@ -0,0 +1,23 @@ +A small company manufactures customized bicycles. + +Whenever the sales department receives an order , a new process instance is created. + +A member of the sales department can then reject or accept the order for a customized bike. + +In the former case , the process instance is finished. + +In the latter case , the storehouse and the engineering department are informed. + +The storehouse immediately processes the part list of the order and checks the required quantity of each part. + +If the part is available in-house , it is reserved. + +If it is not available , it is back-ordered. + +This procedure is repeated for each item on the part list. + +In the meantime , the engineering department prepares everything for the assembling of the ordered bicycle. + +If the storehouse has successfully reserved or back-ordered every item of the part list and the preparation activity has finished , the engineering department assembles the bicycle. + +Afterwards , the sales department ships the bicycle to the customer and finishes the process instance . \ No newline at end of file diff --git a/examples/llm/PET/doc-1.2 b/examples/llm/PET/doc-1.2 new file mode 100644 index 000000000..7d515d93b --- /dev/null +++ b/examples/llm/PET/doc-1.2 @@ -0,0 +1,11 @@ +A customer brings in a defective computer and the CRS checks the defect and hands out a repair cost calculation back. + +If the customer decides that the costs are acceptable , the process continues , otherwise she takes her computer home unrepaired. + +The ongoing repair consists of two activities , which are executed , in an arbitrary order. + +The first activity is to check and repair the hardware , whereas the second activity checks and configures the software. + +After each of these activities , the proper system functionality is tested. + +If an error is detected another arbitrary repair activity is executed , otherwise the repair is finished . \ No newline at end of file diff --git a/examples/llm/PET/doc-1.3 b/examples/llm/PET/doc-1.3 new file mode 100644 index 000000000..0b15218fe --- /dev/null +++ b/examples/llm/PET/doc-1.3 @@ -0,0 +1,25 @@ +The Evanstonian is an upscale independent hotel. + +When a guest calls room service at The Evanstonian , the room-service manager takes down the order. + +She then submits an order ticket to the kitchen to begin preparing the food. + +She also gives an order to the sommelier ( i.e. + +, the wine waiter ) to fetch wine from the cellar and to prepare any other alcoholic beverages. + +Eighty percent of room-service orders include wine or some other alcoholic beverage. + +Finally , she assigns the order to the waiter. + +While the kitchen and the sommelier are doing their tasks , the waiter readies a cart ( i.e. + +, puts a tablecloth on the cart and gathers silverware ). + +The waiter is also responsible for nonalcoholic drinks. + +Once the food , wine , and cart are ready , the waiter delivers it to the guest ’ s room. + +After returning to the room-service station , the waiter debits the guest ’ s account. + +The waiter may wait to do the billing if he has another order to prepare or deliver . \ No newline at end of file diff --git a/examples/llm/PET/doc-1.4 b/examples/llm/PET/doc-1.4 new file mode 100644 index 000000000..09f803c00 --- /dev/null +++ b/examples/llm/PET/doc-1.4 @@ -0,0 +1,21 @@ +Whenever a company makes the decision to go public , its first task is to select the underwriters. + +Underwriters act as financial midwives to a new issue. + +Usually they play a triple role : First they provide the company with procedural and financial advice , then they buy the issue , and finally they resell it to the public. + +Established underwriters are careful of their reputation and will not handle a new issue unless they believe the facts have been presented fairly. + +Thus , in addition to handling the sale of a company ’ s issue , the underwriters in effect give their seal of approval to it. + +They prepare a registration statement for the approval of the Securities and Exchange Commission ( SEC ). + +In addition to registering the issue with the SEC , they need to check that the issue complies with the so-called blue-sky laws of each state that regulate sales of securities within the state. + +While the registration statement is awaiting approval , underwriters begin to firm up the issue price. + +They arrange a road show to talk to potential investors. + +Immediately after they receive clearance from the SEC , underwriters fix the issue price. + +After that they enter into a firm commitment to buy the stock and then offer it to the public , when they haven ’ t still found any reason not to do it . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.1 b/examples/llm/PET/doc-10.1 new file mode 100644 index 000000000..d5a965a44 --- /dev/null +++ b/examples/llm/PET/doc-10.1 @@ -0,0 +1,5 @@ +The MPON sents the dismissal to the MPOO. + +The MPOO reviews the dismissal. + +The MPOO opposes the dismissal of MPON or the MPOO confirmes the dismissal of the MPON . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.10 b/examples/llm/PET/doc-10.10 new file mode 100644 index 000000000..5f10a5b76 --- /dev/null +++ b/examples/llm/PET/doc-10.10 @@ -0,0 +1,15 @@ +The fault detector reports a failure to the MPO or MPO has a suspicion of their own fault. + +The MPO shall examine the failure. + +The MPO rejects the failure of the fault detector or the MPO confirms the failure of the fault detector. + +If the MPO confirms the failure of the fault detector , he informes the GO and the MSP. + +The MPO fixes the fault at the measuring device. + +The MPO shares the results of the repairs carried out with the fault detector. + +The MPO will inform the GO about the resolution of the interference. + +The MPO will inform the MSP about the resolution of the interference . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.11 b/examples/llm/PET/doc-10.11 new file mode 100644 index 000000000..ba391be0c --- /dev/null +++ b/examples/llm/PET/doc-10.11 @@ -0,0 +1,13 @@ +The GO requests the measurements to the MSP. + +The MSP checks the received request. + +The MSP denies the request of the GO or the MSP performs the measurement. + +The MSP informs the GO about the failure of the reading or the MSP transmits the measured values to the GO. + +The GO processes the measured values. + +The GO sends the changed values to the MSP. + +The GO transmit the readings to the SP . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.12 b/examples/llm/PET/doc-10.12 new file mode 100644 index 000000000..0af557032 --- /dev/null +++ b/examples/llm/PET/doc-10.12 @@ -0,0 +1,7 @@ +The EC tells the INQ about the change of his master data. + +The INQ notifies the IP of the change. + +The IP checks whether the master data can be changed at the desired time. + +The IP confirmes the changes of the INQ or the IP rejectes the changes of the INQ . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.13 b/examples/llm/PET/doc-10.13 new file mode 100644 index 000000000..617b00141 --- /dev/null +++ b/examples/llm/PET/doc-10.13 @@ -0,0 +1,7 @@ +The INQ transmits the transaction data request to the IP. + +The IP checks the request of the INQ. + +The IP answers the question of the INQ depending on the outcome of the examination , i.e. + +Transmission of data or rejection . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.14 b/examples/llm/PET/doc-10.14 new file mode 100644 index 000000000..30f1c99b0 --- /dev/null +++ b/examples/llm/PET/doc-10.14 @@ -0,0 +1,9 @@ +If the MPOO sends the bill for the temporary continuation of the metering point operations to the GO , the GO examines the bill. + +If the MSPO sends the bill for the temporary continuation of the measurement to the GO , the GO examines the bill. + +If the MSPO sends the bill for additional readings to the GO , the GO examines the bill. + +If the MPOO sends the bill for the equipment acquisition to the MPON or the GO , the MPON or the GO examines the bill. + +The GO or the MPON confirms the invoice with payment advice to the MPOO or the MSPO , or the GO or the MPON rejects the invoice of the MPOO or the MSPO . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.2 b/examples/llm/PET/doc-10.2 new file mode 100644 index 000000000..ea4e5af80 --- /dev/null +++ b/examples/llm/PET/doc-10.2 @@ -0,0 +1,27 @@ +The MPON reports the meter operation to the GO. + +The GO examines the application of the MPON. + +The GO rejects the application of the MPON or the GO confirmes the application of the MPON. + +The GO informs the MPOO about the registration confirmation of the MPON. + +The GO informs the MSPO about the registration confirmation of the MPON. + +The MPON and the MPOO perform the equipment acquisition and / or equipment changes. + +The MPON informs the GO about the failure of the entire process or the MPON informs the GO about the successful completion of the entire process. + +The GO informs the MPON about the failure of the overall transaction by deadline if after a maximum time limit no message of the MPON is present at the GO. + +If the MPON informs the GO about the failure of the entire process , the GO confirms the failure of the assignment to the MPON. + +If the MPON informs the GO about the successful completion of the overall process , the GO assigns the MPON. + +The GO confirms the assignment to the MPON. + +The GO informs the MPOO about the failure of the assignment of the MPON or the GO informs the MPOO about the assignment of the MPON. + +The GO informs the MSPO about the failure of the assignment of the MPON or the GO informs the MSPO about the assignment of the MPON. + +The GO informs the SP about the assignment of the MPON . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.3 b/examples/llm/PET/doc-10.3 new file mode 100644 index 000000000..75f540d8b --- /dev/null +++ b/examples/llm/PET/doc-10.3 @@ -0,0 +1,21 @@ +The MPOO deregisters at the GO. + +The GO verifies the deregistration. + +The GO rejects the deregistration of the MPOO or the GO preliminarily confirms the deregistration of the MPOO. + +The GO prepares the readmission of the measuring point. + +Optionally , the GO may oblige the MPOO to continue the operations. + +If the GO binds the MPOO to continue the operation , the MPOO confirmes the continuation to the MPOO. + +The GO performs the equipment acquisition and / or equipment changes. + +The GO assigns the GO as MPO. + +The GO informs the MPOO about the end of the assignment of the MPOO and the beginning of the assignment of the GO. + +The GO informs the MSPO about the assignment of the GO. + +The GO informs the SP about the assignment of the GO . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.4 b/examples/llm/PET/doc-10.4 new file mode 100644 index 000000000..d20303d19 --- /dev/null +++ b/examples/llm/PET/doc-10.4 @@ -0,0 +1,17 @@ +The MPON notifies the MPOO about equipment change intentions. + +The MPOO announces self dismounting to the MPON or the MPOO shall notify the MPON about no self-dismounting of the MPOO. + +The MPON or the MPOO perform the final reading. + +The MPON or the MPOO dismount the old equipment. + +The MPON mounts the new device. + +The MPON reads the meter count from the installed meter. + +The MPON sents the values of the final reading to the GO. + +The MPON tells the GO about the device changes , the master data and the meter count at installation. + +The GO shall notify the MSP about the device changes , the master data , the meter count at dismounting , and the meter count at installation . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.5 b/examples/llm/PET/doc-10.5 new file mode 100644 index 000000000..2fe3c6a70 --- /dev/null +++ b/examples/llm/PET/doc-10.5 @@ -0,0 +1,7 @@ +The MPON requests a device takeover bid of the MPOO. + +The MPOO sends a tender for the equipment takeover to the MPON. + +The MPON places an order at the MPOO. + +The MPOO confirms the order of the MPON and sends the master data . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.6 b/examples/llm/PET/doc-10.6 new file mode 100644 index 000000000..adc435faf --- /dev/null +++ b/examples/llm/PET/doc-10.6 @@ -0,0 +1,5 @@ +The MSPN sents a dismissal to the MSPO. + +The MSPO reviews the dismissal. + +The MSPO rejects the dismissal of the MSPN or The MSPO confirms the dismissal of the MSPN . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.7 b/examples/llm/PET/doc-10.7 new file mode 100644 index 000000000..51891b673 --- /dev/null +++ b/examples/llm/PET/doc-10.7 @@ -0,0 +1,13 @@ +The MSPN registers the measurement at the GO. + +The GO examines the application of the MSPN. + +The GO rejects the application of the MSPN or the GO confirmes the application of the MSPN. + +The GO assigns the MSPN. + +The GO informs the MSPO about the assignment of MSPN. + +The GO informs the MPO about the assignment of the MSPN. + +The GO informs the SP about the assignment of MSPN . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.8 b/examples/llm/PET/doc-10.8 new file mode 100644 index 000000000..aaf276ac9 --- /dev/null +++ b/examples/llm/PET/doc-10.8 @@ -0,0 +1,13 @@ +The MSPO deregisters at the GO. + +The GO verifies the deregistration. + +The GO rejects the deregistration of the MSPO or the GO preliminarily confirms the deregistration of the MSPO. + +The GO assigns himself as MSP. + +The GO informs the MSPO about the end of the assignment and the beginning of the assignment of the GO. + +The GO informs the MPO about the assignment of the GO. + +The GO informs the SP about the assignment of the GO . \ No newline at end of file diff --git a/examples/llm/PET/doc-10.9 b/examples/llm/PET/doc-10.9 new file mode 100644 index 000000000..184d4b38c --- /dev/null +++ b/examples/llm/PET/doc-10.9 @@ -0,0 +1,9 @@ +The SP / PU / GO request changes to the MPO or the MPO himself causes a change. + +The MPO reviews the change request. + +The MPO rejects the change of the measuring point by the SP / PU / GO or the MPO confirmes the request of the SP / PU / GO. + +The MPO performs the measuring point change. + +The MPO reports the implementation to the SP / PU / GO or notifies the SP / PU / GO about the failure of the changes . \ No newline at end of file diff --git a/examples/llm/PET/doc-2.1 b/examples/llm/PET/doc-2.1 new file mode 100644 index 000000000..8d0a66a4c --- /dev/null +++ b/examples/llm/PET/doc-2.1 @@ -0,0 +1,79 @@ +At the beginning the customer perceives that her subscribed service has degraded. + +A list with all the problem parameters is then sent to the Customer Service department of TELECO. + +At the customer service an employee enters ( based on the received data ) a problem report into system T. + +. Then the problem report is compared to the customer SLA to identify what the extent and the details of the service degradation are. + +Based on this , the necessary counter measures are determined including their respective priorities. + +An electronic service then determines the significance of the customer based on information that has been collected during the history of the contractual relationship. + +In case the customer is premium , the process will link to an extra problem fix process ( this process will not be detailed here ). + +In case the customer is of certain significance which would affect the counter measures previously decided upon , the process goes back to re-prioritize these measures otherwise the process continues. + +Taking together the information ( i.e. + +contract commitment data + prioritized actions ) a detailed problem report is created. + +The detailed problem report is then sent to Service Management. + +Service Management deals on a first level with violations of quality in services that are provided to customers. + +After receiving the detailed problem report , Service management investigates whether the problem is analyzable at the level of their department or whether the problem may be located at Resource Provisioning. + +In case Service Management assesses the problem to be not analyzable by themselves , the detailed problem report is sent out to Resource Provisioning. + +If Service Management is sure they can analyze it , they perform the analysis and based on the outcome they create a trouble report that indicates the type of problem. + +After Resource Provisioning receives the detailed problem report , it is checked whether there are any possible problems. + +If no problems are detected , a notification about the normal service execution is created. + +If a problem is detected this will be analyzed by Resource Provisioning and a trouble report is created. + +Either trouble report or the normal execution notification will be included in a status report and sent back to Service Management. + +Service Management then prepares the final status report based on the received information. + +Subsequently it has to be determined what counter measures should be taken depending on the information in the final status report. + +Three alternative process paths may be taken. + +For the case that no problem was detected at all , the actual service performance is sent back to the Customer Service. + +For the case that minor corrective actions are required , Service Management will undertake corrective actions by themselves. + +Subsequently , the problem resolution report is created and then sent out to Customer Service. + +After sending , this process path of Service Management ends. + +For the case that automatic resource restoration from Resource Provisioning is required , Service Management must create a request for automatic resource restoration. + +This message is then sent to Resource Provisioning. + +Resource Provisioning has been on-hold and waiting for a restoration request but this must happen within 2 days after the status report was sent out , otherwise Resource Provisioning terminates the process. + +After the restoration request is received , all possible errors are tracked. + +Based on the tracked errors , all necessary corrective actions are undertaken by Resource Provisioning. + +Then a trouble-shooting report is created. + +This report is sent out to Service Management ; then the process ends. + +The trouble-shooting report is received by Service Management and this information goes then into the creation of the problem resolution report just as described for ii ). + +Customer Service either receives the actual service performance ( if there was no problem ) or the problem resolution report. + +Then , two concurrent activities are triggered , i.e. + +i ) a report is created for the customer which details the current service performance and the resolution of the problem , and ii ) an SLA violation rebate is reported to Billing & Collections who will adjust the billing. + +The report for the customer is sent out to her. + +After all three activities are completed the process ends within Customer Service. + +After the customer then receives the report about service performance and problem resolution from Customer Service , the process flow at the customer also ends . \ No newline at end of file diff --git a/examples/llm/PET/doc-2.2 b/examples/llm/PET/doc-2.2 new file mode 100644 index 000000000..54fc9cf61 --- /dev/null +++ b/examples/llm/PET/doc-2.2 @@ -0,0 +1,65 @@ +The process is initiated by a switch-over request. + +In doing so , the customer transmits his data to the customer service department of the company. + +Customer service is a shared service center between the departments Sales and Distribution. + +The customer data is received by customer service and based on this data a customer data object is entered into the CRM system. + +After customer data has been entered it should then be compared with the internal customer data base and checked for completeness and plausibility. + +In case of any errors these should be corrected on the basis of a simple error list. + +The comparison of data is done to prevent individual customer data being stored multiple times. + +In case the customer does not exist in the customer data base , a new customer object is being created which will remain the data object of interest during the rest of the process flow. + +This object consists of data elements such as the customer's name and address and the assigned power gauge. + +The generated customer object is then used , in combination with other customer data to prepare the contract documents for the power supplier switch ( including data such as bank connection , information on the selected rate , requested date of switch-over ). + +In the following an automated check of the contract documents is carried out within the CIS ( customer information system ) in order to confirm their successful generation. + +In case of a negative response , i.e. + +the contract documents are not ( or incorrectly ) generated , the causing issues are being analyzed and resolved. + +Subsequently the contract documents are generated once again. + +In case of a positive response a confirmation document is sent out to the customer stating that the switch-over to the new supplier can be executed. + +A request to the grid operator is automatically sent out by the CIS. + +It puts the question whether the customer may be supplied by the selected supplier in the future. + +The switch-over request is checked by the grid operator for supplier concurrence , and the grid operator transmits a response comment. + +In the case of supplier concurrence the grid operator would inform all involved suppliers and demand the resolution of the conflict. + +The grid operator communicates with the old supplier and carries out the termination of the sales agreement between the customer and the old supplier ( i.e. + +the customer service ( of the new supplier ) does not have to interact with the old supplier regarding termination ). + +If there are not any objections by the grid operator ( i.e. + +no supplier concurrence ) , customer service creates a CIS contract. + +The customer then has the chance to check the contract details and based on this check may decide to either withdraw from the switch contract or confirm it. + +Depending on the customer's acceptance / rejection the process flow at customer service either ends ( in case of withdrawal ) or continues ( in case of a confirmation ). + +An additional constraint is that the customer can only withdraw from the offered contract within 7 days after the 7th day the contract will be regarded as accepted and the process continues. + +The confirmation message by the customer is therefore not absolutely necessary ( as it will count as accepted after 7 days in any way ) but it can speed up the switch process. + +On the switch-date , but no later than 10 days after power supply has begun , the grid operator transmits the power meter data to the customer service and the old supplier via messages containing a services consumption report. + +At the same time , the grid operator computes the final billing based on the meter data and sends it to the old supplier. + +Likewise the old supplier creates and sends the final billing to the customer. + +For the customer as well as the grid operator the process ends then. + +After receiving the meter data customer service imports the meter data to systems that require the information. + +The process of winning a new customer ends here . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.1 b/examples/llm/PET/doc-3.1 new file mode 100644 index 000000000..368dcf1d2 --- /dev/null +++ b/examples/llm/PET/doc-3.1 @@ -0,0 +1,13 @@ +The party sends a warrant possession request asking a warrant to be released. + +The Client Service Back Office as part of the Small Claims Registry Operations receives the request and retrieves the SCT file. + +Then , the SCT Warrant Possession is forwarded to Queensland Police. + +The SCT physical file is stored by the Back Office awaiting a report to be sent by the Police. + +When the report is received , the respective SCT file is retrieved. + +Then , Back Office attaches the new SCT document , and stores the expanded SCT physical file. + +After that , some other MC internal staff receives the physical SCT file ( out of scope ) . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.2 b/examples/llm/PET/doc-3.2 new file mode 100644 index 000000000..6e4d0dfb5 --- /dev/null +++ b/examples/llm/PET/doc-3.2 @@ -0,0 +1,7 @@ +Each morning , the files which have yet to be processed need to be checked , to make sure they are in order for the court hearing that day. + +If some files are missing , a search is initiated , otherwise the files can be physically tracked to the intended location. + +Once all the files are ready , these are handed to the Associate , and meantime the Judgeis Lawlist is distributed to the relevant people. + +Afterwards , the directions hearings are conducted . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.3 b/examples/llm/PET/doc-3.3 new file mode 100644 index 000000000..fc5f61fd5 --- /dev/null +++ b/examples/llm/PET/doc-3.3 @@ -0,0 +1,9 @@ +After a claim is registered , it is examined by a claims officer. + +The claims officer then writes a settlement recommendation. + +This recommendation is then checked by a senior claims officer who may mark the claim as OK or Not OK. + +If the claim is marked as Not OK , it is sent back to the claims officer and the recommendation is repeated. + +If the claim is OK , the claim handling process proceeds . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.5 b/examples/llm/PET/doc-3.5 new file mode 100644 index 000000000..38651596b --- /dev/null +++ b/examples/llm/PET/doc-3.5 @@ -0,0 +1,17 @@ +Mail from the party is collected on a daily basis by the Mail Processing Unit. + +Within this unit , the Mail Clerk sorts the unopened mail into the various business areas. + +The mail is then distributed. + +When the mail is received by the Registry , it is opened and sorted into groups for distribution , and thus registered in a manual incoming Mail Register. + +Afterwards , the Assistant Registry Manager within the Registry performs a quality check. + +If the mail is not compliant , a list of requisition explaining the reason for rejection is compiled and sent back to the party. + +Otherwise , the matter details ( types of action ) are captured and provided to the Cashier , who takes the applicable fees attached to the mail. + +At this point , the Assistant Registry Manager puts the receipt and copied documents into an envelope and posts it to the party. + +Meantime , the Cashier captures the Party Details and prints the Physical Court File . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.6 b/examples/llm/PET/doc-3.6 new file mode 100644 index 000000000..4f59b2984 --- /dev/null +++ b/examples/llm/PET/doc-3.6 @@ -0,0 +1,15 @@ +When a claim is received , it is first checked whether the claimant is insured by the organization. + +If not , the claimant is informed that the claim must be rejected. + +Otherwise , the severity of the claim is evaluated. + +Based on the outcome ( simple or complex claims ) , relevant forms are sent to the claimant. + +Once the forms are returned , they are checked for completeness. + +If the forms provide all relevant details , the claim is registered in the Claims Management system , which ends the Claims Notification process. + +Otherwise , the claimant is informed to update the forms. + +Upon reception of the updated forms , they are checked again . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.7 b/examples/llm/PET/doc-3.7 new file mode 100644 index 000000000..cd679b250 --- /dev/null +++ b/examples/llm/PET/doc-3.7 @@ -0,0 +1,9 @@ +The Police Report related to the car accident is searched within the Police Report database and put in a file together with the Claim Documentation. + +This file serves as input to a claims handler who calculates an initial claim estimate. + +Then , the claims handler creates an Action Plan based on an Action Plan Checklist available in the Document Management system. + +Based on the Action Plan , a claims manager tries to negotiate a settlement on the claim estimate. + +The claimant is informed of the outcome , which ends the process . \ No newline at end of file diff --git a/examples/llm/PET/doc-3.8 b/examples/llm/PET/doc-3.8 new file mode 100644 index 000000000..85e70d2fe --- /dev/null +++ b/examples/llm/PET/doc-3.8 @@ -0,0 +1,13 @@ +The process starts when a customer submits a claim by sending in relevant documentation. + +The Notification department at the car insurer checks the documents upon completeness and registers the claim. + +Then , the Handling department picks up the claim and checks the insurance. + +Then , an assessment is performed. + +If the assessment is positive , a garage is phoned to authorise the repairs and the payment is scheduled ( in this order ). + +Otherwise , the claim is rejected. + +In any case ( whether the outcome is positive or negative ) , a letter is sent to the customer and the process is considered to be complete . \ No newline at end of file diff --git a/examples/llm/PET/doc-4.1 b/examples/llm/PET/doc-4.1 new file mode 100644 index 000000000..3cca0cf1a --- /dev/null +++ b/examples/llm/PET/doc-4.1 @@ -0,0 +1,79 @@ +The intake workflow starts with a notice by telephone at the secretarial office of the mental health care institute. + +This notice is done by the family doctor of somebody who is in need of mental treatment. + +The secretarial worker inquires after the name and residence of the patient. + +On the basis of this information , the doctor is put through to the nursing officer responsible for the part of the region that the patient lives in. + +The nursing officer makes a full inquiry into the mental , health , and social state of the patient in question. + +This information is recorded on a registration form. + +At the end of the conversation , this form is handed in at the secretarial office of the institute. + +Here , the information on the form is stored in the information system and subsequently printed. + +For new patients , a patient file is created. + +The registration form as well as the print from the information system are stored in the patient file. + +Patient files are kept at the secretarial office and may not leave the building. + +At the secretarial office , two registration cards are produced for respectively the future first and second intaker of the patient. + +The registration card contains a set of basic patient data. + +The new patient is added on the list of new notices. + +Halfway the week , at Wednesday , a staff meeting of the entire medical team takes place. + +The medical team consists of social-medical workers , physicians , and a psychiatrist. + +At this meeting , the team-leader assigns all new patients on the list of new notices to members of the team. + +Each patient will be assigned to a social-medical worker , who will act as the first intaker of the patient. + +One of the physicians will act as the second intaker. + +In assigning intakers , the teamleader takes into account their expertise , the region they are responsible for , earlier contacts they might have had with the patient , and their case load. + +The assignments are recorded on an assignment list which is handed to the secretarial office. + +For each new assignment , it is also determined whether the medical file of the patient is required. + +This information is added to the assignment list. + +The secretarial office stores the assignment of each patient of the assignment list in the information system. + +It passes the produced registration cards to the first and second intaker of each newly assigned patient. + +An intaker keeps this registration with him at times when visiting the patient and in his close proximity when he is at the office. + +For each patient for which the medical file is required , the secretarial office prepares and sends a letter to the family doctor of the patient , requesting for a copy of the medical file. + +As soon as this copy is received , the secretarial office will inform the second intaker and add the copy to the patient file. + +The first intaker plans a meeting with the patient as soon as this is possible. + +During the first meeting , the patient is examined using a standard checklist which is filled out. + +Additional observations are registered in a personal notebook. + +After a visit , the first intaker puts a copy of these notes in the file of a patient. + +The standard checklist is also added to the patient's file. + +The second intaker plans the first meeting only after the medical information of the physician if required has been received. + +Physicians use dictaphones to record their observations made during meetings with patients. + +The secretarial office types out these tapes , after which the information is added to the patient file. + +As soon as the meetings of the first and second intaker with the patient have taken place , the secretarial office puts the patient on the list of patients that reach this status. + +For the staff meeting on Wednesday , they provide the team-leader with a list of these patients. + +For each of these patients , the first and second intaker together with the team-leader and the attending psychiatrist formulate a treatment plan. + +This treatment plan formally ends the intake procedure . \ No newline at end of file diff --git a/examples/llm/PET/doc-5.1 b/examples/llm/PET/doc-5.1 new file mode 100644 index 000000000..387fe5f00 --- /dev/null +++ b/examples/llm/PET/doc-5.1 @@ -0,0 +1,11 @@ +The loan approval process starts by receiving a customer request for a loan amount. + +The risk assessment Web service is invoked to assess the request. + +If the loan is small and the customer is low risk , the loan is approved. + +If the customer is high risk , the loan is denied. + +If the customer needs further review or the loan amount is for $10,000 or more , the request is sent to the approver Web service. + +The customer receives feedback from the assessor or approver . \ No newline at end of file diff --git a/examples/llm/PET/doc-5.2 b/examples/llm/PET/doc-5.2 new file mode 100644 index 000000000..2e41b548c --- /dev/null +++ b/examples/llm/PET/doc-5.2 @@ -0,0 +1,9 @@ +The process of Vacations Request starts when any employee of the organization submits a vacation request. + +Once the requirement is registered , the request is received by the immediate supervisor of the employee requesting the vacation. + +The supervisor must approve or reject the request. + +If the request is rejected , the application is returned to the applicant / employee who can review the rejection reasons. + +If the request is approved a notification is generated to the Human Resources Representative , who must complete the respective management procedures . \ No newline at end of file diff --git a/examples/llm/PET/doc-5.3 b/examples/llm/PET/doc-5.3 new file mode 100644 index 000000000..e64cb6a59 --- /dev/null +++ b/examples/llm/PET/doc-5.3 @@ -0,0 +1,19 @@ +The process of an Office Supply Request starts when any employee of the organization submits an office supply request. + +Once the requirement is registered , the request is received by the immediate supervisor of the employee requesting the office supplies. + +The supervisor must approve or ask for a change , or reject the request. + +If the request is rejected the process will end. + +If the request is asked to make a change then it is returned to the petitioner / employee who can review the comments for the change request. + +If the request is approved it will go to the purchase department that will be in charge of making quotations ( using a subprocess ) and select a vendor. + +If the vendor is not valid in the system the purchase department will have to choose a different vendor. + +After a vendor is selected and confirmed , the system will generate and send a purchase order and wait for the product to be delivered and the invoice received. + +In any case the system will send a notification to let the user know what the result was. + +In any of the cases , approval , rejection or change required the system will send the user a notification . \ No newline at end of file diff --git a/examples/llm/PET/doc-5.4 b/examples/llm/PET/doc-5.4 new file mode 100644 index 000000000..5fd1716a3 --- /dev/null +++ b/examples/llm/PET/doc-5.4 @@ -0,0 +1,31 @@ +An employee purchases a product or service he requires. + +For instance , a sales person on a trip rents a car. + +The employee submits an expense report with a list of items , along with the receipts for each item. + +A supervisor reviews the expense report and approves or rejects the report. + +Since the company has expense rules , there are circumstances where the supervisor can accept or reject the report upon first inspection. + +These rules could be automated , to reduce the workload on the supervisor. + +If the supervisor rejects the report , the employee , who submitted it , is given a chance to edit it , for example to correct errors or better describe an expense. + +If the supervisor approves the report , it goes to the treasurer. + +The treasurer checks that all the receipts have been submitted and match the items on the list. + +If all is in order , the treasurer accepts the expenses for processing ( including , e.g. + +, payment or refund , and accounting ). + +If receipts are missing or do not match the report , he sends it back to the employee. + +If a report returns to the employee for corrections , it must again go to a supervisor , even if the supervisor previously approved the report. + +If the treasurer accepts the expenses for processing , the report moves to an automatic activity that links to a payment system. + +The process waits for the payment confirmation. + +After the payment is confirmed , the process ends . \ No newline at end of file diff --git a/examples/llm/PET/doc-6.1 b/examples/llm/PET/doc-6.1 new file mode 100644 index 000000000..3091da445 --- /dev/null +++ b/examples/llm/PET/doc-6.1 @@ -0,0 +1,37 @@ +As a basic principle , ACME AG receives invoices on paper or fax. + +These are received by the Secretariat in the central inbox and forwarded after a short visual inspection to an accounting employee. + +In `` ACME Financial Accounting `` , a software specially developed for the ACME AG , she identifies the charging suppliers and creates a new instance ( invoice ). + +She then checks the invoice items and notes the corresponding cost center at the ACME AG and the related cost center managers for each position on a separate form ( `` docket `` ). + +The docket and the copy of the invoice go to the internal mail together and are sent to the first cost center manager to the list. + +He reviews the content for accuracy after receiving the copy of the invoice. + +Should everything be in order , he notes his code one on the docket ( `` accurate position - AP `` ) and returns the copy of the invoice to the internal mail. + +From it , the copy of the invoice is passed on to the next cost center manager , based on the docket , or if all items are marked correct , sent back to accounting. + +Therefore , the copy of invoice and the docket gradually move through the hands of all cost center managers until all positions are marked as completely accurate. + +However , if inconsistencies exist , e.g. + +because the ordered product is not of the expected quantity or quality , the cost center manager rejects the AP with a note and explanatory statement on the docket , and the copy of the invoice is sent back to accounting directly. + +Based on the statements of the cost center managers , she will proceede with the clarification with the vendor , but , if necessary , she consults the cost center managers by telephone or e-mail again. + +When all inconsistencies are resolved , the copy of the invoice is sent to the cost center managers again , and the process continues. + +After all invoice items are AP , the accounting employee forwards the copy of the invoice to the commercial manager. + +He makes the commercial audit and issues the approval for payment. + +If the bill amount exceeds EUR 20 , the Board wants to check it again ( 4 - eyes-principle ). + +The copy of the invoice including the docket moves back to the accounting employee in the appropriate signature file. + +Should there be a complaint during the commercial audit , it will be resolved by the accounting employee with the supplier. + +After the commercial audit is successfully completed , the accounting employee gives payment instructions and closes the instance in `` ACME financial accounting `` . \ No newline at end of file diff --git a/examples/llm/PET/doc-6.2 b/examples/llm/PET/doc-6.2 new file mode 100644 index 000000000..7a2b69edd --- /dev/null +++ b/examples/llm/PET/doc-6.2 @@ -0,0 +1,9 @@ +The process starts periodically on the first of each month , when Assembler AG places an order with the supplier in order to request more product parts. + +a ) Assembler AG sends the order to the supplier. + +b ) The supplier processes the order. + +c ) The supplier sends an invoice to Assembler AG. + +d ) Assembler AG receives the invoice . \ No newline at end of file diff --git a/examples/llm/PET/doc-6.3 b/examples/llm/PET/doc-6.3 new file mode 100644 index 000000000..be120e59e --- /dev/null +++ b/examples/llm/PET/doc-6.3 @@ -0,0 +1,17 @@ +Every time we get a new order from the sales department , first , one of my masters determines the necessary parts and quantities as well as the delivery date. + +Once that information is present , it has to be entered into our production planning system ( PPS ). + +It optimizes our production processes and creates possibly uniform work packages so that the setup times are minimized. + +Besides , it creates a list of parts to be procured. + +Unfortunately it is not coupled correctly to our Enterprise Resource Planning system ( ERP ) , so the data must be transferred manually. + +By the way , that is the second step. + +Once all the data is present , we need to decide whether any parts are missing and must be procured or if this is not necessary. + +Once production is scheduled to start , we receive a notice from the system and an employee takes care of the implementation. + +Finally , the order will be checked again for its quality . \ No newline at end of file diff --git a/examples/llm/PET/doc-6.4 b/examples/llm/PET/doc-6.4 new file mode 100644 index 000000000..b49728d94 --- /dev/null +++ b/examples/llm/PET/doc-6.4 @@ -0,0 +1,27 @@ +The first step is to determine contact details of potential customers. + +This can be achieved in several ways. + +Sometimes , we buy details for cold calls , sometimes , our marketing staff participates in exhibitions and sometimes , you just happen to know somebody , who is interested in the product. + +Then we start calling the customer. + +That is done by the call center staff. + +They are determining the contact person and the budget which would be available for the project. + +Of course , asking the customer whether he is generally interested is also important. + +If this is not the case , we leave him alone , except if the potential project budget is huge. + +Then the head of development personally tries to acquire the customer. + +If the customer is interested in the end , the next step is a detailed online presentation. + +It is given either by a sales representative or by a pre-sales employee in case of a more technical presentation. + +Afterwards we are waiting for the customer to come back to us. + +If we are not contacted within 2 weeks , a sales representative is calling the customer. + +The last phase is the creation of a quotation . \ No newline at end of file diff --git a/examples/llm/PET/doc-7.1 b/examples/llm/PET/doc-7.1 new file mode 100644 index 000000000..2e2af1ea6 --- /dev/null +++ b/examples/llm/PET/doc-7.1 @@ -0,0 +1,13 @@ +First , the Manager checks the open leads. + +Afterwards , he selects the top five ones. + +He then tells his Sales Assistant to call the contact person of the leads. + +The Sales Assistant calls each customer. + +If someone is interested , he sends a note to the Manager. + +The Manager then processes the lead. + +Otherwise , he calls the next customer . \ No newline at end of file diff --git a/examples/llm/PET/doc-8.1 b/examples/llm/PET/doc-8.1 new file mode 100644 index 000000000..a4519a235 --- /dev/null +++ b/examples/llm/PET/doc-8.1 @@ -0,0 +1,5 @@ +The process is triggered by the demand of a functional department to fill a post. + +The post is advertised , applicants apply , the applications are checked and the post is filled. + +The process finishes when the post was filled , precisely through the conclusion of a contract of employment . \ No newline at end of file diff --git a/examples/llm/PET/doc-8.2 b/examples/llm/PET/doc-8.2 new file mode 100644 index 000000000..134082b62 --- /dev/null +++ b/examples/llm/PET/doc-8.2 @@ -0,0 +1,13 @@ +I am the HR clerk. + +When a vacancy is reported to me , I create a job description from the information. + +Sometimes there is still confusion in the message , then I must ask the Department again. + +I am submitting the job description for consideration and waiting for the approval. + +But , it can also happen that the department does not approve it , but rejects it , and requests a correction. + +Then I correct the description and submit it again for consideration. + +If the description is finally approved , I post the job . \ No newline at end of file diff --git a/examples/llm/PET/doc-8.3 b/examples/llm/PET/doc-8.3 new file mode 100644 index 000000000..516df82d6 --- /dev/null +++ b/examples/llm/PET/doc-8.3 @@ -0,0 +1,11 @@ +I am the Head of the functional department. + +When I have detected a number of personnel requirements , I report the vacancy to the Personnel Department. + +Then I wait to get the job description for review before it is advertized. + +Under certain circumstances , I must ask for corrections again , otherwise I approve the job description. + +Sometimes it also happens that the colleague from the HR department still has questions about the tasks and requirements before he can describe the job. + +Then I am available for clarifications , of course . \ No newline at end of file diff --git a/examples/llm/PET/doc-9.1 b/examples/llm/PET/doc-9.1 new file mode 100644 index 000000000..ee22b5dfc --- /dev/null +++ b/examples/llm/PET/doc-9.1 @@ -0,0 +1,15 @@ +Every weekday morning , the database is backed up and then it is checked to see whether the Account Defaulter table has new records. + +If no new records are found , then the process should check the CRM system to see whether new returns have been filed. + +If new returns exist , then register all defaulting accounts and customers. + +If the defaulting client codes have not been previously advised , produce another table of defaulting accounts and send to account management. + +All of this must be completed by 2 : 30 pm , if it is not , then an alert should be sent to the supervisor. + +Once the new defaulting account report has been completed , check the CRM system to see whether new returns have been filed. + +If new returns have been filed , reconcile with the existing account defaulters table. + +This must be completed by 4 : 0 pm otherwise a supervisor should be sent a message . \ No newline at end of file diff --git a/examples/llm/PET/doc-9.2 b/examples/llm/PET/doc-9.2 new file mode 100644 index 000000000..97b2d9578 --- /dev/null +++ b/examples/llm/PET/doc-9.2 @@ -0,0 +1,9 @@ +The Customer Service Representative sends a Mortgage offer to the customer and waits for a reply. + +If the customer calls or writes back declining the mortgage , the case details are updated and the work is then archived prior to cancellation. + +If the customer sends back the completed offer documents and attaches all prerequisite documents then the case is moved to administration for completion. + +If all pre-requisite documents are not provided a message is generated to the customer requesting outstanding documents. + +If no answer is received after 2 weeks , the case details are updated prior to archive and cancellation . \ No newline at end of file diff --git a/examples/llm/PET/doc-9.3 b/examples/llm/PET/doc-9.3 new file mode 100644 index 000000000..ac2dc4a43 --- /dev/null +++ b/examples/llm/PET/doc-9.3 @@ -0,0 +1,7 @@ +In November of each year , the Coordination Unit at the Town Planning Authority drafts a schedule of meetings for the next calendar year and adds draft dates to all calendars. + +The Support Officer then checks the dates and suggests modifications. + +The Coordination Unit then rechecks all dates and looks for potential conflicts. + +The final schedule of meeting dates is sent to all the independent Committee Members by email , who then check their diaries and advise the Coordination Unit of any conflicts . \ No newline at end of file diff --git a/examples/llm/PET/doc-9.4 b/examples/llm/PET/doc-9.4 new file mode 100644 index 000000000..2e7879146 --- /dev/null +++ b/examples/llm/PET/doc-9.4 @@ -0,0 +1,9 @@ +Once the dates are finalized ( by the Coordination Unit ) , the Support Officer updates all group calendars and creates meeting folders for each meeting and ensures all appropriate documents are uploaded to system. + +Committee Members are advised a week before each meeting to read all related documents. + +The Committee Members hold their meeting , and the Support Office then produces minutes including any Action Points for each Committee Member. + +Within 5 working days , the Coordination Unit must conduct a QA check on the minutes , which are then sent to all Committee Members. + +The Support Officer then updates all departmental records . \ No newline at end of file diff --git a/examples/llm/PET/doc-9.5 b/examples/llm/PET/doc-9.5 new file mode 100644 index 000000000..850d0c5f0 --- /dev/null +++ b/examples/llm/PET/doc-9.5 @@ -0,0 +1,13 @@ +After the Expense Report is received , a new account must be created if the employee does not already have one. + +The report is then reviewed for automatic approval. + +Amounts under $200 are automatically approved , whereas amounts equal to or over $200 require approval of the supervisor. + +In case of rejection , the employee must receive a rejection notice by email. + +Otherwise , the reimbursement goes to the employees direct deposit bank account. + +If the request is not completed in 7 days , then the employee must receive an approval in progress email. + +If the request is not finished within 30 days , then the process is stopped and the employee receives an email cancellation notice and must re-submit the expense report . \ No newline at end of file diff --git a/examples/llm/abstractions/log_to_acti_summary.py b/examples/llm/abstractions/log_to_acti_summary.py new file mode 100644 index 000000000..c5db4f19e --- /dev/null +++ b/examples/llm/abstractions/log_to_acti_summary.py @@ -0,0 +1,124 @@ +from pm4py.objects.conversion.log import converter as log_converter +from typing import Union, Optional, Dict, Any +from pm4py.objects.log.obj import EventLog, EventStream +from enum import Enum +from pm4py.util import exec_utils, constants, xes_constants +from pm4py.statistics.service_time.pandas import get as service_time_get +from pm4py.statistics.eventually_follows.pandas import get as eventually_follows +import pandas as pd + + +class Parameters(Enum): + MAX_LEN = "max_len" + RESPONSE_HEADER = "response_header" + PERFORMANCE_AGGREGATION = "performance_aggregation" + ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY + TIMESTAMP_KEY = constants.PARAMETER_CONSTANT_TIMESTAMP_KEY + START_TIMESTAMP_KEY = constants.PARAMETER_CONSTANT_START_TIMESTAMP_KEY + CASE_ID_KEY = constants.PARAMETER_CONSTANT_CASEID_KEY + + +def apply(log_obj: Union[EventLog, EventStream, pd.DataFrame], + parameters: Optional[Dict[Union[str, Parameters], Any]] = None) -> str: + """ + Provides an abstraction of the activities' frequency and performance. + + Minimum Viable Example: + + import pm4py + from pm4py.algo.querying.llm.abstractions import log_to_acti_summary + + log = pm4py.read_xes("tests/input_data/receipt.xes") + print(log_to_acti_summary.apply(log)) + + Example output: + + Below you find the top activities of the event log, specified with their total number of occurrences, the number of cases in which they occur, an aggregation of the service time, an aggregation of the times from the preceding activities and to the succeeding activities. + + Confirmation of receipt [tot.occ=1434; num.cases=1434; service time=0.00 s; time from prec.=0.00 s; time to succ.=76014.05 s] + T02 Check confirmation of receipt [tot.occ=1368; num.cases=1316; service time=0.00 s; time from prec.=100581.24 s; time to succ.=44701.62 s] + T06 Determine necessity of stop advice [tot.occ=1416; num.cases=1309; service time=0.00 s; time from prec.=186313.29 s; time to succ.=44757.08 s] + T04 Determine confirmation of receipt [tot.occ=1307; num.cases=1303; service time=0.00 s; time from prec.=36815.50 s; time to succ.=65668.55 s] + + + Parameters + --------------- + log_obj + Log object + parameters + Optional parameters of the algorithm, including: + - Parameters.MAX_LEN => desidered length of the textual abstraction + - Parameters.RESPONSE_HEADER => includes an header in the textual abstraction, which explains the context + - Parameters.PERFORMANCE_AGGREGATION => performance metric to be used to express the performance (e.g., mean). Available options: mean, median, stdev, min, max, sum + - Parameters.ACTIVITY_KEY => the attribute of the log to be used as activity + - Parameters.TIMESTAMP_KEY => the attribute of the log to be used as timestamp + - Parameters.CASE_ID_KEY => the attribute of the log to be used as case identifier + + Returns + -------------- + textual_abstraction + Textual abstraction of the activities frequency and of their performance. + """ + if parameters is None: + parameters = {} + + response_header = exec_utils.get_param_value(Parameters.RESPONSE_HEADER, parameters, True) + max_len = exec_utils.get_param_value(Parameters.MAX_LEN, parameters, constants.OPENAI_MAX_LEN) + + activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, xes_constants.DEFAULT_NAME_KEY) + timestamp_key = exec_utils.get_param_value(Parameters.TIMESTAMP_KEY, parameters, + xes_constants.DEFAULT_TIMESTAMP_KEY) + start_timestamp_key = exec_utils.get_param_value(Parameters.START_TIMESTAMP_KEY, parameters, + xes_constants.DEFAULT_TIMESTAMP_KEY) + case_id_key = exec_utils.get_param_value(Parameters.CASE_ID_KEY, parameters, constants.CASE_CONCEPT_NAME) + performance_aggregation = exec_utils.get_param_value(Parameters.PERFORMANCE_AGGREGATION, parameters, "mean") + + log_obj = log_converter.apply(log_obj, variant=log_converter.Variants.TO_DATA_FRAME, parameters=parameters) + log_obj = log_obj[list({activity_key, timestamp_key, start_timestamp_key, case_id_key})] + + num_occ = log_obj[activity_key].value_counts().to_dict() + num_cases = log_obj.groupby([case_id_key, activity_key]).first().reset_index()[ + activity_key].value_counts().to_dict() + + parameters["aggregationMeasure"] = performance_aggregation + service_times = service_time_get.apply(log_obj, parameters=parameters) + + dir_follo_dataframe = eventually_follows.get_partial_order_dataframe(log_obj.copy(), activity_key=activity_key, + start_timestamp_key=start_timestamp_key, + timestamp_key=timestamp_key, + case_id_glue=case_id_key, + sort_caseid_required=False, + sort_timestamp_along_case_id=False, + reduce_dataframe=False) + + post_times = dir_follo_dataframe.groupby(activity_key)[constants.DEFAULT_FLOW_TIME].agg( + performance_aggregation).to_dict() + pre_times = dir_follo_dataframe.groupby(activity_key + "_2")[constants.DEFAULT_FLOW_TIME].agg( + performance_aggregation).to_dict() + + activities_list = [] + for act in num_occ: + activities_list.append({"activity": act, "num_occ": num_occ[act], "num_cases": num_cases[act], + "agg_service_time": service_times[act] if act in service_times else 0.0, + "agg_pre_times": pre_times[act] if act in pre_times else 0.0, + "agg_post_times": post_times[act] if act in post_times else 0.0}) + + activities_list = sorted(activities_list, key=lambda x: (x["num_cases"], x["num_occ"], x["activity"]), reverse=True) + + ret = "\n\n" + + if response_header: + ret += "Below you find the top activities of the event log, specified with their total number of occurrences, the number of cases in which they occur, an aggregation of the service time, an aggregation of the times from the preceding activities and to the succeeding activities.\n\n" + + for dct in activities_list: + ths = "%s [tot.occ=%d; num.cases=%d; service time=%.2f s; time from prec.=%.2f s; time to succ.=%.2f s]\n" % ( + dct["activity"], dct["num_occ"], dct["num_cases"], dct["agg_service_time"], dct["agg_pre_times"], + dct["agg_post_times"]) + if len(ret) + len(ths) < max_len: + ret = ret + ths + else: + break + + ret += "\n\n" + + return ret diff --git a/examples/llm/abstractions/log_to_top_resources.py b/examples/llm/abstractions/log_to_top_resources.py new file mode 100644 index 000000000..f7293f031 --- /dev/null +++ b/examples/llm/abstractions/log_to_top_resources.py @@ -0,0 +1,140 @@ +from pm4py.objects.conversion.log import converter as log_converter +from typing import Union, Optional, Dict, Any +from pm4py.objects.log.obj import EventLog, EventStream +from enum import Enum +from pm4py.util import exec_utils, constants, xes_constants +import pandas as pd +from copy import copy + + +class Parameters(Enum): + MAX_LEN = "max_len" + RESPONSE_HEADER = "response_header" + DEFAULT_MIN_ACTIVITIES = "default_min_activities" + ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY + RESOURCE_KEY = constants.PARAMETER_CONSTANT_RESOURCE_KEY + + +def get_abstr_from_dict(ret, activities_dict, response_header): + """ + Internal method to get the textual abstraction starting from the computations already performed. + """ + abstr = ["\n\n"] + + if response_header: + abstr.append( + "In the following text, you find the top activities along with their number of occurrences in the event log and the number of unique resources performing them.") + abstr.append("The top resources for such activities are included.\n\n") + + sort_act = sorted([(x, activities_dict[x][0], activities_dict[x][1], ret[x]) for x in ret], + key=lambda x: (x[1], x[2], x[0]), reverse=True) + + for el in sort_act: + abstr.append("%s (num.occ=%d ; num.resources=%d)" % (el[0], el[1], el[2])) + + if el[3]: + abstr.append(" top resources=[") + + this_res = sorted([(x, y) for x, y in el[3].items()], key=lambda z: (z[1], z[0]), reverse=True) + + for i in range(len(this_res)): + if i > 0: + abstr.append("; ") + abstr.append("%s=%d" % (this_res[i][0], this_res[i][1])) + abstr.append("]") + + abstr.append("\n") + + abstr.append("\n\n") + + abstr1 = "".join(abstr) + return abstr1 + + +def apply(log: Union[EventLog, EventStream, pd.DataFrame], parameters: Optional[Dict[Any, Any]] = None) -> str: + """ + Textually abstracts the top activities/resources combinations in the event log. + + + Minimum Viable Example: + + import pm4py + from pm4py.algo.querying.llm.abstractions import log_to_resources + + + log = pm4py.read_xes("C:/receipt.xes") + res = log_to_resources.apply(log) + print(res) + + + Example output: + + In the following text, you find the top activities along with their number of occurrences in the event log and the number of unique resources performing them.The top resources for such activities are included. + + Confirmation of receipt (num.occ=1434 ; num.resources=41) top resources=[Resource01=195; admin2=114; Resource02=102; Resource03=87; Resource04=81; Resource07=78; Resource08=74; Resource06=70; Resource05=65; Resource11=58; Resource09=55; Resource15=51; Resource12=49; Resource13=47; Resource14=44; Resource17=43; Resource27=37; Resource16=35; Resource18=29; Resource10=21; Resource21=19; Resource20=18; Resource23=14; Resource22=12; Resource26=7; Resource25=7; Resource30=4; Resource33=2; Resource31=2; Resource29=2; Resource28=2; admin3=1; admin1=1; Resource43=1; Resource42=1; Resource38=1; Resource37=1; Resource36=1; Resource35=1; Resource34=1; Resource19=1] + T06 Determine necessity of stop advice (num.occ=1416 ; num.resources=34) top resources=[Resource01=203; Resource02=114; Resource04=85; Resource03=85; Resource05=84; Resource07=83; Resource08=75; Resource06=75; Resource11=74; Resource12=72; Resource09=67; Resource15=58; Resource13=53; Resource14=48; Resource17=43; Resource16=36; Resource18=28; admin2=20; Resource20=18; Resource21=16; Resource22=15; Resource23=14; Resource26=12; Resource25=12; Resource29=6; Resource28=6; Resource37=2; Resource35=2; Resource34=2; Resource33=2; Resource31=2; Resource30=2; test=1; Resource36=1] + T02 Check confirmation of receipt (num.occ=1368 ; num.resources=40) top resources=[Resource01=209; Resource02=95; Resource04=91; Resource03=86; Resource06=73; Resource08=65; Resource05=65; Resource19=64; Resource10=62; Resource13=55; Resource09=51; Resource07=50; Resource24=44; Resource12=44; Resource14=43; Resource16=36; Resource17=32; Resource15=32; Resource18=30; Resource11=30; Resource21=18; Resource20=18; Resource22=13; Resource23=12; admin2=9; Resource32=9; Resource25=6; Resource26=5; Resource28=4; Resource30=3; Resource39=2; Resource34=2; Resource31=2; Resource29=2; admin1=1; TEST=1; Resource38=1; Resource36=1; Resource35=1; Resource33=1] + T04 Determine confirmation of receipt (num.occ=1307 ; num.resources=37) top resources=[Resource10=240; Resource01=184; Resource03=81; Resource04=68; Resource02=67; Resource06=66; Resource19=61; Resource05=60; Resource07=58; Resource09=46; Resource14=41; Resource12=41; Resource13=40; Resource18=36; Resource16=36; Resource08=31; Resource11=29; Resource15=28; Resource20=18; Resource21=15; Resource17=13; Resource22=12; Resource23=11; admin2=3; Resource26=3; Resource25=3; admin3=2; admin1=2; Resource31=2; Resource29=2; Resource28=2; Resource38=1; Resource36=1; Resource35=1; Resource34=1; Resource33=1; Resource24=1] + + + Parameters + ---------------- + log + Log object + parameters + Parameters of the algorithm, including: + - Parameters.ACTIVITY_KEY => the attribute to be used as activity + - Parameters.RESOURCE_KEY => the attribute to be used as resource + - Parameters.DEFAULT_MIN_ACTIVITIES => minimum number of different activities to include in the textual abstraction + - Parameters.ACTIVITY_KEY => attribute of the log to be used as activity + - Parameters.RESOURCE_KEY => attribute of the log to be used as resource + + Returns + ---------------- + textual_abstraction + Textual abstraction + """ + if parameters is None: + parameters = {} + + max_len = exec_utils.get_param_value(Parameters.MAX_LEN, parameters, constants.OPENAI_MAX_LEN) + response_header = exec_utils.get_param_value(Parameters.RESPONSE_HEADER, parameters, True) + default_min_activities = exec_utils.get_param_value(Parameters.DEFAULT_MIN_ACTIVITIES, parameters, 15) + activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, xes_constants.DEFAULT_NAME_KEY) + resource_key = exec_utils.get_param_value(Parameters.RESOURCE_KEY, parameters, xes_constants.DEFAULT_RESOURCE_KEY) + + log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME, parameters=parameters) + + activities = log[activity_key].value_counts().to_dict() + activities_unq_resources = log.groupby(activity_key)[resource_key].nunique().to_dict() + activities = [(x, y, activities_unq_resources[x]) for x, y in activities.items()] + activities_dict = {x[0]: (x[1], x[2]) for x in activities} + + activities = sorted(activities, key=lambda z: (z[1], z[2], z[0]), reverse=True) + + ret = {} + for i in range(min(len(activities), default_min_activities)): + new_ret = copy(ret) + new_ret[activities[i][0]] = {} + + if len(get_abstr_from_dict(new_ret, activities_dict, response_header)) > max_len: + break + + ret = new_ret + + activities_resources = log.groupby([activity_key, resource_key]).size().to_dict() + activities_resources = sorted([(x, y) for x, y in activities_resources.items()], key=lambda z: (z[1], z[0]), + reverse=True) + + for el in activities_resources: + new_ret = copy(ret) + if el[0][0] not in new_ret: + new_ret[el[0][0]] = {} + new_ret[el[0][0]][el[0][1]] = el[1] + + if len(get_abstr_from_dict(new_ret, activities_dict, response_header)) > max_len: + break + + ret = new_ret + + return get_abstr_from_dict(ret, activities_dict, response_header) diff --git a/examples/llm/abstractions/log_to_var_paths.py b/examples/llm/abstractions/log_to_var_paths.py new file mode 100644 index 000000000..4ba66e394 --- /dev/null +++ b/examples/llm/abstractions/log_to_var_paths.py @@ -0,0 +1,101 @@ +from pm4py.objects.conversion.log import converter as log_converter +from typing import Union, Optional, Dict, Any +from pm4py.objects.log.obj import EventLog, EventStream +from enum import Enum +from pm4py.util import exec_utils, constants, xes_constants +import pandas as pd + + +class Parameters(Enum): + MAX_LEN = "max_len" + RESPONSE_HEADER = "response_header" + PERFORMANCE_AGGREGATION = "performance_aggregation" + ACTIVITY_KEY = constants.PARAMETER_CONSTANT_ACTIVITY_KEY + TIMESTAMP_KEY = constants.PARAMETER_CONSTANT_TIMESTAMP_KEY + CASE_ID_KEY = constants.PARAMETER_CONSTANT_CASEID_KEY + + +def apply(log_obj: Union[EventLog, EventStream, pd.DataFrame], parameters: Optional[Dict[Any, Any]] = None) -> str: + """ + Provides an abstraction of the paths performance for the process variants of the provided event log. + + Minimum Viable Example: + + import pm4py + from pm4py.algo.querying.llm.abstractions import log_to_var_paths + + log = pm4py.read_xes("tests/input_data/receipt.xes") + print(log_to_var_paths.apply(log)) + + + Example output: + + Below your find a description of the top process variants of the event logs, along with their frequency. The paths of every reported variant are decorated with an aggregation (mean) of the performance of the path in the given variant. + + Confirmation of receipt -(8064.44 s)-> T02 Check confirmation of receipt -(29250.98 s)-> T04 Determine confirmation of receipt -(218458.20 s)-> T05 Print and send confirmation of receipt -(39225.28 s)-> T06 Determine necessity of stop advice [frequency=713] + Confirmation of receipt -(3621.01 s)-> T06 Determine necessity of stop advice -(157907.57 s)-> T10 Determine necessity to stop indication -(116514.54 s)-> T02 Check confirmation of receipt -(144858.47 s)-> T04 Determine confirmation of receipt [frequency=123] + Confirmation of receipt -(79543.37 s)-> T02 Check confirmation of receipt -(169.38 s)-> T06 Determine necessity of stop advice -(144037.68 s)-> T10 Determine necessity to stop indication -(86823.89 s)-> T04 Determine confirmation of receipt [frequency=115] + + + Parameters + --------------- + log_obj + Log object + parameters + Optional parameters of the algorithm, including: + - Parameters.MAX_LEN => desidered length of the textual abstraction + - Parameters.RESPONSE_HEADER => includes an header in the textual abstraction, which explains the context + - Parameters.PERFORMANCE_AGGREGATION => performance metric to be used to express the performance (e.g., mean). Available options: mean, median, stdev, min, max, sum + - Parameters.ACTIVITY_KEY => the attribute of the log to be used as activity + - Parameters.TIMESTAMP_KEY => the attribute of the log to be used as timestamp + - Parameters.CASE_ID_KEY => the attribute of the log to be used as case identifier + + Returns + -------------- + textual_abstraction + Textual abstraction of the paths' performance for every process variant + """ + if parameters is None: + parameters = {} + + activity_key = exec_utils.get_param_value(Parameters.ACTIVITY_KEY, parameters, xes_constants.DEFAULT_NAME_KEY) + timestamp_key = exec_utils.get_param_value(Parameters.TIMESTAMP_KEY, parameters, + xes_constants.DEFAULT_TIMESTAMP_KEY) + case_id_key = exec_utils.get_param_value(Parameters.CASE_ID_KEY, parameters, constants.CASE_CONCEPT_NAME) + performance_aggregation = exec_utils.get_param_value(Parameters.PERFORMANCE_AGGREGATION, parameters, "mean") + + response_header = exec_utils.get_param_value(Parameters.RESPONSE_HEADER, parameters, True) + max_len = exec_utils.get_param_value(Parameters.MAX_LEN, parameters, constants.OPENAI_MAX_LEN) + + log_obj = log_converter.apply(log_obj, variant=log_converter.Variants.TO_DATA_FRAME, parameters=parameters) + + import pm4py.stats + var_paths0 = pm4py.stats.get_variants_paths_duration(log_obj, activity_key=activity_key, + timestamp_key=timestamp_key, case_id_key=case_id_key, + times_agg=performance_aggregation).to_dict("records") + var_paths = [] + for el in var_paths0: + if el["@@index_in_trace"] == 0: + var_paths.append([]) + var_paths[-1].append(el) + + ret = "\n\n" + + if response_header: + ret += "Below your find a description of the top process variants of the event logs, along with their frequency. The paths of every reported variant are decorated with an aggregation (" + performance_aggregation + ") of the performance of the path in the given variant.\n\n" + + for var in var_paths: + ths = var[0][activity_key] + for i in range(1, len(var)): + ths += " -(%.2f s)-> %s" % (var[i]["@@flow_time"], var[i][activity_key]) + + ths += " [frequency=%d]\n" % (var[0]["@@variant_count"]) + + if len(ret) + len(ths) < max_len: + ret = ret + ths + else: + break + + ret = ret + "\n\n" + + return ret diff --git a/examples/llm/openai_stt_tss.py b/examples/llm/openai_stt_tss.py new file mode 100644 index 000000000..e69e32023 --- /dev/null +++ b/examples/llm/openai_stt_tss.py @@ -0,0 +1,209 @@ +from enum import Enum +from typing import Optional, Dict, Any +from pm4py.util import exec_utils, constants +from tempfile import NamedTemporaryFile +import os +import sys +import subprocess +import importlib.util + + +class Parameters(Enum): + API_KEY = "api_key" + MODEL = "openai_model" + RECORDING_DURATION = "recording_duration" + VOICE = "voice" + PLAY_SOUND = "play_sound" + MAX_LEN = "max_len" + + +def check_ffmpeg_installed(): + try: + # Try to execute "ffmpeg -version" command and capture its output + result = subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, check=True) + # If the command was executed successfully, ffmpeg is installed + return True + except subprocess.CalledProcessError: + # If the command execution leads to an error, ffmpeg is not installed + return False + + +def speech_to_text(sound_file_path: Optional[str] = None, parameters: Optional[Dict[Any, Any]] = None) -> str: + """ + Uses an OpenAI speech-to-text model + + Parameters + ------------------ + sound_file_path + If provided, path to a .mp3 file containing the voice to be transcribed as text. If not, a recording of the specified duration is started, and provided to the model. + parameters + Parameters of the method, including: + - Parameters.API_KEY => the API key to be used + - Parameters.MODEL => the speech-to-text model to be used (default: whisper-1) + - Parameters.RECORDING_DURATION => the duration of the voice recording + + Returns + ------------------- + text + Transcription as text of the sound + """ + if parameters is None: + parameters = {} + + api_key = exec_utils.get_param_value(Parameters.API_KEY, parameters, constants.OPENAI_API_KEY) + model = exec_utils.get_param_value(Parameters.MODEL, parameters, constants.OPENAI_DEFAULT_STT_MODEL) + recording_duration = exec_utils.get_param_value(Parameters.RECORDING_DURATION, parameters, 10) + + if sound_file_path is None: + import pyaudio + from pydub import AudioSegment + import wave + + # Audio recording parameters + FORMAT = pyaudio.paInt16 + CHANNELS = 1 + RATE = 44100 + CHUNK = 1024 + RECORD_SECONDS = recording_duration + + F = NamedTemporaryFile(suffix=".wav") + WAVE_OUTPUT_FILENAME = F.name + F.close() + + F = NamedTemporaryFile(suffix=".mp3") + sound_file_path = F.name + F.close() + + audio = pyaudio.PyAudio() + + # Start recording + stream = audio.open(format=FORMAT, channels=CHANNELS, + rate=RATE, input=True, + frames_per_buffer=CHUNK) + print("Recording...") + + frames = [] + + for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): + data = stream.read(CHUNK) + frames.append(data) + + print("Finished recording.") + + # Stop recording + stream.stop_stream() + stream.close() + audio.terminate() + + # Save the recorded data as a WAV file + wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb') + wf.setnchannels(CHANNELS) + wf.setsampwidth(audio.get_sample_size(FORMAT)) + wf.setframerate(RATE) + wf.writeframes(b''.join(frames)) + wf.close() + + sound = AudioSegment.from_wav(WAVE_OUTPUT_FILENAME) + sound.export(sound_file_path, format="mp3") + + if sound_file_path is not None: + from openai import OpenAI + + client = OpenAI(api_key=api_key) + + transcript = client.audio.transcriptions.create( + model=model, + file=open(sound_file_path, "rb") + ) + + return transcript.text + + +def text_to_speech(stri: str, parameters: Optional[Dict[Any, Any]] = None) -> str: + """ + Uses an OpenAI text-to-speech model + + Parameters + --------------- + stri + String that needs to be translated to voice + parameters + Parameters of the algorithm, including: + - Parameters.API_KEY => the API key of OpenAI to be used + - Parameters.MODEL => the TTS model of OpenAI to be used (default: tts-1) + - Parameters.VOICE => the voice of the TTS model to be used (default: alloy) + - Parameters.PLAY_SOUND => boolean that determines if the voice should be played + + Returns + --------------- + stru + Path to the .mp3 file obtained after the transcription + """ + if parameters is None: + parameters = {} + + api_key = exec_utils.get_param_value(Parameters.API_KEY, parameters, constants.OPENAI_API_KEY) + model = exec_utils.get_param_value(Parameters.MODEL, parameters, constants.OPENAI_DEFAULT_TTS_MODEL) + voice = exec_utils.get_param_value(Parameters.VOICE, parameters, constants.OPENAI_DEFAULT_TTS_VOICE) + max_len = exec_utils.get_param_value(Parameters.MAX_LEN, parameters, 4096) + play_sound = exec_utils.get_param_value(Parameters.PLAY_SOUND, parameters, True) + + F = NamedTemporaryFile(suffix=".mp3") + speech_file_path = F.name + F.close() + + from openai import OpenAI + + client = OpenAI(api_key=api_key) + + if len(stri) > max_len: + # TTS limit + stri = stri[:max_len] + + response = client.audio.speech.create( + model=model, + voice=voice, + input=stri + ) + + response.stream_to_file(speech_file_path) + + if play_sound: + if importlib.util.find_spec("pygame"): + # if the user installed pygame, use that to seamlessy play the .mp3 file + import pygame + + pygame.mixer.init() + pygame.mixer.music.load(speech_file_path) + pygame.mixer.music.play() + + while pygame.mixer.music.get_busy(): + pygame.time.Clock().tick(10) + else: + # calls the system .mp3 opener + if sys.platform.startswith('darwin'): + subprocess.call(('open', speech_file_path)) + elif os.name == 'nt': # For Windows + os.startfile(speech_file_path) + elif os.name == 'posix': # For Linux, Mac, etc. + subprocess.call(('xdg-open', speech_file_path)) + + return speech_file_path + + +if __name__ == "__main__": + if not check_ffmpeg_installed(): + raise Exception("install ffmpeg and add it to the environment variables!") + + if not importlib.util.find_spec("pydub") or not importlib.util.find_spec("pyaudio"): + raise Exception("install pydub and pyaudio using pip!") + + parameters = {} + + parameters["api_key"] = "sk-" # OpenAI key + parameters["recording_duration"] = 5 # 10 seconds recording duration + + transcription = speech_to_text(None, parameters=parameters) + print(transcription) + + text_to_speech(transcription, parameters=parameters)