cpee-llm 1.0.6 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +668 -159
  3. data/README.md +15 -0
  4. data/cpee-llm.gemspec +3 -3
  5. data/lib/cpee/llm/dataflow.rb +3 -3
  6. data/lib/cpee/llm/functions.rb +80 -77
  7. data/lib/cpee/llm/implementation.rb +43 -17
  8. data/lib/cpee/llm/implementation.xml +41 -7
  9. data/lib/cpee/llm/prompts/system/adapt_mermaid.txt +12 -0
  10. data/lib/cpee/llm/prompts/system/adapt_xml_documentation.txt +50 -0
  11. data/lib/cpee/llm/prompts/system/adapt_xml_endpoints.txt +80 -0
  12. data/lib/cpee/llm/prompts/{dataflow.txt → system/dataflow.txt} +13 -25
  13. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/arguments.txt +8 -0
  14. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/color_palette.txt +10 -0
  15. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/description.txt +3 -0
  16. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/documentation.txt +35 -0
  17. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/exclusive_gateway.txt +7 -0
  18. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/finalize.txt +2 -0
  19. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/inclusive_gateway.txt +2 -0
  20. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/loop.txt +7 -0
  21. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/method.txt +6 -0
  22. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/parallel_gateway.txt +6 -0
  23. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/pause.txt +4 -0
  24. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/pause_insertion.txt +3 -0
  25. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/script_task.txt +5 -0
  26. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/sequence.txt +2 -0
  27. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/service_task.txt +20 -0
  28. data/lib/cpee/llm/prompts/system/fragments/cpee_xml/variables.txt +3 -0
  29. data/lib/cpee/llm/prompts/system/fragments/cpee_xml.txt +15 -0
  30. data/lib/cpee/llm/prompts/system/fragments/data_references.txt +14 -0
  31. data/lib/cpee/llm/prompts/system/fragments/endpoint_naming.txt +1 -0
  32. data/lib/cpee/llm/prompts/system/fragments/mermaid/structure_rules.txt +29 -0
  33. data/lib/cpee/llm/prompts/system/fragments/mermaid/syntax.txt +22 -0
  34. data/lib/cpee/llm/prompts/system/fragments/numeric_conversion.txt +5 -0
  35. data/lib/cpee/llm/prompts/system/fragments/service_registry.txt +6 -0
  36. data/lib/cpee/llm/prompts/system/fragments/unmatched_tasks.txt +4 -0
  37. data/lib/cpee/llm/prompts/system/generate_mermaid.txt +40 -0
  38. data/lib/cpee/llm/prompts/system/generate_mermaid_endpoints.txt +82 -0
  39. data/lib/cpee/llm/prompts/system/intent.txt +45 -0
  40. data/lib/cpee/llm/prompts/{validate_xml.txt → system/validate_xml.txt} +15 -0
  41. data/lib/cpee/llm/prompts/user/adapt.txt +8 -0
  42. data/lib/cpee/llm/prompts/user/adapt_xml_endpoints.txt +11 -0
  43. data/lib/cpee/llm/prompts/user/dataflow.txt +9 -0
  44. data/lib/cpee/llm/prompts/user/describe_text.txt +4 -0
  45. data/lib/cpee/llm/prompts/user/generate_mermaid.txt +5 -0
  46. data/lib/cpee/llm/prompts/user/generate_mermaid_endpoints.txt +9 -0
  47. data/lib/cpee/llm/prompts/user/intent.txt +17 -0
  48. data/lib/cpee/llm/prompts/user/validate_xml.txt +5 -0
  49. data/lib/cpee/llm/rubyllm_requests.rb +71 -119
  50. data/server/connect_gemini +1 -1
  51. data/server/connect_gpt +1 -1
  52. data/server/connect_morpheus +1 -1
  53. data/server/{cpee-llm → llm} +5 -4
  54. data/server/plugins.json +51 -0
  55. data/tools/cpee-llm +3 -3
  56. data/tools/cpee-llm-tool +4 -4
  57. metadata +46 -17
  58. data/lib/cpee/llm/prompts/adapt_docxml_description.txt +0 -131
  59. data/lib/cpee/llm/prompts/adapt_xml_endpoints.txt +0 -157
  60. data/lib/cpee/llm/prompts/apply.txt +0 -32
  61. data/lib/cpee/llm/prompts/derive.txt +0 -28
  62. data/lib/cpee/llm/prompts/gemini-request.json +0 -18
  63. data/lib/cpee/llm/prompts/generate1.txt +0 -90
  64. data/lib/cpee/llm/prompts/generate_enpoints.txt +0 -132
  65. data/lib/cpee/llm/prompts/generate_enpoints1.txt +0 -155
  66. data/lib/cpee/llm/prompts/identify.txt +0 -25
  67. data/lib/cpee/llm/prompts/validate_mermaid.xml +0 -74
  68. /data/lib/cpee/llm/prompts/{describe.txt → system/describe_text.txt} +0 -0
  69. /data/server/{cpee-llm.conf → llm.conf} +0 -0
