ad-agent_architecture 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +14 -0
- data/README.md +2 -0
- data/docs/erd.svg +12 -0
- data/docs/images/sample-workflow.png +0 -0
- data/docs/requirements.md +618 -74
- data/docs/structure-youtube-script.yaml +177 -0
- data/lib/ad/agent_architecture/db/create_schema.rb +159 -0
- data/lib/ad/agent_architecture/db/models.rb +76 -0
- data/lib/ad/agent_architecture/version.rb +1 -1
- data/lib/ad/agent_architecture.rb +10 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +35 -2
@@ -0,0 +1,177 @@
|
|
1
|
+
workflows:
|
2
|
+
- id: 1
|
3
|
+
name: "YouTube Video Script"
|
4
|
+
description: "Workflow for creating a YouTube video script"
|
5
|
+
|
6
|
+
sections:
|
7
|
+
- id: 1
|
8
|
+
name: "Research"
|
9
|
+
description: "Research phase of the workflow"
|
10
|
+
order: 1
|
11
|
+
workflow_id: 1
|
12
|
+
- id: 2
|
13
|
+
name: "Script Writing"
|
14
|
+
description: "Script writing phase of the workflow"
|
15
|
+
order: 2
|
16
|
+
workflow_id: 1
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- id: 1
|
20
|
+
name: "01-1-basic-meta"
|
21
|
+
description: "Basic metadata for Fotor AI tool"
|
22
|
+
order: 1
|
23
|
+
section_id: 1
|
24
|
+
prompt: "Generate 5 titles to get started"
|
25
|
+
- id: 2
|
26
|
+
name: "01-2-basic-factsheet"
|
27
|
+
description: "Detailed factsheet about Fotor AI Tool"
|
28
|
+
order: 2
|
29
|
+
section_id: 1
|
30
|
+
prompt: "Generate detailed factsheet"
|
31
|
+
- id: 3
|
32
|
+
name: "01-3-video-type"
|
33
|
+
description: "Identify video types"
|
34
|
+
order: 3
|
35
|
+
section_id: 1
|
36
|
+
prompt: "Identify video types based on basic factsheet"
|
37
|
+
- id: 4
|
38
|
+
name: "01-4-expanded-factsheet"
|
39
|
+
description: "Expanded factsheet about Fotor AI Tool"
|
40
|
+
order: 4
|
41
|
+
section_id: 1
|
42
|
+
prompt: "Generate expanded factsheet"
|
43
|
+
- id: 5
|
44
|
+
name: "01-5-expanded-meta"
|
45
|
+
description: "Expanded metadata for Fotor AI Tool"
|
46
|
+
order: 5
|
47
|
+
section_id: 1
|
48
|
+
prompt: "Generate engaging titles, keywords, and topics"
|
49
|
+
- id: 6
|
50
|
+
name: "02-1-create-script"
|
51
|
+
description: "Create basic script"
|
52
|
+
order: 1
|
53
|
+
section_id: 2
|
54
|
+
prompt: "Generate basic script"
|
55
|
+
- id: 7
|
56
|
+
name: "02-2-clean-transcript"
|
57
|
+
description: "Clean and revise transcript"
|
58
|
+
order: 2
|
59
|
+
section_id: 2
|
60
|
+
prompt: "Generate basic transcript"
|
61
|
+
- id: 8
|
62
|
+
name: "02-3-transcript-factchecked"
|
63
|
+
description: "Fact-check and revise transcript"
|
64
|
+
order: 3
|
65
|
+
section_id: 2
|
66
|
+
prompt: "Generate fact-checked transcript"
|
67
|
+
|
68
|
+
attributes:
|
69
|
+
- id: 1
|
70
|
+
name: "simple_title"
|
71
|
+
type: "string"
|
72
|
+
is_array: false
|
73
|
+
workflow_id: 1
|
74
|
+
- id: 2
|
75
|
+
name: "basic_factsheet"
|
76
|
+
type: "string"
|
77
|
+
is_array: false
|
78
|
+
workflow_id: 1
|
79
|
+
- id: 3
|
80
|
+
name: "focus_video_type"
|
81
|
+
type: "string"
|
82
|
+
is_array: false
|
83
|
+
workflow_id: 1
|
84
|
+
- id: 4
|
85
|
+
name: "expanded_factsheet"
|
86
|
+
type: "string"
|
87
|
+
is_array: false
|
88
|
+
workflow_id: 1
|
89
|
+
- id: 5
|
90
|
+
name: "video_types"
|
91
|
+
type: "string"
|
92
|
+
is_array: true
|
93
|
+
workflow_id: 1
|
94
|
+
- id: 6
|
95
|
+
name: "engaging_titles"
|
96
|
+
type: "string"
|
97
|
+
is_array: true
|
98
|
+
workflow_id: 1
|
99
|
+
- id: 7
|
100
|
+
name: "keywords"
|
101
|
+
type: "string"
|
102
|
+
is_array: true
|
103
|
+
workflow_id: 1
|
104
|
+
- id: 8
|
105
|
+
name: "topics"
|
106
|
+
type: "string"
|
107
|
+
is_array: true
|
108
|
+
workflow_id: 1
|
109
|
+
- id: 9
|
110
|
+
name: "basic_script"
|
111
|
+
type: "string"
|
112
|
+
is_array: false
|
113
|
+
workflow_id: 1
|
114
|
+
- id: 10
|
115
|
+
name: "basic_transcript"
|
116
|
+
type: "string"
|
117
|
+
is_array: false
|
118
|
+
workflow_id: 1
|
119
|
+
- id: 11
|
120
|
+
name: "transcript_qa"
|
121
|
+
type: "string"
|
122
|
+
is_array: false
|
123
|
+
workflow_id: 1
|
124
|
+
|
125
|
+
input_attributes:
|
126
|
+
- step_id: 1
|
127
|
+
attribute_id: 1
|
128
|
+
- step_id: 2
|
129
|
+
attribute_id: 1
|
130
|
+
- step_id: 3
|
131
|
+
attribute_id: 1
|
132
|
+
- step_id: 3
|
133
|
+
attribute_id: 2
|
134
|
+
- step_id: 4
|
135
|
+
attribute_id: 1
|
136
|
+
- step_id: 4
|
137
|
+
attribute_id: 2
|
138
|
+
- step_id: 4
|
139
|
+
attribute_id: 3
|
140
|
+
- step_id: 5
|
141
|
+
attribute_id: 1
|
142
|
+
- step_id: 5
|
143
|
+
attribute_id: 3
|
144
|
+
- step_id: 5
|
145
|
+
attribute_id: 4
|
146
|
+
- step_id: 6
|
147
|
+
attribute_id: 1
|
148
|
+
- step_id: 6
|
149
|
+
attribute_id: 3
|
150
|
+
- step_id: 6
|
151
|
+
attribute_id: 4
|
152
|
+
- step_id: 7
|
153
|
+
attribute_id: 9
|
154
|
+
- step_id: 8
|
155
|
+
attribute_id: 10
|
156
|
+
|
157
|
+
output_attributes:
|
158
|
+
- step_id: 1
|
159
|
+
attribute_id: 6
|
160
|
+
- step_id: 2
|
161
|
+
attribute_id: 2
|
162
|
+
- step_id: 3
|
163
|
+
attribute_id: 5
|
164
|
+
- step_id: 4
|
165
|
+
attribute_id: 4
|
166
|
+
- step_id: 5
|
167
|
+
attribute_id: 6
|
168
|
+
- step_id: 5
|
169
|
+
attribute_id: 7
|
170
|
+
- step_id: 5
|
171
|
+
attribute_id: 8
|
172
|
+
- step_id: 6
|
173
|
+
attribute_id: 9
|
174
|
+
- step_id: 7
|
175
|
+
attribute_id: 10
|
176
|
+
- step_id: 8
|
177
|
+
attribute_id: 11
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Usage
|
4
|
+
# DB = Sequel.sqlite # In-memory database
|
5
|
+
|
6
|
+
# schema_creator = Ad::AgentArchitecture::Database::CreateSchema.new(DB)
|
7
|
+
# schema_creator.execute
|
8
|
+
module Ad
|
9
|
+
module AgentArchitecture
|
10
|
+
module Database
|
11
|
+
# Create the database schema
|
12
|
+
class CreateSchema
|
13
|
+
attr_reader :db
|
14
|
+
|
15
|
+
def initialize(db)
|
16
|
+
@db = db
|
17
|
+
end
|
18
|
+
|
19
|
+
def execute
|
20
|
+
create_tables
|
21
|
+
define_models
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def create_tables
|
27
|
+
db.create_table :workflows do
|
28
|
+
primary_key :id
|
29
|
+
String :name, null: false
|
30
|
+
String :description
|
31
|
+
end
|
32
|
+
|
33
|
+
db.create_table :sections do
|
34
|
+
primary_key :id
|
35
|
+
foreign_key :workflow_id, :workflows
|
36
|
+
String :name, null: false
|
37
|
+
String :description
|
38
|
+
Integer :order
|
39
|
+
end
|
40
|
+
|
41
|
+
db.create_table :steps do
|
42
|
+
primary_key :id
|
43
|
+
foreign_key :section_id, :sections
|
44
|
+
String :name, null: false
|
45
|
+
String :action, default: 'gpt'
|
46
|
+
String :description
|
47
|
+
Integer :order
|
48
|
+
String :prompt
|
49
|
+
end
|
50
|
+
|
51
|
+
db.create_table :attributes do
|
52
|
+
primary_key :id
|
53
|
+
foreign_key :workflow_id, :workflows
|
54
|
+
String :name, null: false
|
55
|
+
String :type
|
56
|
+
Boolean :is_array
|
57
|
+
end
|
58
|
+
|
59
|
+
db.create_table :input_attributes do
|
60
|
+
primary_key :id
|
61
|
+
foreign_key :step_id, :steps
|
62
|
+
foreign_key :attribute_id, :attributes
|
63
|
+
Boolean :required
|
64
|
+
end
|
65
|
+
|
66
|
+
db.create_table :output_attributes do
|
67
|
+
primary_key :id
|
68
|
+
foreign_key :step_id, :steps
|
69
|
+
foreign_key :attribute_id, :attributes
|
70
|
+
end
|
71
|
+
|
72
|
+
db.create_table :workflow_runs do
|
73
|
+
primary_key :id
|
74
|
+
foreign_key :workflow_id, :workflows
|
75
|
+
end
|
76
|
+
|
77
|
+
db.create_table :section_runs do
|
78
|
+
primary_key :id
|
79
|
+
foreign_key :workflow_run_id, :workflow_runs
|
80
|
+
foreign_key :section_id, :sections
|
81
|
+
end
|
82
|
+
|
83
|
+
db.create_table :step_runs do
|
84
|
+
primary_key :id
|
85
|
+
foreign_key :section_run_id, :section_runs
|
86
|
+
foreign_key :step_id, :steps
|
87
|
+
Integer :branch_number
|
88
|
+
end
|
89
|
+
|
90
|
+
db.create_table :attribute_values do
|
91
|
+
primary_key :id
|
92
|
+
foreign_key :attribute_id, :attributes
|
93
|
+
foreign_key :step_run_id, :step_runs
|
94
|
+
String :value
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def define_models
|
99
|
+
Class.new(Sequel::Model(:workflows)) do
|
100
|
+
one_to_many :sections
|
101
|
+
one_to_many :attributes
|
102
|
+
one_to_many :workflow_runs
|
103
|
+
end
|
104
|
+
|
105
|
+
Class.new(Sequel::Model(:sections)) do
|
106
|
+
many_to_one :workflow
|
107
|
+
one_to_many :steps
|
108
|
+
one_to_many :section_runs
|
109
|
+
end
|
110
|
+
|
111
|
+
Class.new(Sequel::Model(:steps)) do
|
112
|
+
many_to_one :section
|
113
|
+
one_to_many :input_attributes, class: :InputAttribute
|
114
|
+
one_to_many :output_attributes, class: :OutputAttribute
|
115
|
+
one_to_many :step_runs
|
116
|
+
end
|
117
|
+
|
118
|
+
Class.new(Sequel::Model(:attributes)) do
|
119
|
+
many_to_one :workflow
|
120
|
+
one_to_many :input_attributes, class: :InputAttribute
|
121
|
+
one_to_many :output_attributes, class: :OutputAttribute
|
122
|
+
end
|
123
|
+
|
124
|
+
Class.new(Sequel::Model(:input_attributes)) do
|
125
|
+
many_to_one :step
|
126
|
+
many_to_one :attribute
|
127
|
+
end
|
128
|
+
|
129
|
+
Class.new(Sequel::Model(:output_attributes)) do
|
130
|
+
many_to_one :step
|
131
|
+
many_to_one :attribute
|
132
|
+
end
|
133
|
+
|
134
|
+
Class.new(Sequel::Model(:workflow_runs)) do
|
135
|
+
many_to_one :workflow
|
136
|
+
one_to_many :section_runs
|
137
|
+
end
|
138
|
+
|
139
|
+
Class.new(Sequel::Model(:section_runs)) do
|
140
|
+
many_to_one :workflow_run
|
141
|
+
many_to_one :section
|
142
|
+
one_to_many :step_runs
|
143
|
+
end
|
144
|
+
|
145
|
+
Class.new(Sequel::Model(:step_runs)) do
|
146
|
+
many_to_one :section_run
|
147
|
+
many_to_one :step
|
148
|
+
one_to_many :attribute_values
|
149
|
+
end
|
150
|
+
|
151
|
+
Class.new(Sequel::Model(:attribute_values)) do
|
152
|
+
many_to_one :attribute
|
153
|
+
many_to_one :step_run
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sequel'
|
4
|
+
|
5
|
+
module Ad
|
6
|
+
module AgentArchitecture
|
7
|
+
module Database
|
8
|
+
# Workflow model represents a workflow entity in the database.
|
9
|
+
class Workflow < Sequel::Model
|
10
|
+
one_to_many :sections, class: 'Ad::AgentArchitecture::Database::Section'
|
11
|
+
one_to_many :attributes, class: 'Ad::AgentArchitecture::Database::Attribute'
|
12
|
+
one_to_many :workflow_runs, class: 'Ad::AgentArchitecture::Database::WorkflowRun'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Section model represents a section entity in the database.
|
16
|
+
class Section < Sequel::Model
|
17
|
+
many_to_one :workflow, class: 'Ad::AgentArchitecture::Database::Workflow'
|
18
|
+
one_to_many :steps, class: 'Ad::AgentArchitecture::Database::Step'
|
19
|
+
one_to_many :section_runs, class: 'Ad::AgentArchitecture::Database::SectionRun'
|
20
|
+
end
|
21
|
+
|
22
|
+
# Step model represents a step entity in the database.
|
23
|
+
class Step < Sequel::Model
|
24
|
+
many_to_one :section, class: 'Ad::AgentArchitecture::Database::Section'
|
25
|
+
one_to_many :input_attributes, class: 'Ad::AgentArchitecture::Database::InputAttribute'
|
26
|
+
one_to_many :output_attributes, class: 'Ad::AgentArchitecture::Database::OutputAttribute'
|
27
|
+
one_to_many :step_runs, class: 'Ad::AgentArchitecture::Database::StepRun'
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute model represents an attribute entity in the database.
|
31
|
+
class Attribute < Sequel::Model
|
32
|
+
many_to_one :workflow, class: 'Ad::AgentArchitecture::Database::Workflow'
|
33
|
+
one_to_many :input_attributes, class: 'Ad::AgentArchitecture::Database::InputAttribute'
|
34
|
+
one_to_many :output_attributes, class: 'Ad::AgentArchitecture::Database::OutputAttribute'
|
35
|
+
end
|
36
|
+
|
37
|
+
# InputAttribute model represents an input attribute entity in the database.
|
38
|
+
class InputAttribute < Sequel::Model
|
39
|
+
many_to_one :step, class: 'Ad::AgentArchitecture::Database::Step'
|
40
|
+
many_to_one :attribute, class: 'Ad::AgentArchitecture::Database::Attribute'
|
41
|
+
end
|
42
|
+
|
43
|
+
# OutputAttribute model represents an output attribute entity in the database.
|
44
|
+
class OutputAttribute < Sequel::Model
|
45
|
+
many_to_one :step, class: 'Ad::AgentArchitecture::Database::Step'
|
46
|
+
many_to_one :attribute, class: 'Ad::AgentArchitecture::Database::Attribute'
|
47
|
+
end
|
48
|
+
|
49
|
+
# WorkflowRun model represents a workflow run entity in the database.
|
50
|
+
class WorkflowRun < Sequel::Model
|
51
|
+
many_to_one :workflow, class: 'Ad::AgentArchitecture::Database::Workflow'
|
52
|
+
one_to_many :section_runs, class: 'Ad::AgentArchitecture::Database::SectionRun'
|
53
|
+
end
|
54
|
+
|
55
|
+
# SectionRun model represents a section run entity in the database.
|
56
|
+
class SectionRun < Sequel::Model
|
57
|
+
many_to_one :workflow_run, class: 'Ad::AgentArchitecture::Database::WorkflowRun'
|
58
|
+
many_to_one :section, class: 'Ad::AgentArchitecture::Database::Section'
|
59
|
+
one_to_many :step_runs, class: 'Ad::AgentArchitecture::Database::StepRun'
|
60
|
+
end
|
61
|
+
|
62
|
+
# StepRun model represents a step run entity in the database.
|
63
|
+
class StepRun < Sequel::Model
|
64
|
+
many_to_one :section_run, class: 'Ad::AgentArchitecture::Database::SectionRun'
|
65
|
+
many_to_one :step, class: 'Ad::AgentArchitecture::Database::Step'
|
66
|
+
one_to_many :attribute_values, class: 'Ad::AgentArchitecture::Database::AttributeValue'
|
67
|
+
end
|
68
|
+
|
69
|
+
# AttributeValue model represents an attribute value entity in the database.
|
70
|
+
class AttributeValue < Sequel::Model
|
71
|
+
many_to_one :attribute, class: 'Ad::AgentArchitecture::Database::Attribute'
|
72
|
+
many_to_one :step_run, class: 'Ad::AgentArchitecture::Database::StepRun'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,6 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'sequel'
|
4
|
+
require 'sqlite3'
|
5
|
+
|
3
6
|
require 'ad/agent_architecture/version'
|
7
|
+
require 'ad/agent_architecture/db/create_schema'
|
8
|
+
|
9
|
+
DB = Sequel.sqlite
|
10
|
+
|
11
|
+
Ad::AgentArchitecture::Database::CreateSchema.new(DB).execute
|
12
|
+
|
13
|
+
require 'ad/agent_architecture/db/models'
|
4
14
|
|
5
15
|
module Ad
|
6
16
|
module AgentArchitecture
|
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.5",
|
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.5",
|
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.5
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_log
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sequel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
27
55
|
description: " Architecture/Schema for AI Agents\n"
|
28
56
|
email:
|
29
57
|
- david@ideasmen.com.au
|
@@ -47,8 +75,13 @@ files:
|
|
47
75
|
- Rakefile
|
48
76
|
- bin/console
|
49
77
|
- bin/setup
|
78
|
+
- docs/erd.svg
|
79
|
+
- docs/images/sample-workflow.png
|
50
80
|
- docs/requirements.md
|
81
|
+
- docs/structure-youtube-script.yaml
|
51
82
|
- lib/ad/agent_architecture.rb
|
83
|
+
- lib/ad/agent_architecture/db/create_schema.rb
|
84
|
+
- lib/ad/agent_architecture/db/models.rb
|
52
85
|
- lib/ad/agent_architecture/version.rb
|
53
86
|
- package-lock.json
|
54
87
|
- package.json
|