ad-agent_architecture 0.0.6 → 0.0.7
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/.rubocop.yml +12 -0
- data/CHANGELOG.md +7 -0
- data/lib/ad/agent_architecture/db/models.rb +2 -2
- data/lib/ad/agent_architecture/db/save_workflow_graph.rb +53 -0
- data/lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb +97 -0
- data/lib/ad/agent_architecture/version.rb +1 -1
- data/lib/ad/agent_architecture.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25616fff163424e27ea21bf76cabec403e7113c7b018e791ed42fe523e7964aa
|
4
|
+
data.tar.gz: a34ad7c9d1275dc3db2394623874408225b67ab6a1a6d39bf0f2b46fafc7608f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2acf82a7726aa7168e595cac40238e79e634a2a396c93899ab30394494bae8ba3d96e1a843e27a4a826e18c96fefbc290cd34ae4592dbdd24a83a7a12ec0734
|
7
|
+
data.tar.gz: 6f7948ae17ac536b0608e5063d6b61411ea74408d5cbdc8007772e6dab32d372b5c714f5a31ff19043958513094a5e9322661bbff41fca466f81ee86e21eacc8
|
data/.rubocop.yml
CHANGED
@@ -42,6 +42,8 @@ Metrics/BlockLength:
|
|
42
42
|
|
43
43
|
Metrics/MethodLength:
|
44
44
|
Max: 25
|
45
|
+
Exclude:
|
46
|
+
- "lib/ad/agent_architecture/dsl/*"
|
45
47
|
|
46
48
|
Layout/LineLength:
|
47
49
|
Max: 200
|
@@ -87,6 +89,12 @@ Lint/AmbiguousBlockAssociation:
|
|
87
89
|
|
88
90
|
Style/AccessorGrouping:
|
89
91
|
Enabled: false
|
92
|
+
Metrics/AbcSize:
|
93
|
+
Exclude:
|
94
|
+
- "lib/ad/agent_architecture/dsl/*"
|
95
|
+
Metrics/NoExpectationExample:
|
96
|
+
Exclude:
|
97
|
+
- "spec/ad/agent_architecture/dsl/*"
|
90
98
|
|
91
99
|
Layout/SpaceBeforeComma:
|
92
100
|
Enabled: false
|
@@ -105,3 +113,7 @@ RSpec/SpecFilePathSuffix:
|
|
105
113
|
RSpec/NamedSubject:
|
106
114
|
Exclude:
|
107
115
|
- "**/spec/**/*"
|
116
|
+
|
117
|
+
RSpec/ExampleLength:
|
118
|
+
Exclude:
|
119
|
+
- "**/spec/**/*"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.0.6](https://github.com/appydave/ad-agent_architecture/compare/v0.0.5...v0.0.6) (2024-06-28)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* update requirements documentation ([e80d072](https://github.com/appydave/ad-agent_architecture/commit/e80d0728652c7a4fdeb014324f196e0044cb13af))
|
7
|
+
|
1
8
|
## [0.0.5](https://github.com/appydave/ad-agent_architecture/compare/v0.0.4...v0.0.5) (2024-06-28)
|
2
9
|
|
3
10
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'sequel'
|
4
|
-
|
5
3
|
module Ad
|
6
4
|
module AgentArchitecture
|
7
5
|
module Database
|
8
6
|
# Workflow model represents a workflow entity in the database.
|
9
7
|
class Workflow < Sequel::Model
|
8
|
+
set_primary_key :id
|
9
|
+
|
10
10
|
one_to_many :sections, class: 'Ad::AgentArchitecture::Database::Section'
|
11
11
|
one_to_many :attributes, class: 'Ad::AgentArchitecture::Database::Attribute'
|
12
12
|
one_to_many :workflow_runs, class: 'Ad::AgentArchitecture::Database::WorkflowRun'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ad
|
4
|
+
module AgentArchitecture
|
5
|
+
module Database
|
6
|
+
class SaveWorkflowGraph
|
7
|
+
def initialize(workflow_hash)
|
8
|
+
@workflow_hash = workflow_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def save
|
12
|
+
DB.transaction do
|
13
|
+
# Save workflow
|
14
|
+
workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow_hash[:name])
|
15
|
+
|
16
|
+
# Save attributes
|
17
|
+
attribute_records = @workflow_hash[:attributes].map do |_name, attr|
|
18
|
+
Ad::AgentArchitecture::Database::Attribute.create(
|
19
|
+
name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
|
20
|
+
)
|
21
|
+
end
|
22
|
+
attribute_map = attribute_records.to_h { |ar| [ar.name.to_sym, ar] }
|
23
|
+
|
24
|
+
# Save sections and steps
|
25
|
+
@workflow_hash[:sections].each do |section|
|
26
|
+
section_record = Ad::AgentArchitecture::Database::Section.create(
|
27
|
+
name: section[:name], order: section[:order], workflow: workflow_record
|
28
|
+
)
|
29
|
+
|
30
|
+
section[:steps].each do |step|
|
31
|
+
step_record = Ad::AgentArchitecture::Database::Step.create(
|
32
|
+
name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
|
33
|
+
)
|
34
|
+
|
35
|
+
step[:input_attributes].each do |attr_name|
|
36
|
+
Ad::AgentArchitecture::Database::InputAttribute.create(
|
37
|
+
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
step[:output_attributes].each do |attr_name|
|
42
|
+
Ad::AgentArchitecture::Database::OutputAttribute.create(
|
43
|
+
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ad
|
4
|
+
module AgentArchitecture
|
5
|
+
module Dsl
|
6
|
+
# DSL for defining agent workflows
|
7
|
+
class AgentWorkflowDsl
|
8
|
+
def self.create(name:, &block)
|
9
|
+
new(name).tap do |dsl|
|
10
|
+
dsl.instance_eval(&block) if block_given?
|
11
|
+
dsl.save
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(name)
|
16
|
+
@workflow = { name: name, sections: [], attributes: {} }
|
17
|
+
@current_section_order = 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def attributes(&block)
|
21
|
+
instance_eval(&block) if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
def attribute(name, type:, is_array: false)
|
25
|
+
@workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
|
26
|
+
end
|
27
|
+
|
28
|
+
def section(name:, &block)
|
29
|
+
@current_step_order = 1
|
30
|
+
@current_section = { name: name, order: @current_section_order, steps: [] }
|
31
|
+
@current_section_order += 1
|
32
|
+
instance_eval(&block) if block_given?
|
33
|
+
@workflow[:sections] << @current_section
|
34
|
+
end
|
35
|
+
|
36
|
+
def step(name:, &block)
|
37
|
+
@current_step = { name: name, order: @current_step_order, input_attributes: [], output_attributes: [] }
|
38
|
+
@current_step_order += 1
|
39
|
+
instance_eval(&block) if block_given?
|
40
|
+
@current_section[:steps] << @current_step
|
41
|
+
end
|
42
|
+
|
43
|
+
def input(attr_name, **_opts)
|
44
|
+
@current_step[:input_attributes] << attr_name
|
45
|
+
end
|
46
|
+
|
47
|
+
def output(attr_name, **_opts)
|
48
|
+
@current_step[:output_attributes] << attr_name
|
49
|
+
end
|
50
|
+
|
51
|
+
def prompt(prompt_text, **_opts)
|
52
|
+
@current_step[:prompt] = prompt_text
|
53
|
+
end
|
54
|
+
|
55
|
+
def save
|
56
|
+
DB.transaction do
|
57
|
+
# Save workflow
|
58
|
+
workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow[:name])
|
59
|
+
|
60
|
+
# Save attributes
|
61
|
+
attribute_records = @workflow[:attributes].map do |_name, attr|
|
62
|
+
Ad::AgentArchitecture::Database::Attribute.create(
|
63
|
+
name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
|
64
|
+
)
|
65
|
+
end
|
66
|
+
attribute_map = attribute_records.to_h { |ar| [ar.name.to_sym, ar] }
|
67
|
+
|
68
|
+
# Save sections and steps
|
69
|
+
@workflow[:sections].each do |section|
|
70
|
+
section_record = Ad::AgentArchitecture::Database::Section.create(
|
71
|
+
name: section[:name], order: section[:order], workflow: workflow_record
|
72
|
+
)
|
73
|
+
|
74
|
+
section[:steps].each do |step|
|
75
|
+
step_record = Ad::AgentArchitecture::Database::Step.create(
|
76
|
+
name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
|
77
|
+
)
|
78
|
+
|
79
|
+
step[:input_attributes].each do |attr_name|
|
80
|
+
Ad::AgentArchitecture::Database::InputAttribute.create(
|
81
|
+
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
step[:output_attributes].each do |attr_name|
|
86
|
+
Ad::AgentArchitecture::Database::OutputAttribute.create(
|
87
|
+
step: step_record, attribute: attribute_map[attr_name.to_sym]
|
88
|
+
)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "ad-agent_architecture",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "ad-agent_architecture",
|
9
|
-
"version": "0.0.
|
9
|
+
"version": "0.0.7",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.3",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ad-agent_architecture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_log
|
@@ -82,6 +82,8 @@ files:
|
|
82
82
|
- lib/ad/agent_architecture.rb
|
83
83
|
- lib/ad/agent_architecture/db/create_schema.rb
|
84
84
|
- lib/ad/agent_architecture/db/models.rb
|
85
|
+
- lib/ad/agent_architecture/db/save_workflow_graph.rb
|
86
|
+
- lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb
|
85
87
|
- lib/ad/agent_architecture/version.rb
|
86
88
|
- package-lock.json
|
87
89
|
- package.json
|