ad-agent_architecture 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f028f265371e8a636e96ebbd94eb147d157133faac830fb212e6d7863cff2e0
4
- data.tar.gz: cb6231c112e8788b82f19325ad54716b03fed23905435716aa1592967b9f8f48
3
+ metadata.gz: 5f5f327df1d3c95d9adf30cbbe9d973b33457737096d21c607fbe080caa9d839
4
+ data.tar.gz: 948a4cbd3540dc300eedb249c96b13e1963058abbd4f2c205ea23ce55d446431
5
5
  SHA512:
6
- metadata.gz: 873afb3fa43cfba38266711436db58c76b8d83202f7926c6be23be7799c059b8de94715a8f68df3ef71c20a519215e1173bcd8eb3ddfb8c0cffe70d958270fb4
7
- data.tar.gz: 794d569604a03b43a85aeadcfd42f566c7bba8e746445d69d30cae7bf6362c2d1a2e48a2967d8018b3fe3ce0aa9d1b539787f7a73a7d908a12a6d2343b5429a4
6
+ metadata.gz: 6b7f671d1ad1c28534f6e35f0d141fdb05c8fe0c28192e12087d10fbacb67265e451d17a91df3194e3495d8fec98881ff31a4ec7000db10f13886bc9c0de5785
7
+ data.tar.gz: 07de02cccb8f30f128f8e81663eeba0e4e4dc190394c030675a8d574259e5c50d85bb8d4643de1c94db197b7261e2f7bb22b3ed2708eafdb6ac7c07802341258
data/.rubocop.yml CHANGED
@@ -15,6 +15,7 @@ AllCops:
15
15
  - ".builders/**/*"
16
16
  - "spec/samples/**/*"
17
17
  - "lib/ad/agent_architecture/database/*"
18
+ - "spec/usecases/**/*"
18
19
 
19
20
  Metrics/BlockLength:
20
21
  Exclude:
@@ -43,8 +44,7 @@ Metrics/BlockLength:
43
44
  Metrics/MethodLength:
44
45
  Max: 25
45
46
  Exclude:
46
- - "lib/ad/agent_architecture/dsl/*"
47
- - "lib/ad/agent_architecture/database/*"
47
+ - "lib/ad/agent_architecture/**/*"
48
48
 
49
49
  Layout/LineLength:
50
50
  Max: 200
@@ -92,9 +92,7 @@ Style/AccessorGrouping:
92
92
  Enabled: false
93
93
  Metrics/AbcSize:
94
94
  Exclude:
95
- - "lib/ad/agent_architecture/dsl/*"
96
- - "lib/ad/agent_architecture/database/*"
97
- - "lib/ad/agent_architecture/report/*"
95
+ - "lib/ad/agent_architecture/**/*"
98
96
  Metrics/NoExpectationExample:
99
97
  Exclude:
100
98
  - "spec/ad/agent_architecture/dsl/*"
@@ -119,4 +117,13 @@ RSpec/NamedSubject:
119
117
 
120
118
  RSpec/ExampleLength:
121
119
  Exclude:
