ad-agent_architecture 0.0.9 → 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: b1afc432b8e4a84cec6f099987e20ccb1abd19b278a1f299fdd3cd822e47b6f2
4
- data.tar.gz: fd1b6e9054740f005c083712e3cd67b1872cc0cd8d66eadaa2c9541fb3f33c9c
3
+ metadata.gz: 5f5f327df1d3c95d9adf30cbbe9d973b33457737096d21c607fbe080caa9d839
4
+ data.tar.gz: 948a4cbd3540dc300eedb249c96b13e1963058abbd4f2c205ea23ce55d446431
5
5
  SHA512:
6
- metadata.gz: 7af0666287aaef19e10bc414c160066ff2ab0dde2f55f2ae758790454028bccc5bb33ee48fb1ff63ca307a98ab25a82a16a896d2dbf256090151870519e5cb78
7
- data.tar.gz: ae03bbcc49b5f4a0f467852a6f2c411c5d45484ba86eeac3251f75ce97379b2f04e8790530248ad997e5b8fee776174c5ef6ec36b128d89dfc693c52e09de874
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:
@@ -116,4 +117,13 @@ RSpec/NamedSubject:
116
117
 
117
118
  RSpec/ExampleLength:
118
119
  Exclude:
119
- - "**/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,11 @@
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
+
1
9
  ## [0.0.8](https://github.com/appydave/ad-agent_architecture/compare/v0.0.7...v0.0.8) (2024-06-29)
2
10
 
3
11
 
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'
@@ -24,6 +24,13 @@ module Ad
24
24
 
25
25
  attribute_map = attribute_records.to_h { |ar| [ar.name.to_sym, ar] }
26
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
+
27
34
  # Save sections and steps
28
35
  @workflow_hash[:sections].each do |section|
