cpee-llm 1.0.1 → 1.0.4
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.
- checksums.yaml +4 -4
- data/README.md +179 -1
- data/cpee-llm.gemspec +3 -2
- data/lib/cpee/llm/dataflow.rb +0 -2
- data/lib/cpee/llm/functions.rb +18 -29
- data/lib/cpee/llm/implementation.rb +0 -3
- data/lib/cpee/llm/rubyllm_requests.rb +0 -2
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 646927187c9c5794a457b8f0d41fbc9d791c5727a9c70ab58201959aa6617097
|
|
4
|
+
data.tar.gz: c39a4b3375b52eb5d546bc909a56d0396a5b35ac4a568e368d827eed55b76818
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbda644521022ad10e07229ff3d22b73dad79ab9fae820fcf148db6791d68a775261e40ced4f15691fe779e5d9d198fd6a7e812ab48cd21c9b65a4fd038be22f
|
|
7
|
+
data.tar.gz: 80cbabf613f66a03da91eceeda7541730c833acf573c63315f827309fe97614774334e5681a102b53dc5c61ae96020b0cae2a8b45ee70bf808d7941880dc4d15
|
data/README.md
CHANGED
|
@@ -1,7 +1,185 @@
|
|
|
1
1
|
# CPEE-LLM
|
|
2
2
|
|
|
3
|
-
CPEE Conversational Agents
|
|
3
|
+
This gem realizes the 3 CPEE Conversational Agents
|
|
4
4
|
|
|
5
5
|
* CM-A for creating models
|
|
6
6
|
* EP-A for selecting endpoints
|
|
7
7
|
* DF-A for creating and validating dataflow
|
|
8
|
+
|
|
9
|
+
# Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
gem install --user cpee-llm
|
|
13
|
+
mkdir ~/run
|
|
14
|
+
cd ~/run
|
|
15
|
+
cpee-llm new cllm # scaffold; you maybe need to add installed bins to PATH
|
|
16
|
+
cd cllm
|
|
17
|
+
vim cpee-llm.conf # only add the connect adapters you need
|
|
18
|
+
vim connect_gemini # add your key
|
|
19
|
+
vim connect_gpt # add your key
|
|
20
|
+
vim connect_morpheus # add your key, and change url of you morpheus hosting
|
|
21
|
+
# connect adapters can be added or deleted as you wish, see rubyllm for
|
|
22
|
+
# possible config options. The myllm variable always contains the requested
|
|
23
|
+
# model.
|
|
24
|
+
./cpee-llm start
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
These commands install and scaffold a sample server. In the same directory you
|
|
28
|
+
see a set of sample connectors.
|
|
29
|
+
|
|
30
|
+
# Supported LLMs
|
|
31
|
+
|
|
32
|
+
We support all LLMs that https://rubyllm.org supports. Check it out.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
# 1. Text → Process Model
|
|
37
|
+
|
|
38
|
+
```http
|
|
39
|
+
POST https://cpee.org/llm/
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Converts a textual process description into a process model or adapts an existing model.
|
|
43
|
+
|
|
44
|
+
## Parameters
|
|
45
|
+
|
|
46
|
+
| Parameter | Type | Description |
|
|
47
|
+
|------------|------|-------------|
|
|
48
|
+
| rpst_xml | text/xml | Existing CPEE XML model |
|
|
49
|
+
| user_input | text/plain | Natural language process description |
|
|
50
|
+
| llm | text/plain | LLM identifier |
|
|
51
|
+
| prompt_type | text/plain | `generate_noendpoints` or `adapt_noendpoints` |
|
|
52
|
+
| temperature | text/plain (optional) | Defaults to 0 |
|
|
53
|
+
|
|
54
|
+
**Important:** Parameter order matters.
|
|
55
|
+
|
|
56
|
+
rpst\_ xml contains the content of the `<description>` tag from the CPEE testset
|
|
57
|
+
|
|
58
|
+
### Empty RPST Example
|
|
59
|
+
|
|
60
|
+
```xml
|
|
61
|
+
<description xmlns="http://cpee.org/ns/description/1.0"/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Response
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"user_input": "...",
|
|
69
|
+
"used_llm": "...",
|
|
70
|
+
"input_cpee": "...",
|
|
71
|
+
"input_intermediate": "...",
|
|
72
|
+
"output_intermediate": "...",
|
|
73
|
+
"output_cpee": "...",
|
|
74
|
+
"status": "..."
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Key Outputs
|
|
79
|
+
|
|
80
|
+
- `output_intermediate` → generated process model in Mermaid .js format
|
|
81
|
+
- `output_cpee` → CPEE XML process model
|
|
82
|
+
|
|
83
|
+
## cURL Example
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
curl -X POST https://cpee.org/llm/ \
|
|
87
|
+
-H 'Content-Type:multipart/form-data' \
|
|
88
|
+
-F "rpst_xml=@cpee_empty_example;type=text/xml" \
|
|
89
|
+
-F "user_input=Create task A after dismissal review.;type=text/plain" \
|
|
90
|
+
-F "llm=gemini-2.5-flash-lite;type=text/plain" \
|
|
91
|
+
-F "prompt_type=generate_noendpoints;type=text/plain"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
# 2. Process Model → Text
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
```http
|
|
100
|
+
POST https://cpee.org/llm/text/llm/
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Generates a textual process description from a process model.
|
|
104
|
+
|
|
105
|
+
## Parameters
|
|
106
|
+
|
|
107
|
+
| Parameter | Type |
|
|
108
|
+
|-----------|------|
|
|
109
|
+
| rpst_xml | text/xml |
|
|
110
|
+
| llm | string |
|
|
111
|
+
|
|
112
|
+
## Response
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"input_cpee": "...",
|
|
117
|
+
"input_intermediate": "...",
|
|
118
|
+
"output_text": "...",
|
|
119
|
+
"status": "..."
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Key Output
|
|
124
|
+
|
|
125
|
+
- `output_text` → Generated process description
|
|
126
|
+
|
|
127
|
+
## cURL Example
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
curl -X POST https://cpee.org/llm/text/llm/ \
|
|
131
|
+
-H 'Content-Type:multipart/form-data' \
|
|
132
|
+
-F "rpst_xml=@cpee_example;type=text/xml" \
|
|
133
|
+
-F "llm=gemini-2.5-flash-lite"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
# 3. Generic Functionality
|
|
139
|
+
|
|
140
|
+
```http
|
|
141
|
+
POST https://cpee.org/llm/generic/
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Performs arbitrary LLM tasks using a system prompt and user input.
|
|
145
|
+
|
|
146
|
+
## Parameters
|
|
147
|
+
|
|
148
|
+
| Parameter | Type |
|
|
149
|
+
|-----------|------|
|
|
150
|
+
| llm | text/plain |
|
|
151
|
+
| user_input | text/plain |
|
|
152
|
+
| system_prompt | text/plain |
|
|
153
|
+
| format | text/plain (`true`/`false`) |
|
|
154
|
+
| temperature | text/plain (optional) |
|
|
155
|
+
|
|
156
|
+
## Response
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"user_input": "...",
|
|
161
|
+
"used_llm": "...",
|
|
162
|
+
"system_prompt": "...",
|
|
163
|
+
"llm_response": "...",
|
|
164
|
+
"status": "..."
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Notes
|
|
169
|
+
|
|
170
|
+
- `format=true` requests JSON output (guarantees valid JSON but not any specific structure).
|
|
171
|
+
|
|
172
|
+
List of supporteb providers: https://rubyllm.com/chat/#getting-structured-output
|
|
173
|
+
|
|
174
|
+
## cURL Example
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
curl -X POST https://cpee.org/llm/generic/ \
|
|
178
|
+
-H 'Content-Type:multipart/form-data' \
|
|
179
|
+
-F "llm=mistralai/Ministral-3-14B-Reasoning-2512;type=text/plain" \
|
|
180
|
+
-F "user_input=The MPON sends the dismissal to the MPOO.;type=text/plain" \
|
|
181
|
+
-F "system_prompt=Return the list of tasks.;type=text/plain" \
|
|
182
|
+
-F "format=false;type=text/plain"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
data/cpee-llm.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cpee-llm"
|
|
3
|
-
s.version = "1.0.
|
|
3
|
+
s.version = "1.0.4"
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
5
|
s.license = "LGPL-3.0-or-later"
|
|
6
6
|
s.summary = "CPEE Conversational Agents"
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.bindir = 'tools'
|
|
14
14
|
s.executables = ['cpee-llm']
|
|
15
15
|
|
|
16
|
-
s.required_ruby_version = '>=3.
|
|
16
|
+
s.required_ruby_version = '>=3.2'
|
|
17
17
|
|
|
18
18
|
s.authors = ['Nataliia Klievtsova', 'Matthias Ehrendorfer', 'Juergen eTM Mangler']
|
|
19
19
|
|
|
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
|
|
|
26
26
|
s.add_runtime_dependency 'typhoeus', '~> 1.4'
|
|
27
27
|
s.add_runtime_dependency 'ruby_llm', '~> 1.15'
|
|
28
28
|
s.add_runtime_dependency 'rag_embeddings', '~> 0'
|
|
29
|
+
s.add_runtime_dependency 'cpee-transformation', '~> 1.0'
|
|
29
30
|
end
|
data/lib/cpee/llm/dataflow.rb
CHANGED
data/lib/cpee/llm/functions.rb
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
require_relative 'rubyllm_requests'
|
|
18
18
|
require 'json'
|
|
19
|
+
require 'cpee/transformation/transformer'
|
|
20
|
+
require 'cpee/transformation/cpee'
|
|
21
|
+
require 'cpee/transformation/mermaid'
|
|
19
22
|
|
|
20
23
|
module CPEE
|
|
21
24
|
|
|
@@ -25,34 +28,22 @@ module CPEE
|
|
|
25
28
|
|
|
26
29
|
include RubyLLM_Requests
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end #}}}
|
|
41
|
-
|
|
42
|
-
def mermaid_to_cpee(mermaid) #{{{
|
|
43
|
-
srv = Riddl::Client.new('http://localhost:9295/cpee/mermaid')
|
|
44
|
-
status, res = srv.post [
|
|
45
|
-
Riddl::Parameter::Complex.new("description","text/plain",mermaid),
|
|
46
|
-
Riddl::Parameter::Simple.new("type","description")
|
|
47
|
-
]
|
|
48
|
-
if status >= 200 && status < 300
|
|
49
|
-
res
|
|
50
|
-
else
|
|
51
|
-
raise 'error when converting mermaid to cpee'
|
|
52
|
-
end
|
|
53
|
-
return res[0].value().read()
|
|
54
|
-
end #}}}
|
|
31
|
+
def cpee_to_mermaid(cpee) #{{{
|
|
32
|
+
model = CPEE::Transformation::Source::CPEE.new(cpee)
|
|
33
|
+
trans = CPEE::Transformation::Transformer.new(model)
|
|
34
|
+
traces = trans.build_traces
|
|
35
|
+
tree = trans.build_tree(false)
|
|
36
|
+
trans.generate_model(CPEE::Transformation::Target::Mermaid)
|
|
37
|
+
end #}}}
|
|
38
|
+
def mermaid_to_cpee(mermaid) #{{{
|
|
39
|
+
model = CPEE::Transformation::Source::Mermaid.new(mermaid)
|
|
40
|
+
|
|
41
|
+
trans = CPEE::Transformation::Transformer.new(model)
|
|
42
|
+
traces = trans.build_traces
|
|
55
43
|
|
|
44
|
+
tree = trans.build_tree(false)
|
|
45
|
+
trans.generate_model(CPEE::Transformation::Target::CPEE)
|
|
46
|
+
end #}}}
|
|
56
47
|
|
|
57
48
|
def generate_model(myllm,user_input,temperature,llms) #{{{
|
|
58
49
|
begin
|
|
@@ -178,10 +169,8 @@ module CPEE
|
|
|
178
169
|
llm_response = inside.empty? ? llm_response : inside[0][1]
|
|
179
170
|
#check if response is json:
|
|
180
171
|
begin
|
|
181
|
-
pp "here"
|
|
182
172
|
hash = JSON.parse(llm_response)
|
|
183
173
|
rescue JSON::ParserError => e
|
|
184
|
-
pp "there"
|
|
185
174
|
raise LLMError.new("Something went wrong and llm was not able to generate Json data flow: #{llm_response}", 500)
|
|
186
175
|
end
|
|
187
176
|
return llm_response
|
|
@@ -41,7 +41,6 @@ module CPEE
|
|
|
41
41
|
temperature = @p.shift.value.read if @p[0]&.name == 'temperature'
|
|
42
42
|
|
|
43
43
|
doc = XML::Smart.string(input_cpee)
|
|
44
|
-
pp temperature
|
|
45
44
|
begin
|
|
46
45
|
output_cpee = if prompt_type == 'generate_noendpoints'
|
|
47
46
|
llm_response = generate_model(myllm,user_input,temperature,llms)
|
|
@@ -64,7 +63,6 @@ module CPEE
|
|
|
64
63
|
|
|
65
64
|
return(Riddl::Parameter::Complex.new("llm_out","application/json",{:user_input => user_input, :used_llm => myllm, :input_cpee => input_cpee, :input_intermediate => doc.root().empty?() ? "" : cpee_to_mermaid(doc.to_s()), :output_intermediate => llm_response, :output_cpee => output_cpee, :status => "Success"}.to_json()))
|
|
66
65
|
rescue LLMError => e
|
|
67
|
-
pp 'here in error'
|
|
68
66
|
@status = e&.http_response || 400
|
|
69
67
|
return Riddl::Parameter::Complex.new("llm_out","application/json",{ :error => "#{prompt_type} #{e.message}"}.to_json())
|
|
70
68
|
end
|
|
@@ -166,7 +164,6 @@ module CPEE
|
|
|
166
164
|
begin
|
|
167
165
|
dataflow = generate_dataflow(myllm,mermaid_model,api_speck,llms)
|
|
168
166
|
rescue LLMError => e
|
|
169
|
-
pp e.http_response
|
|
170
167
|
@status = e.http_response || 400
|
|
171
168
|
return Riddl::Parameter::Complex.new("llm_out","application/json",{:error => e.message}.to_json())
|
|
172
169
|
end
|
|
@@ -92,8 +92,6 @@ module CPEE
|
|
|
92
92
|
def generate_mermaid_model(llm, user_input, temperature, llms={}) #{{{
|
|
93
93
|
max_tokens = 4000
|
|
94
94
|
temperature = temperature.nil? ? 0.1 : temperature.to_f
|
|
95
|
-
pp "here"
|
|
96
|
-
pp temperature
|
|
97
95
|
system_prompt = File.read(File.join(__dir__,"prompts/generate1.txt"))
|
|
98
96
|
user_prompt = "Consider following process description: #{user_input}. Generate a BPMN model in Mermaid.js format."
|
|
99
97
|
new_mermaid = generate_content(llm,system_prompt,user_prompt,max_tokens,temperature,llms)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cpee-llm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nataliia Klievtsova
|
|
@@ -95,6 +95,20 @@ dependencies:
|
|
|
95
95
|
- - "~>"
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '0'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: cpee-transformation
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - "~>"
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '1.0'
|
|
105
|
+
type: :runtime
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - "~>"
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '1.0'
|
|
98
112
|
description: see http://cpee.org
|
|
99
113
|
email: n.klievtsova@gmail.com
|
|
100
114
|
executables:
|
|
@@ -143,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
143
157
|
requirements:
|
|
144
158
|
- - ">="
|
|
145
159
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: '3.
|
|
160
|
+
version: '3.2'
|
|
147
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
162
|
requirements:
|
|
149
163
|
- - ">="
|