ad-agent_architecture 0.0.5 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48e72bffc8e25721cc39304860dac54bdde2cbe3828fd9bf39ea5a93d2ae40d8
4
- data.tar.gz: 6579e5af918b96e8eb9960ea2e672cf1b2315fad054f794ca5789cec1779624c
3
+ metadata.gz: 25616fff163424e27ea21bf76cabec403e7113c7b018e791ed42fe523e7964aa
4
+ data.tar.gz: a34ad7c9d1275dc3db2394623874408225b67ab6a1a6d39bf0f2b46fafc7608f
5
5
  SHA512:
6
- metadata.gz: a3ac5432296309961a50273fbb71cdf0fd681ab5d1a40cf7054a9b1a044001d1262d0eefc91f08f579a887294104dc3e22e2fbe3717e3c32b98fe0eae7ff54de
7
- data.tar.gz: 93c048683f119fa32427bf57422bf1217bb689870162cb733a3eda10bdba6d92c0f8b7606e3550630b747ad2000a7bd48ec7c83beaa4ab2c67593a67c7b5b5ef
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,18 @@
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
+
8
+ ## [0.0.5](https://github.com/appydave/ad-agent_architecture/compare/v0.0.4...v0.0.5) (2024-06-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add sqlite3, sequal and setup a schema ([a8fa9c9](https://github.com/appydave/ad-agent_architecture/commit/a8fa9c9ff29ed223644d3622bd46ca5d626af9a9))
14
+ * add sqlite3, sequal and setup a schema ([87ded1e](https://github.com/appydave/ad-agent_architecture/commit/87ded1e6886d3190fc83ecaa4e215bacf044378f))
15
+
1
16
  ## [0.0.4](https://github.com/appydave/ad-agent_architecture/compare/v0.0.3...v0.0.4) (2024-06-26)
2
17
 
3
18
 
data/docs/requirements.md CHANGED
@@ -1,3 +1,65 @@
1
+ # AppyDave - Agent Architecture Schema
2
+
3
+ ## Purpose
4
+
5
+ The application is designed to handle structured workflows for building documents or text-based assets using LLMs from OpenAi, Anthropic and others. It should be adaptable to any workflow that follows a structured concept or a series of steps.
6
+
7
+ ## Sample Workflows
8
+ - YouTube titles
9
+ - YouTube scripts
10
+ - YouTube transcription to Medium, LinkedIn, etc.
11
+
12
+ ## Key Components
13
+
14
+ ### Static Workflow Definition
15
+ - **Workflows**: Define a series of tasks to achieve a specific goal.
16
+ - **Sections**: Subdivisions within workflows to organize steps logically.
17
+ - **Steps**: Individual tasks within a section, each associated with an AI prompt and various input/output attributes.
18
+ - **Attributes**: Parameters used in steps, which can be simple values or arrays.
19
+ - **Input/Output Attributes**: Map attributes to steps as either inputs or outputs.
20
+
21
+ ### Dynamic Workflow Execution
22
+ - **Workflow Runs**: Instances of workflow executions.
23
+ - **Section Runs**: Instances of section executions within a workflow run.
24
+ - **Step Runs**: Instances of step executions within a section run, supporting multiple branches.
25
+ - **Attribute Values**: Store the values of attributes during step executions.
26
+
27
+ ## Features
28
+
29
+ ### Schema Creation and Models
30
+ - Use Sequel and SQLite to define and manage the database schema.
31
+ - Models are defined for workflows, sections, steps, attributes, and their relationships.
32
+
33
+ ### Testing and Validation
34
+ - Unit tests to verify the schema and associations using RSpec.
35
+ - Guard setup to automatically run tests when certain files are modified.
36
+
37
+ ### Data Management
38
+ - Methods to export the database schema and data to JSON files for backup.
39
+ - Methods to restore the database from JSON files for easy editing and re-importing.
40
+
41
+ ## Initial Workflows
42
+ - These include YouTube video scripts, YouTube title creation, and transcription to articles.
43
+ - These workflows serve as examples and validation for the broader concept.
44
+
45
+ ## Implementation Details
46
+ - **Database**: Use SQLite with Sequel for ORM.
47
+ - **Code Structure**: Organize code into modules and classes for database schema creation and model definitions.
48
+ - **Testing**: Ensure models and associations are correctly implemented and tested.
49
+
50
+ ## Next Steps
51
+
52
+ ### Refine DSL for Static Workflows
53
+ - Enhance the DSL to create and update static workflows.
54
+ - Ensure it updates the database and exports workflows in JSON/YAML format.
55
+ - Implement rendering of the workflow structure as HTML.
56
+
57
+ ### Plan Dynamic Execution
58
+ - Determine the approach for executing workflows dynamically.
59
+ - Decide on using a DSL or a web application for this purpose.
60
+
61
+ This summary should help guide the development and focus on the core objectives and future directions.
62
+
1
63
 
2
64
  ## Schema for AI Agents
3
65
 
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ad
4
4
  module AgentArchitecture
5
- VERSION = '0.0.5'
5
+ VERSION = '0.0.7'
6
6
  end
7
7
  end
@@ -11,6 +11,7 @@ DB = Sequel.sqlite
11
11
  Ad::AgentArchitecture::Database::CreateSchema.new(DB).execute
12
12
 
13
13
  require 'ad/agent_architecture/db/models'
14
+ require 'ad/agent_architecture/dsl/agent_workflow_dsl'
14
15
 
15
16
  module Ad
16
17
  module AgentArchitecture
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.5",
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.5",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ad-agent_architecture",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Architecture/Schema for AI Agents",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
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.5
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-28 00:00:00.000000000 Z
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