122
- - "**/spec/**/*"
120
+ - "**/spec/**/*"
121
+
122
+ RSpec/MultipleExpectations:
123
+ Max: 3
124
+ Exclude:
125
+ - "spec/ad/agent_architecture/dsl/actions/save_database_spec.rb"
126
+
127
+ Metrics/CyclomaticComplexity:
128
+ Exclude:
129
+ - "lib/ad/agent_architecture/dsl/actions/save_database.rb"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.0.9](https://github.com/appydave/ad-agent_architecture/compare/v0.0.8...v0.0.9) (2024-06-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add save, save_json, save_yaml and better report support ([4350628](https://github.com/appydave/ad-agent_architecture/commit/4350628f95b06a5df3bac3432f52aa560c7699f5))
7
+ * add save, save_json, save_yaml and better report support ([9a7238a](https://github.com/appydave/ad-agent_architecture/commit/9a7238a0102e40a6e603a7a82757ff7c684ab374))
8
+
9
+ ## [0.0.8](https://github.com/appydave/ad-agent_architecture/compare/v0.0.7...v0.0.8) (2024-06-29)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * add basic reports ([82d89e1](https://github.com/appydave/ad-agent_architecture/commit/82d89e164744f9100f92ca8ec677447ee1c083cb))
15
+
1
16
  ## [0.0.7](https://github.com/appydave/ad-agent_architecture/compare/v0.0.6...v0.0.7) (2024-06-29)
2
17
 
3
18
 
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group :development, :test do
9
9
  gem 'guard-bundler'
10
10
  gem 'guard-rspec'
11
11
  gem 'guard-rubocop'
12
+ gem 'guard-shell'
12
13
  gem 'rake'
13
14
  gem 'rake-compiler', require: false
14
15
  gem 'rspec', '~> 3.0'
data/Guardfile CHANGED
@@ -27,4 +27,10 @@ group :green_pass_then_cop, halt_on_fail: true do
27
27
  watch(/{.+\.rb$/)
28
28
  watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
29
29
  end
30
+
31
+ guard :shell do
32
+ watch(%r{^spec/usecases/.+\.rbx$}) do |m|
33
+ `ruby -r ./spec/usecases/dsl_initialize.rb #{m[0]}`
34
+ end
35
+ end
30
36
  end
@@ -69,6 +69,16 @@ module Ad
69
69
  foreign_key :attribute_id, :attributes
70
70
  end
71
71
 
72
+ db.create_table :prompts do
73
+ primary_key :id
74
+ String :name, null: false
75
+ String :path, null: true
76
+ String :content, null: true
77
+ foreign_key :workflow_id, :workflows
78
+ end
79
+
80
+ # Workflow runs workflows that are executed
81
+
72
82
  db.create_table :workflow_runs do
73
83
  primary_key :id
74
84
  foreign_key :workflow_id, :workflows
@@ -10,6 +10,7 @@ module Ad
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'
13
+ one_to_many :prompts, class: 'Ad::AgentArchitecture::Database::Prompt'
13
14
  end
14
15
 
15
16
  # Section model represents a section entity in the database.
@@ -46,6 +47,10 @@ module Ad
46
47
  many_to_one :attribute, class: 'Ad::AgentArchitecture::Database::Attribute'
47
48
  end
48
49
 
50
+ class Prompt < Sequel::Model
51
+ many_to_one :workflow, class: 'Ad::AgentArchitecture::Database::Workflow'
52
+ end
53
+
49
54
  # WorkflowRun model represents a workflow run entity in the database.
50
55
  class WorkflowRun < Sequel::Model
51
56
  many_to_one :workflow, class: 'Ad::AgentArchitecture::Database::Workflow'
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ module Actions
7
+ # Save workflow graph to database
8
+ class SaveDatabase
9
+ def initialize(workflow_hash)
10
+ @workflow_hash = workflow_hash
11
+ end
12
+
13
+ def save
14
+ DB.transaction do
15
+ # Save workflow
16
+ workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow_hash[:name])
17
+
18
+ # Save attributes
19
+ attribute_records = @workflow_hash[:attributes].map do |_name, attr|
20
+ Ad::AgentArchitecture::Database::Attribute.create(
21
+ name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
22
+ )
23
+ end
24
+
25
+ attribute_map = attribute_records.to_h { |ar| [ar.name.to_sym, ar] }
26
+
27
+ # Save prompts
28
+ @workflow_hash[:prompts].each_value do |prompt|
29
+ Ad::AgentArchitecture::Database::Prompt.create(
30
+ name: prompt[:name], path: prompt[:path], content: prompt[:content], workflow: workflow_record
31
+ )
32
+ end
33
+
34
+ # Save sections and steps
35
+ @workflow_hash[:sections].each do |section|
36
+ section_record = Ad::AgentArchitecture::Database::Section.create(
37
+ name: section[:name], order: section[:order], workflow: workflow_record
38
+ )
39
+
40
+ section[:steps].each do |step|
41
+ step_record = Ad::AgentArchitecture::Database::Step.create(
42
+ name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
43
+ )
44
+
45
+ step[:input_attributes].each do |attr_name|
46
+ Ad::AgentArchitecture::Database::InputAttribute.create(
47
+ step: step_record, attribute: attribute_map[attr_name.to_sym]
48
+ )
49
+ end
50
+
51
+ step[:output_attributes].each do |attr_name|
52
+ Ad::AgentArchitecture::Database::OutputAttribute.create(
53
+ step: step_record, attribute: attribute_map[attr_name.to_sym]
54
+ )
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Ad
6
+ module AgentArchitecture
7
+ module Dsl
8
+ module Actions
9
+ # Save workflow graph to JSON file
10
+ class SaveJson
11
+ def initialize(workflow_hash)
12
+ @workflow_hash = workflow_hash
13
+ end
14
+
15
+ def save(file_name)
16
+ # Pretty JSON
17
+ File.write(file_name, JSON.pretty_generate(@workflow_hash))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module Ad
6
+ module AgentArchitecture
7
+ module Dsl
8
+ module Actions
9
+ # Save workflow graph to YAML file
10
+ class SaveYaml
11
+ def initialize(workflow_hash)
12
+ @workflow_hash = workflow_hash
13
+ end
14
+
15
+ def save(file_name)
16
+ File.write(file_name, @workflow_hash.to_yaml)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for defining the agent DSL
7
+ class AgentDsl
8
+ attr_reader :workflow
9
+
10
+ def self.create(name:, &block)
11
+ new(name).tap do |dsl|
12
+ dsl.instance_eval(&block) if block_given?
13
+ end
14
+ end
15
+
16
+ def initialize(name)
17
+ @workflow = WorkflowDsl.new(name)
18
+ end
19
+
20
+ def attributes(&block)
21
+ @workflow.attributes(&block)
22
+ end
23
+
24
+ def prompts(&block)
25
+ @workflow.prompts(&block)
26
+ end
27
+
28
+ def section(name:, &block)
29
+ @workflow.section(name: name, &block)
30
+ end
31
+
32
+ def save
33
+ Ad::AgentArchitecture::Dsl::Actions::SaveDatabase.new(@workflow.workflow).save
34
+
35
+ self
36
+ end
37
+
38
+ def save_json(file_name = nil)
39
+ full_file_name = file_name || 'workflow.json'
40
+ Ad::AgentArchitecture::Dsl::Actions::SaveJson.new(@workflow.workflow).save(full_file_name)
41
+
42
+ self
43
+ end
44
+
45
+ def save_yaml(file_name = nil)
46
+ full_file_name = file_name || 'workflow.yaml'
47
+ Ad::AgentArchitecture::Dsl::Actions::SaveYaml.new(@workflow.workflow).save(full_file_name)
48
+
49
+ self
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -8,12 +8,11 @@ module Ad
8
8
  def self.create(name:, &block)
9
9
  new(name).tap do |dsl|
10
10
  dsl.instance_eval(&block) if block_given?
11
- dsl.save
12
11
  end
13
12
  end
14
13
 
15
14
  def initialize(name)
16
- @workflow = { name: name, sections: [], attributes: {} }
15
+ @workflow = { name: name, sections: [], attributes: {}, prompts: [] }
17
16
  @current_section_order = 1
18
17
  end
19
18
 
@@ -25,6 +24,14 @@ module Ad
25
24
  @workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
26
25
  end
27
26
 
27
+ def prompts(&block)
28
+ instance_eval(&block) if block_given?
29
+ end
30
+
31
+ def define_prompt(name, path: nil, content: nil)
32
+ @workflow[:prompts] << { name: name, path: path, content: content }
33
+ end
34
+
28
35
  def section(name:, &block)
29
36
  @current_step_order = 1
30
37
  @current_section = { name: name, order: @current_section_order, steps: [] }
@@ -53,43 +60,23 @@ module Ad
53
60
  end
54
61
 
55
62
  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
63
+ Ad::AgentArchitecture::Dsl::Actions::SaveDatabase.new(@workflow).save
64
+
65
+ self
66
+ end
67
+
68
+ def save_json(file_name: nil)
69
+ full_file_name = file_name || 'workflow.json'
70
+ Ad::AgentArchitecture::Dsl::Actions::SaveJson.new(@workflow).save(full_file_name)
71
+
72
+ self
73
+ end
74
+
75
+ def save_yaml(file_name: nil)
76
+ full_file_name = file_name || 'workflow.yaml'
77
+ Ad::AgentArchitecture::Dsl::Actions::SaveYaml.new(@workflow).save(full_file_name)
78
+
79
+ self
93
80
  end
94
81
  end
95
82
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for defining the attributes of a workflow
7
+ class AttributeDsl
8
+ def initialize(attributes)
9
+ @attributes = attributes
10
+ end
11
+
12
+ def attribute(name, type:, is_array: false)
13
+ @attributes[name] = { name: name, type: type, is_array: is_array }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for defining the prompts of a workflow
7
+ class PromptDsl
8
+ def initialize(prompts)
9
+ @prompts = prompts
10
+ end
11
+
12
+ def prompt(name, path: nil, content: nil)
13
+ @prompts[name] = { name: name, path: path, content: content }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for creating a section in the workflow
7
+ class SectionDsl
8
+ def initialize(name, order, sections)
9
+ @section = { name: name, order: order, steps: [] }
10
+ @sections = sections
11
+ @current_step_order = 1
12
+ @sections << @section
13
+ end
14
+
15
+ def step(name:, &block)
16
+ StepDsl.new(name, @current_step_order, @section[:steps]).instance_eval(&block)
17
+ @current_step_order += 1
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for defining the steps of a section
7
+ class StepDsl
8
+ def initialize(name, order, steps)
9
+ @step = { name: name, order: order, input_attributes: [], output_attributes: [], prompt: '' }
10
+ @steps = steps
11
+ @steps << @step
12
+ end
13
+
14
+ def input(attr_name, **_opts)
15
+ @step[:input_attributes] << attr_name
16
+ end
17
+
18
+ def output(attr_name, **_opts)
19
+ @step[:output_attributes] << attr_name
20
+ end
21
+
22
+ def prompt(prompt_text, **_opts)
23
+ @step[:prompt] = prompt_text
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ad
4
+ module AgentArchitecture
5
+ module Dsl
6
+ # This class is responsible for defining the workflow DSL
7
+ class WorkflowDsl
8
+ attr_reader :workflow
9
+
10
+ def initialize(name)
11
+ @workflow = { name: name, sections: [], attributes: {}, prompts: {} }
12
+ @current_section_order = 1
13
+ end
14
+
15
+ def attributes(&block)
16
+ dsl = AttributeDsl.new(@workflow[:attributes])
17
+ dsl.instance_eval(&block) if block_given?
18
+ end
19
+
20
+ def prompts(&block)
21
+ dsl = PromptDsl.new(@workflow[:prompts])
22
+ dsl.instance_eval(&block) if block_given?
23
+ end
24
+
25
+ def section(name:, &block)
26
+ dsl = SectionDsl.new(name, @current_section_order, @workflow[:sections])
27
+ dsl.instance_eval(&block) if block_given?
28
+ @current_section_order += 1
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -11,7 +11,7 @@ module Ad
11
11
 
12
12
  def print
13
13
  # tp query, :workflow_name, :workflow_description, :section_name, :section_description, :section_order, :step_name, :step_order, :step_prompt, :inputs, :outputs
14
- tp query, :workflow_name, :workflow_description, :section_name, :step_name, :step_prompt, :inputs, :outputs
14
+ tp query, :workflow_name, :section_name, :step_name, :step_prompt, :inputs, :outputs
15
15
  end
16
16
 
17
17
  def query
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ad
4
4
  module AgentArchitecture
5
- VERSION = '0.0.8'
5
+ VERSION = '0.0.10'
6
6
  end
7
7
  end
@@ -13,10 +13,20 @@ Ad::AgentArchitecture::Database::CreateSchema.new(DB).execute
13
13
 
14
14
  require 'ad/agent_architecture/database/models'
15
15
  require 'ad/agent_architecture/database/sql_query'
16
- require 'ad/agent_architecture/database/save_workflow_graph'
17
- require 'ad/agent_architecture/dsl/agent_workflow_dsl'
18
- require 'ad/agent_architecture/report/workflow_detail_report'
19
- require 'ad/agent_architecture/report/workflow_list_report'
16
+ require 'ad/agent_architecture/dsl/attribute_dsl'
17
+ require 'ad/agent_architecture/dsl/prompt_dsl'
18
+ require 'ad/agent_architecture/dsl/section_dsl'
19
+ require 'ad/agent_architecture/dsl/step_dsl'
20
+ require 'ad/agent_architecture/dsl/workflow_dsl'
21
+ require 'ad/agent_architecture/dsl/agent_dsl'
22
+ require 'ad/agent_architecture/dsl/actions/save_database'
23
+ require 'ad/agent_architecture/dsl/actions/save_json'
24
+ require 'ad/agent_architecture/dsl/actions/save_yaml'
25
+ # require 'ad/agent_architecture/report/workflow_detail_report'
26
+ # require 'ad/agent_architecture/report/workflow_list_report'
27
+
28
+ # Alias'
29
+ # AgentWorkflow = Ad::AgentArchitecture::Dsl::AgentWorkflowDsl
20
30
 
21
31
  module Ad
22
32
  module AgentArchitecture
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ad-agent_architecture",
9
- "version": "0.0.8",
9
+ "version": "0.0.10",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Architecture/Schema for AI Agents",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
data/workflow.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "YouTube Title Creator",
3
+ "sections": [
4
+ {
5
+ "name": "Research",
6
+ "order": 1,
7
+ "steps": [
8
+ {
9
+ "name": "Starting Context",
10
+ "order": 1,
11
+ "input_attributes": [
12
+
13
+ ],
14
+ "output_attributes": [
15
+
16
+ ],
17
+ "prompt": "best_practice"
18
+ },
19
+ {
20
+ "name": "Basic titles",
21
+ "order": 2,
22
+ "input_attributes": [
23
+ "basic_title",
24
+ "basic_keyword",
25
+ "basic_transcript"
26
+ ],
27
+ "output_attributes": [
28
+ "potential_titles"
29
+ ],
30
+ "prompt": "Keyword: [start_keyword]\nTitle: [start_title]\n\nTranscript:\n\n[start_transcript]\n"
31
+ },
32
+ {
33
+ "name": "Working Title",
34
+ "order": 3,
35
+ "input_attributes": [
36
+ "potential_titles"
37
+ ],
38
+ "output_attributes": [
39
+ "working_title"
40
+ ]
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "attributes": {
46
+ "start_title": {
47
+ "name": "start_title",
48
+ "type": "string",
49
+ "is_array": false
50
+ },
51
+ "start_keyword": {
52
+ "name": "start_keyword",
53
+ "type": "string",
54
+ "is_array": false
55
+ },
56
+ "start_transcript": {
57
+ "name": "start_transcript",
58
+ "type": "string",
59
+ "is_array": false
60
+ },
61
+ "potential_titles": {
62
+ "name": "potential_titles",
63
+ "type": "array",
64
+ "is_array": false
65
+ },
66
+ "working_title": {
67
+ "name": "working_title",
68
+ "type": "string",
69
+ "is_array": false
70
+ }
71
+ },
72
+ "prompts": [
73
+ {
74
+ "name": "best_practice",
75
+ "path": "youtube/title_creator/best_practice.md"
76
+ }
77
+ ]
78
+ }
data/workflow.yaml ADDED
@@ -0,0 +1,56 @@
1
+ ---
2
+ :name: YouTube Title Creator
3
+ :sections:
4
+ - :name: Research
5
+ :order: 1
6
+ :steps:
7
+ - :name: Starting Context
8
+ :order: 1
9
+ :input_attributes: []
10
+ :output_attributes: []
11
+ :prompt: :best_practice
12
+ - :name: Basic titles
13
+ :order: 2
14
+ :input_attributes:
15
+ - :basic_title
16
+ - :basic_keyword
17
+ - :basic_transcript
18
+ :output_attributes:
19
+ - :potential_titles
20
+ :prompt: |
21
+ Keyword: [start_keyword]
22
+ Title: [start_title]
23
+
24
+ Transcript:
25
+
26
+ [start_transcript]
27
+ - :name: Working Title
28
+ :order: 3
29
+ :input_attributes:
30
+ - :potential_titles
31
+ :output_attributes:
32
+ - :working_title
33
+ :attributes:
34
+ :start_title:
35
+ :name: :start_title
36
+ :type: :string
37
+ :is_array: false
38
+ :start_keyword:
39
+ :name: :start_keyword
40
+ :type: :string
41
+ :is_array: false
42
+ :start_transcript:
43
+ :name: :start_transcript
44
+ :type: :string
45
+ :is_array: false
46
+ :potential_titles:
47
+ :name: :potential_titles
48
+ :type: :array
49
+ :is_array: false
50
+ :working_title:
51
+ :name: :working_title
52
+ :type: :string
53
+ :is_array: false
54
+ :prompts:
55
+ - :name: :best_practice
56
+ :path: youtube/title_creator/best_practice.md
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ad-agent_architecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -82,9 +82,17 @@ files:
82
82
  - lib/ad/agent_architecture.rb
83
83
  - lib/ad/agent_architecture/database/create_schema.rb
84
84
  - lib/ad/agent_architecture/database/models.rb
85
- - lib/ad/agent_architecture/database/save_workflow_graph.rb
86
85
  - lib/ad/agent_architecture/database/sql_query.rb
87
- - lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb
86
+ - lib/ad/agent_architecture/dsl/actions/save_database.rb
87
+ - lib/ad/agent_architecture/dsl/actions/save_json.rb
88
+ - lib/ad/agent_architecture/dsl/actions/save_yaml.rb
89
+ - lib/ad/agent_architecture/dsl/agent_dsl.rb
90
+ - lib/ad/agent_architecture/dsl/agent_workflow_dsl.rb.old
91
+ - lib/ad/agent_architecture/dsl/attribute_dsl.rb
92
+ - lib/ad/agent_architecture/dsl/prompt_dsl.rb
93
+ - lib/ad/agent_architecture/dsl/section_dsl.rb
94
+ - lib/ad/agent_architecture/dsl/step_dsl.rb
95
+ - lib/ad/agent_architecture/dsl/workflow_dsl.rb
88
96
  - lib/ad/agent_architecture/report/workflow_detail_report.rb
89
97
  - lib/ad/agent_architecture/report/workflow_list_report.rb
90
98
  - lib/ad/agent_architecture/sql/workflow_details.sql
@@ -92,6 +100,8 @@ files:
92
100
  - package-lock.json
93
101
  - package.json
94
102
  - sig/ad/agent_architecture.rbs
103
+ - workflow.json
104
+ - workflow.yaml
95
105
  homepage: http://appydave.com/gems/ad-agent_architecture
96
106
  licenses:
97
107
  - MIT
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ad
4
- module AgentArchitecture
5
- module Database
6
- # Save workflow graph to database
7
- class SaveWorkflowGraph
8
- def initialize(workflow_hash)
9
- @workflow_hash = workflow_hash
10
- end
11
-
12
- def save
13
- DB.transaction do
14
- # Save workflow
15
- workflow_record = Ad::AgentArchitecture::Database::Workflow.create(name: @workflow_hash[:name])
16
-
17
- # Save attributes
18
- attribute_records = @workflow_hash[:attributes].map do |_name, attr|
19
- Ad::AgentArchitecture::Database::Attribute.create(
20
- name: attr[:name], type: attr[:type], is_array: attr[:is_array], workflow: workflow_record
21
- )
22
- end
23
- attribute_map = attribute_records.to_h { |ar| [ar.name.to_sym, ar] }
24
-
25
- # Save sections and steps
26
- @workflow_hash[:sections].each do |section|
27
- section_record = Ad::AgentArchitecture::Database::Section.create(
28
- name: section[:name], order: section[:order], workflow: workflow_record
29
- )
30
-
31
- section[:steps].each do |step|
32
- step_record = Ad::AgentArchitecture::Database::Step.create(
33
- name: step[:name], order: step[:order], prompt: step[:prompt], section: section_record
34
- )
35
-
36
- step[:input_attributes].each do |attr_name|
37
- Ad::AgentArchitecture::Database::InputAttribute.create(
38
- step: step_record, attribute: attribute_map[attr_name.to_sym]
39
- )
40
- end
41
-
42
- step[:output_attributes].each do |attr_name|
43
- Ad::AgentArchitecture::Database::OutputAttribute.create(
44
- step: step_record, attribute: attribute_map[attr_name.to_sym]
45
- )
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end