29
36
  section_record = Ad::AgentArchitecture::Database::Section.create(
@@ -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
@@ -12,7 +12,7 @@ module Ad
12
12
  end
13
13
 
14
14
  def initialize(name)
15
- @workflow = { name: name, sections: [], attributes: {} }
15
+ @workflow = { name: name, sections: [], attributes: {}, prompts: [] }
16
16
  @current_section_order = 1
17
17
  end
18
18
 
@@ -24,6 +24,14 @@ module Ad
24
24
  @workflow[:attributes][name] = { name: name, type: type, is_array: is_array }
25
25
  end
26
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
+
27
35
  def section(name:, &block)
28
36
  @current_step_order = 1
29
37
  @current_section = { name: name, order: @current_section_order, steps: [] }
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ad
4
4
  module AgentArchitecture
5
- VERSION = '0.0.9'
5
+ VERSION = '0.0.10'
6
6
  end
7
7
  end
@@ -13,12 +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/dsl/agent_workflow_dsl'
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'
17
22
  require 'ad/agent_architecture/dsl/actions/save_database'
18
23
  require 'ad/agent_architecture/dsl/actions/save_json'
19
24
  require 'ad/agent_architecture/dsl/actions/save_yaml'
20
- require 'ad/agent_architecture/report/workflow_detail_report'
21
- require 'ad/agent_architecture/report/workflow_list_report'
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
22
30
 
23
31
  module Ad
24
32
  module AgentArchitecture
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.9",
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.9",
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.9",
3
+ "version": "0.0.10",
4
4
  "description": "Architecture/Schema for AI Agents",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
data/workflow.json CHANGED
@@ -1,99 +1,78 @@
1
1
  {
2
- "name": "YouTube Transcript to Medium Article",
2
+ "name": "YouTube Title Creator",
3
3
  "sections": [
4
4
  {
5
- "name": "Analysis",
5
+ "name": "Research",
6
6
  "order": 1,
7
7
  "steps": [
8
8
  {
9
- "name": "Generate Outline",
9
+ "name": "Starting Context",
10
10
  "order": 1,
11
11
  "input_attributes": [
12
- "transcript"
12
+
13
13
  ],
14
14
  "output_attributes": [
15
- "outline"
15
+
16
16
  ],
17
- "prompt": "Analyze [transcript] and generate a preliminary outline for a blog post."
17
+ "prompt": "best_practice"
18
18
  },
19
19
  {
20
- "name": "Write First Draft",
20
+ "name": "Basic titles",
21
21
  "order": 2,
22
22
  "input_attributes": [
23
- "outline"
23
+ "basic_title",
24
+ "basic_keyword",
25
+ "basic_transcript"
24
26
  ],
25
27
  "output_attributes": [
26
- "first_draft"
28
+ "potential_titles"
27
29
  ],
28
- "prompt": "Write a blog post based on [outline]."
30
+ "prompt": "Keyword: [start_keyword]\nTitle: [start_title]\n\nTranscript:\n\n[start_transcript]\n"
29
31
  },
30
32
  {
31
- "name": "Generate Intros",
33
+ "name": "Working Title",
32
34
  "order": 3,
33
35
  "input_attributes": [
34
- "first_draft"
36
+ "potential_titles"
35
37
  ],
36
38
  "output_attributes": [
37
- "intro_variations"
38
- ],
39
- "prompt": "Create 5 introduction variations for [first_draft]."
40
- },
41
- {
42
- "name": "SEO Analysis",
43
- "order": 4,
44
- "input_attributes": [
45
- "first_draft"
46
- ],
47
- "output_attributes": [
48
- "seo_analysis"
49
- ],
50
- "prompt": "Analyze the blog post for SEO."
51
- }
52
- ]
53
- },
54
- {
55
- "name": "Editing",
56
- "order": 2,
57
- "steps": [
58
- {
59
- "name": "Edit Draft",
60
- "order": 1,
61
- "input_attributes": [
62
- "first_draft"
63
- ],
64
- "output_attributes": [
65
- "first_draft"
66
- ],
67
- "prompt": "Edit [first_draft] for grammar, style, and clarity."
39
+ "working_title"
40
+ ]
68
41
  }
69
42
  ]
70
43
  }
71
44
  ],
72
45
  "attributes": {
73
- "transcript": {
74
- "name": "transcript",
46
+ "start_title": {
47
+ "name": "start_title",
75
48
  "type": "string",
76
49
  "is_array": false
77
50
  },
78
- "outline": {
79
- "name": "outline",
51
+ "start_keyword": {
52
+ "name": "start_keyword",
80
53
  "type": "string",
81
54
  "is_array": false
82
55
  },
83
- "first_draft": {
84
- "name": "first_draft",
56
+ "start_transcript": {
57
+ "name": "start_transcript",
85
58
  "type": "string",
86
59
  "is_array": false
87
60
  },
88
- "intro_variations": {
89
- "name": "intro_variations",
61
+ "potential_titles": {
62
+ "name": "potential_titles",
90
63
  "type": "array",
91
64
  "is_array": false
92
65
  },
93
- "seo_analysis": {
94
- "name": "seo_analysis",
66
+ "working_title": {
67
+ "name": "working_title",
95
68
  "type": "string",
96
69
  "is_array": false
97
70
  }
98
- }
71
+ },
72
+ "prompts": [
73
+ {
74
+ "name": "best_practice",
75
+ "path": "youtube/title_creator/best_practice.md"
76
+ }
77
+ ]
99
78
  }
data/workflow.yaml CHANGED
@@ -1,65 +1,56 @@
1
1
  ---
2
- :name: YouTube Transcript to Medium Article
2
+ :name: YouTube Title Creator
3
3
  :sections:
4
- - :name: Analysis
4
+ - :name: Research
5
5
  :order: 1
6
6
  :steps:
7
- - :name: Generate Outline
7
+ - :name: Starting Context
8
8
  :order: 1
9
- :input_attributes:
10
- - :transcript
11
- :output_attributes:
12
- - :outline
13
- :prompt: Analyze [transcript] and generate a preliminary outline for a blog post.
14
- - :name: Write First Draft
9
+ :input_attributes: []
10
+ :output_attributes: []
11
+ :prompt: :best_practice
12
+ - :name: Basic titles
15
13
  :order: 2
16
14
  :input_attributes:
17
- - :outline
15
+ - :basic_title
16
+ - :basic_keyword
17
+ - :basic_transcript
18
18
  :output_attributes:
19
- - :first_draft
20
- :prompt: Write a blog post based on [outline].
21
- - :name: Generate Intros
19
+ - :potential_titles
20
+ :prompt: |
21
+ Keyword: [start_keyword]
22
+ Title: [start_title]
23
+
24
+ Transcript:
25
+
26
+ [start_transcript]
27
+ - :name: Working Title
22
28
  :order: 3
23
29
  :input_attributes:
24
- - :first_draft
25
- :output_attributes:
26
- - :intro_variations
27
- :prompt: Create 5 introduction variations for [first_draft].
28
- - :name: SEO Analysis
29
- :order: 4
30
- :input_attributes:
31
- - :first_draft
32
- :output_attributes:
33
- - :seo_analysis
34
- :prompt: Analyze the blog post for SEO.
35
- - :name: Editing
36
- :order: 2
37
- :steps:
38
- - :name: Edit Draft
39
- :order: 1
40
- :input_attributes:
41
- - :first_draft
30
+ - :potential_titles
42
31
  :output_attributes:
43
- - :first_draft
44
- :prompt: Edit [first_draft] for grammar, style, and clarity.
32
+ - :working_title
45
33
  :attributes:
46
- :transcript:
47
- :name: :transcript
34
+ :start_title:
35
+ :name: :start_title
48
36
  :type: :string
49
37
  :is_array: false
50
- :outline:
51
- :name: :outline
38
+ :start_keyword:
39
+ :name: :start_keyword
52
40
  :type: :string
53
41
  :is_array: false
54
- :first_draft:
55
- :name: :first_draft
42
+ :start_transcript:
43
+ :name: :start_transcript
56
44
  :type: :string
57
45
  :is_array: false
58
- :intro_variations:
59
- :name: :intro_variations
46
+ :potential_titles:
47
+ :name: :potential_titles
60
48
  :type: :array
61
49
  :is_array: false
62
- :seo_analysis:
63
- :name: :seo_analysis
50
+ :working_title:
51
+ :name: :working_title
64
52
  :type: :string
65
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cruwys
@@ -86,7 +86,13 @@ files:
86
86
  - lib/ad/agent_architecture/dsl/actions/save_database.rb
87
87
  - lib/ad/agent_architecture/dsl/actions/save_json.rb
88
88
  - lib/ad/agent_architecture/dsl/actions/save_yaml.rb
89
- - lib/ad/agent_architecture/dsl/agent_workflow_dsl.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
90
96
  - lib/ad/agent_architecture/report/workflow_detail_report.rb
91
97
  - lib/ad/agent_architecture/report/workflow_list_report.rb
92
98
  - lib/ad/agent_architecture/sql/workflow_details.sql