@@ -1,155 +0,0 @@
1
- You are an expert in BPMN modeling, Mermaid.js syntax, and endpoint-based process orchestration.
2
- You receive:
3
- (a) A textual business process description
4
- (b) A list of available API endpoints (service registry)
5
-
6
- 2. Service Registry maps each task label to one service specification. Each service specification includes:
7
- - service url
8
- - service description
9
- - service functionality
10
- - input (RelaxNG schema)
11
- - optional output
12
-
13
- Core Objective
14
- Generate the BPMN process that most faithfully represents the user's business process while maximizing reuse of the provided endpoint-backed tasks whenever they naturally implement an activity.
15
- The process description is the source of truth.
16
- The endpoint catalog is a library of reusable task implementations and must not introduce additional business activities.
17
-
18
- Endpoint Integration Rules
19
- *The service registry is a catalog of reusable task implementations.
20
- *The user's process description determines:
21
- - which activities exist,
22
- - their order,
23
- - their control flow,
24
- - the overall business objective.
25
- *Whenever an activity can reasonably be implemented by an existing endpoint, use the endpoint task label.
26
- *If no suitable endpoint exists, create a new task that best represents the required business activity.
27
- *Endpoints are optional implementation choices, not mandatory workflow steps.
28
- *Do not introduce additional business activities solely because corresponding endpoints exist.
29
- *Do not extend or "complete" the user's workflow using common business practices.
30
- *Ignore endpoints that are irrelevant to the user's requested process.
31
- *If multiple endpoints together provide a better implementation of one requested activity, that activity may be decomposed into multiple endpoint-backed tasks.
32
- *Decomposition is allowed only when it improves the implementation of an activity already present in the user's process. It must never introduce new business goals.
33
-
34
- Task Selection Principles
35
- When generating the process:
36
- Preserve every activity explicitly described by the user.
37
- Add missing activities only if they are logically indispensable for producing a coherent BPMN process.
38
- Prefer endpoint-backed tasks whenever they appropriately realize an activity.
39
- Create new task labels whenever no suitable endpoint exists.
40
- Never introduce activities that do not contribute directly to the user's requested objective.
41
-
42
- Decision Logic
43
- Create gateways only when they are explicitly implied by the process description, or they are necessary for correct process execution.
44
- Do not introduce unnecessary branching simply because endpoint outputs could support decisions.
45
-
46
- Internal Process-Control Tasks
47
- Some process descriptions imply internal process-control logic that is not explicitly stated in the text (e.g., loop counters, variable initialization, value calculations, threshold computations, or other data transformations required for routing and execution).
48
- When necessary to create a complete, executable, and logically consistent process model, additional tasks may be introduced to generate, initialize, update, or transform process data required by gateways, loops, routing decisions, or downstream activities.
49
- Such tasks represent internal workflow logic rather than business actions. They are allowed only when required to support process execution and data flow. Any variable referenced by a gateway condition or required by a downstream task must have a clear origin in a preceding task.
50
- Ensure that all decision conditions can be interpreted from preceding tasks. Timer-based conditions (e.g. wait, timeout) may be used directly without additional data derivation steps.
51
-
52
- Mermaid BPMN Syntax Specification
53
- Each Mermaid.js node must have the following structure:
54
- id:type:shape and label
55
- id: a unique integer from 0 to n.
56
- type: BPMN element type → startevent, endevent, task, subprocess, exclusivegateway, inclusivegateway, parallelgateway.
57
- Shapes and labels:
58
- Start event → id:startevent:((startevent))
59
- End event → id:endevent:(((endevent)))
60
- Task → id:task:(Task Label)
61
- Subprocess → id:subprocess:(Subprocess Label)
62
- Exclusive gateway → id:exclusivegateway:{x}
63
- Parallel gateway → id:parallelgateway:{AND}
64
- Inclusive gateway → id:inclusivegateway:{O}
65
-
66
- Hard Structural Rules:
67
- Tasks:
68
- No empty tasks are allowed: every task node must have a descriptive label.
69
- “Default branches” between gateways are allowed — i.e., edges that go directly from one gateway to another without any task in between. These represent “nothing happens”.
70
-
71
- Gateways:
72
- Every split gateway must be matched with a corresponding merge gateway of the same type.
73
- No implicit merges are allowed — merges must always be explicit.
74
- No split gateway is permitted without a matching merge.
75
-
76
- Loop Abstraction:
77
- If a process contains repetitive behavior, it MUST NOT be unrolled into repeated tasks.
78
- Instead, it MUST be modeled as a loop using an exclusive gateway for loop control.
79
- The gateway branches either back to the loop body or to the exit path.
80
- For time-based loops, timer or wait tasks may directly provide the loop termination condition. Explicit initialization and update tasks are required only when the process description implies them.
81
-
82
- Parallel Logic:
83
- Create a parallel gateway when two or more activities must occur concurrently or when one activity controls the duration of another. One branch may establish the termination condition while the other performs the repeated work. Merge parallel branches with a matching parallel gateway.
84
-
85
- Flow correctness:
86
- Each path/branch must start from the start event and lead to the end event.
87
- Each incoming node must have its own separate edge to the target node.
88
-
89
- Reused nodes:
90
- If a node occurs more than once, reference it by repeating the full node declaration like this - id:type:shape and label (e.g., 2:task:(do something)).
91
- It is strictly prohibited to use only the ID (e.g., 2) without type and to use other short versions like id:type (e.g.,2:task).
92
-
93
- Edges:
94
- All nodes must be connected with -->.
95
- Edge labels (for conditions/annotations) must be written as |text| between nodes.
96
- Edge label is always located between 2 nodes: id:exclusivegateway:{x} --> |condition or annotation|id:task:(task label)
97
-
98
- Simplification Rule:
99
- If you cannot generate a model that fully meets all requirements due to the complexity of the description, you must simplify the model until it fully satisfies every requirement.
100
-
101
- Generation Procedure
102
- 1. Extract activities from the process description.
103
- 2. Match activities against endpoint capabilities.
104
- 3. Maximize reuse of endpoint-backed tasks by decomposing activities only when appropriate.
105
- 4. Add gateways only when required by the business logic.
106
- 5. Ensure all paths begin at the start event and terminate at the end event.
107
-
108
- Mandatory Validation Before Output
109
- The model is valid only if all of the following are true:
110
- 1) Valid Mermaid.js syntax
111
- 2) Every endpoint-backed task corresponds to one provided endpoint.
112
- 3) Any non-endpoint task exists only because no suitable endpoint is available.
113
- 3) No invented task labels exist for endpoint-backed tasks
114
- 5) No endpoint URLs appear in the diagram
115
- 6) Every split gateway has a matching merge gateway of the same type
116
- 7) No implicit merges exist
117
- 8) Every branch reaches an end path
118
- 9) The process can be interpreted as an executable orchestration over the supplied endpoint catalog
119
-
120
- If any validation fails, simplify or restructure the model until all conditions are satisfied.
121
- Correctness takes precedence over completeness.
122
- Return only Mermaid.js code. Do not provide explanations, comments, markdown, or additional text.
123
-
124
- Example:
125
- Process Description:
126
- When a request arrives, validate it. If it is valid, store it and wait 2 seconds.
127
-
128
- Available Endpoints
129
- {
130
- "https-post://system/validate" =>
131
- ["Validate request",
132
- "Checks whether a request is valid.",
133
- "request",
134
- "validity result (valid/invalid)"],
135
- "https-post://system/store" =>
136
- ["Store request; Save data",
137
- "Stores a validated request.",
138
- "validated request",
139
- "record id"],
140
- "https-post://system/timeout" =>
141
- ["Wait; Timeout",
142
- "Wait for a given duration in seconds.",
143
- "duration (float)",
144
- "completion event"]
145
- }
146
-
147
- Generated BPMN Model
148
- graph LR
149
- 0:startevent:((startevent)) --> 1:task:(Validate request)
150
- 1:task:(Validate request) --> 2:exclusivegateway:{x}
151
- 2:exclusivegateway:{x} --> |valid| 3:task:(Store request)
152
- 2:exclusivegateway:{x} --> |invalid| 4:exclusivegateway:{x}
153
- 3:task:(Store request) --> 5:task:(Wait)
154
- 5:task:(Wait) --> 4:exclusivegateway:{x}
155
- 4:exclusivegateway:{x} --> 6:endevent:(((endevent)))
@@ -1,25 +0,0 @@
1
- Consider following predefined change patterns for business process model redesign:
2
- {
3
- "cp1":"Insert Process Fragment. Adds a new process fragments between two directly succeeding activities",
4
- "cp2":"Delete Process Fragment. Removes an existing process fragment and consequently flatten the hierarchy if necessary",
5
- "cp3":"Move Process Fragment. Shifts an existing process fragment from its current position to a new one",
6
- "cp4":"Replace Process Fragment. Replaces Process Fragment & replace an existing process fragment with by a new one",
7
- "cp5":"Swap Process Fragments. Swaps an existing process fragment with another existing process fragment",
8
- "cp8.1":"Embed Process Fragment in Pre-Conditional Loop. An existing process fragment is embedded in a loop to allow for a repeated execution between 0 and N times",
9
- "cp8.2":"Embed Process Fragment in Post-Conditional Loop. An existing process fragment is embedded in a loop to allow for a repeated execution between 1 and N times",
10
- "cp9":"Parallelize Process Fragments. Parallelization of existing process fragments which were confined to be executed in sequence",
11
- "cp10":"Embed Process Fragment in Conditional Branch. An existing process fragment is embedded in a conditional branch",
12
- "cp14":"Copy Process Fragment. Copies an existing process fragment and paste it to a new position",
13
- "cp6":"Extract Sub Process. Extracts an existing process fragment to encapsulate it in a separate sub process",
14
- "cp7":"Inline Sub Process. Inlines a sub process into the parent process, and consequently flatten the hierarchy of the overall process",
15
- "cp13":"Update Condition. Updates transition conditions in a process",
16
- "cp19":"Replace Gateways. Replaces existing gateways (both splitting and merging) in specified fragment simultaneously with the gateways of the other type",
17
- "cp15":"Split Process Fragment. Splits an existing process fragment into a sequence of multiple separate new process fragments",
18
- "cp16":"Merge Process Fragment. Merges multiple existing separate process fragments into one new process fragment",
19
- "cp17":"Delete Entire Branch. Removes single entire branch inside selected gateways and consequently flatten the hierarchy if necessary",
20
- "cp18":"Leave Single Branch. Replace existing gateways (both splitting and merging) in specified fragment simultaneously with the gateways of the other type"
21
- }
22
-
23
- Classify the user input into one of the predefined change patterns, if a matching pattern exists.
24
- If a match is found, return only the pattern ID. Only one pattern can be matched.
25
- If no match is found, return NA. No other information is allowed to be returned!!!
@@ -1,74 +0,0 @@
1
- Given the relevant the Mermaid.js BPMN model, and the provided Mermaid.js BPMN syntax and structural rules, perform the validation.
2
- mermaid model: .
3
-
4
- Mermaid.js BPMN Syntax:
5
- - The graph must use the LR (Left to Right) direction.
6
- - Each Mermaid.js node must have the following structure:
7
- id:type:shape and label
8
- - id: a unique integer from 0 to n.
9
- - type: BPMN element type → startevent, endevent, task, subprocess, exclusivegateway, inclusivegateway, parallelgateway.
10
- - Shapes and labels:
11
- - Start event → id:startevent:((startevent))
12
- - End event → id:endevent:(((endevent)))
13
- - Task → id:task:(Task Label)
14
- - Subprocess → id:subprocess:(Subprocess Label)
15
- - Exclusive gateway → id:exclusivegateway:{x}
16
- - Parallel gateway → id:parallelgateway:{AND}
17
- - Inclusive gateway → id:inclusivegateway:{O}
18
-
19
- Hard Structural Rules:
20
- - Tasks:
21
- - No empty tasks are allowed: every task node must have a descriptive label.
22
- - “Default branches” between gateways are allowed — edges that go directly from one gateway to another without any task in between.
23
- - Gateways:
24
- - Every split gateway must be matched with a corresponding merge gateway of the same type.
25
- - No implicit merges are allowed — merges must always be explicit.
26
- - No split gateway is permitted without a matching merge.
27
- - Flow correctness:
28
- - Each path/branch must start from the start event and lead to the end event.
29
- - Each incoming node must have its own separate edge to the target node.
30
- - Reused nodes:
31
- - If a node occurs more than once, reference it by repeating the full node declaration like this - id:type:shape and label (e.g., 2:task:(do something)).
32
- - It is strictly prohibited to use only the ID (e.g., 2) without type and to use other short versions like id:type (e.g.,2:task).
33
- - Edges:
34
- - All nodes must be connected with -->.
35
- - Edge labels (for conditions/annotations) must be written as |text| between nodes.
36
- - Simplification Rule:
37
- - If you cannot generate a model that fully meets all requirements due to the complexity of the description, you must simplify the model until it fully satisfies every requirement.
38
-
39
- ### Validation Procedure Summary:
40
- When validating a Mermaid BPMN graph against the above rules, apply these steps systematically:
41
-
42
- 1. **Basic Syntax Validation**
43
- - Confirm the graph uses LR direction.
44
- - Verify all nodes follow the `id:type:shape and label` format with unique integer IDs.
45
- - Check every task and subprocess node has a non-empty descriptive label.
46
- - Ensure node types are valid BPMN types.
47
-
48
- 2. **Connectivity Validation**
49
- - Confirm all edges use `-->` syntax and connect valid existing nodes.
50
- - Ensure exactly one start event and at least one end event exist.
51
- - Verify the graph is connected: all nodes are reachable from start and lead to an end event.
52
-
53
- 3. **Gateway Structural Validation**
54
- - Identify all gateways as splits (≥2 outgoing edges) or merges (≥2 incoming edges).
55
- - Confirm every split gateway has a corresponding matching merge gateway of the same type.
56
- - Ensure no implicit merges (e.g., branches merging into a gateway of a different type without an explicit merge).
57
- - Verify all gateways are connected (no isolated gateways).
58
-
59
- 4. **Task and Subprocess Rules**
60
- - Verify no empty task or subprocess nodes.
61
- - Confirm tasks are not orphaned: they have both incoming and outgoing edges unless start/end tasks.
62
-
63
- 5. **Flow Semantics**
64
- - Exclusive gateways must have at least two outgoing branches.
65
- - Parallel gateways’ splits must be followed by matching merges before continuing.
66
- - All paths must start at the start event and lead to an end event.
67
-
68
- 6. **Reused Nodes Validation**
69
- - Each reused node must be fully re-declared (with id:type:shape and label), never referenced by ID only or shorthand.
70
-
71
- 7. **Simplification Rule**
72
- - If any rule above fails, simplify the model by removing redundant gateways or tasks, adding missing merges, or merging sequential gateways until the model fully satisfies all rules.
73
-
74
- Return only Mermaid.js code as plain text, without markdown formatting or explanation.
File without changes