autoflux 0.2.0 → 0.3.0

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: 4057f638e916ef5cca2980912c4daf1b0928cc929766156f7859ae93d2a596f6
4
- data.tar.gz: a71fc9aaa77da24cb1c4dd9ea7dcd46b7386d640aaef737eb143d960bd1183c7
3
+ metadata.gz: bfba17b715db371a3388379b0d894f1cd7e02e5ddec7dc9e30545b009037195e
4
+ data.tar.gz: 768d96e08f58eac4516c03b6fb1ae13a6c4939ffa47702fa57de3c45cff8a831
5
5
  SHA512:
6
- metadata.gz: 59926823b4d02b924f919f63df286be8e912e3a13921e8033ba7db333d21ff95ad0f5e4be669f604bf1bfea6c9c3ec90f4c2844375ad768c05dd835b9c9df2c6
7
- data.tar.gz: 5ab23c20f3a229f5cc864b4814a08d8a25d3e38de97ef04c41ba77470c97ca0a9b1b297caaf86f8b01a54ef67ae69524d6b2deef91b10eb397b935879dc322ca
6
+ metadata.gz: fe2ee26a057d023a378eee32fead552d45312724a1a59b4dcf1a6681cef889ffda78030fcafac5b98ee41ae2c4a4d3b24d859fa1682aac86595ed82e58759226
7
+ data.tar.gz: dd3461bdffb1f07be326962f43b3ee661e901881eaea3a71c0225bb55047c559e13a5e62743e4426751a36af3447fdcf4084cddd238f155ce4529060f619802a
data/README.md CHANGED
@@ -57,82 +57,110 @@ When receive "exit" from the user, the workflow transition to the stop state.
57
57
 
58
58
  ### Agent
59
59
 
60
- The agent is an adapter to the LLM model. You can inherit the `Autoflux::Agent` class to implement your own agent.
60
+ The agent is an adapter to the LLM model.
61
61
 
62
62
  ```ruby
63
63
  # :nodoc:
64
- class OpenAIAgent < Autoflux::Agent
64
+ class OpenAIAgent
65
65
  attr_reader :client, :model
66
66
 
67
- def initialize(client:, tools: [], model: 'gpt-4o-mini')
67
+ def initialize(client:, model: 'gpt-4o-mini')
68
68
  super(tools: tools)
69
69
  @client = client
70
70
  @model = model
71
71
  end
72
72
 
73
73
  def call(memory:)
74
- client.chat(
74
+ msg = client.chat(
75
75
  parameters: {
76
76
  model: model,
77
- messages: memory.data,
78
- tools: tools
77
+ messages: memory.data.map { |event| convert_message(event) },
79
78
  }
80
79
  ).dig('choices', 0, 'message')
80
+
81
+ convert_event(msg)
81
82
  end
82
83
 
83
- def tools
84
- @tools ||= @_tools.map do |tool|
85
- {
86
- type: :function,
87
- function: {
88
- name: tool.name,
89
- description: tool.description,
90
- parameters: tool.parameters
91
- }
92
- }
84
+ # If allow to use the tool, return tool object implements `Autoflux::_Tool` interface
85
+ def tools?(name) = false
86
+ def tool(name) = nil
87
+
88
+ # Autoflux use a generic event object to represent the message, you have to convert it to the model's format
89
+ def convert_message(event)
90
+ {
91
+ role: event[:role],
92
+ content: event[:content]
93
+ }.tap do |evt|
94
+ evt[:tool_calls] = event[:invocations]&.map { |invocation| convert_tool_call(invocation) }
95
+ evt[:tool_call_id] = event[:invocation_id] if event[:invocation_id]
93
96
  end
94
97
  end
98
+
99
+ def convert_tool_call(invocation)
100
+ {
101
+ type: :function,
102
+ id: invocation[:id],
103
+ function: {
104
+ name: invocation[:name],
105
+ arguments: invocation[:args]
106
+ }
107
+ }
108
+ end
109
+
110
+ def convert_event(msg) # rubocop:disable Metrics/MethodLength
111
+ {
112
+ role: msg['role'],
113
+ content: msg['content'],
114
+ invocations: msg['tool_calls']&.map do |call|
115
+ {
116
+ id: call['id'],
117
+ name: call.dig('function', 'name'),
118
+ args: call.dig('function', 'arguments')
119
+ }
120
+ end
121
+ }
122
+ end
95
123
  end
96
124
  ```
97
125
 
98
- The memory is chat history which keep in the workflow. You can decide to use it or not.
126
+ The memory is history which keep in the workflow. You can decide to use it or not.
99
127
 
100
128
  ### Tool
101
129
 
102
- The tool is a function that can be used in the agent's response. You can inherit the `Autoflux::Tool` class to implement your own tool.
130
+ The tool is a function that can be used in the agent's response.
103
131
 
104
132
  ```ruby
105
133
  # :nodoc:
106
- class AddToCartTool < Autoflux::Tool
134
+ class AddToCartTool
135
+ attr_reader :name, :description, :parameters
136
+
107
137
  def initialize # rubocop:disable Metrics/MethodLength
108
- super(
109
- name: 'add_to_cart',
110
- description: 'Add the product to the cart',
111
- parameters: {
112
- type: 'object',
113
- properties: {
114
- name: { type: 'string', description: 'The name of the product' },
115
- quantity: { type: 'number', description: 'The quantity of the product' }
116
- }
138
+ @name = 'add_to_cart'
139
+ @description = 'Add the product to the cart'
140
+ @parameters = {
141
+ type: 'object',
142
+ properties: {
143
+ name: { type: 'string', description: 'The name of the product' },
144
+ quantity: { type: 'number', description: 'The quantity of the product' }
117
145
  }
118
- )
146
+ }
119
147
  end
120
148
 
121
- def call(name:, quantity:, **)
122
- { success: true, content: "Added #{quantity} #{name} to the cart" }
149
+ def call(workflow:, params:)
150
+ { success: true, content: "Added #{params[:quantity]} #{params[:name]} to the cart" }
123
151
  end
124
152
  end
125
153
  ```
126
154
 
127
- The tool is require the name and description. The parameters is optional.
155
+ > You can define how to tell the agent to use the tool by adding `name` and `description` to the tool.
128
156
 
129
157
  ### IO
130
158
 
131
- The IO is an adapter to the input and output. You can inherit the `Autoflux::IO` class to implement your own IO.
159
+ The IO is an adapter to the input and output.
132
160
 
133
161
  ```ruby
134
162
  # :nodoc:
135
- class ConsoleIO < Autoflux::IO
163
+ class ConsoleIO
136
164
  def read
137
165
  print 'User: '
138
166
  gets.chomp
@@ -147,6 +175,8 @@ end
147
175
  The default `Autoflux::Stdio` implement the minimal Standard I/O support.
148
176
 
149
177
  ```ruby
178
+ require 'autoflux/stdio'
179
+
150
180
  workflow = Autoflux::Workflow.new(
151
181
  agent: agent,
152
182
  io: Autoflux::Stdio.new(prompt: '> ')
@@ -15,9 +15,9 @@ module Autoflux
15
15
  # Push the data to the memory.
16
16
  #
17
17
  # @rbs data: Hash
18
- def push(data)
19
- puts JSON.pretty_generate(data) if verbose
20
- @data.push(data)
18
+ def push(event)
19
+ puts JSON.pretty_generate(event) if verbose
20
+ @data.push(event)
21
21
  end
22
22
 
23
23
  # Get the last data from the memory.
@@ -2,14 +2,12 @@
2
2
 
3
3
  module Autoflux
4
4
  # The Stdio is a class to represent the standard input/output.
5
- class Stdio < IO
5
+ class Stdio
6
6
  attr_accessor :prompt
7
7
 
8
8
  # @rbs input: IO
9
9
  # @rbs output: IO
10
10
  def initialize(input: $stdin, output: $stdout, prompt: nil)
11
- super()
12
-
13
11
  @input = input
14
12
  @output = output
15
13
  @prompt = prompt
@@ -18,12 +16,12 @@ module Autoflux
18
16
 
19
17
  def read
20
18
  print prompt if prompt
21
- @input.gets.chomp
19
+ @input.gets&.chomp
22
20
  end
23
21
 
24
22
  # @rbs data: String
25
23
  def write(data)
26
- @output.puts(data)
24
+ @output.puts(data) if data
27
25
  end
28
26
  end
29
27
  end
@@ -3,15 +3,19 @@
3
3
  module Autoflux
4
4
  module Step
5
5
  # The Assistant state is used to call the agent.
6
- class Assistant < Base
7
- OUTPUT_ROLE_NAME = "assistant"
6
+ class Assistant
7
+ def to_s = self.class.name || "Assistant"
8
8
 
9
9
  def call(workflow:)
10
- res = workflow.agent.call(memory: workflow.memory)
11
- workflow.memory.push(res)
12
- return Tool.new if res["tool_calls"]&.any?
10
+ event = workflow.agent.call(memory: workflow.memory)
11
+ workflow.memory.push(event)
13
12
 
14
- workflow.io.write(res["content"]) if res["role"] == OUTPUT_ROLE_NAME
13
+ # @type var invocation_event: Autoflux::invocationEvent
14
+ invocation_event = event
15
+ return Tool.new if invocation_event[:invocations]&.any?
16
+
17
+ # @type var event: Autoflux::textEvent
18
+ workflow.io.write(event[:content]) if event[:role] == ROLE_ASSISTANT
15
19
 
16
20
  Command.new
17
21
  end
@@ -3,14 +3,19 @@
3
3
  module Autoflux
4
4
  module Step
5
5
  # The Command step is used to get the user input.
6
- class Command < Base
6
+ class Command
7
7
  EXIT_COMMAND = "exit"
8
8
 
9
+ def to_s = self.class.name || "Command"
10
+
9
11
  def call(workflow:)
10
12
  input = workflow.io.read
13
+ return Stop.new if input.nil?
11
14
  return Stop.new if input == EXIT_COMMAND
12
15
 
13
- workflow.memory.push(role: :user, content: input)
16
+ # @type var event: Autoflux::event
17
+ event = { role: ROLE_USER, content: input }
18
+ workflow.memory.push(event)
14
19
  Assistant.new
15
20
  end
16
21
  end
@@ -3,7 +3,8 @@
3
3
  module Autoflux
4
4
  module Step
5
5
  # The Start step is used to start the workflow.
6
- class Start < Base
6
+ class Start
7
+ def to_s = self.class.name || "Start"
7
8
  def call(**) = Command.new
8
9
  end
9
10
  end
@@ -3,7 +3,8 @@
3
3
  module Autoflux
4
4
  module Step
5
5
  # The Stop step is used to stop the workflow.
6
- class Stop < Base
6
+ class Stop
7
+ def to_s = self.class.name || "Stop"
7
8
  def call(**) = nil
8
9
  end
9
10
  end
@@ -3,14 +3,21 @@
3
3
  module Autoflux
4
4
  module Step
5
5
  # The Tool state is used to call the tools provided by the agent.
6
- class Tool < Base
6
+ class Tool
7
+ def to_s = self.class.name || "Tool"
8
+
7
9
  def call(workflow:)
8
- workflow.memory.last["tool_calls"]&.each do |tool|
9
- workflow.memory.push(
10
- role: :tool,
11
- content: run(workflow: workflow, tool: tool).to_json,
12
- tool_call_id: tool["id"]
13
- )
10
+ # @type var event: Autoflux::invocationEvent
11
+ event = workflow.memory.last
12
+ event[:invocations]&.each do |invocation|
13
+ # @type: var invocation: Autoflux::invocation
14
+ # @type: var event: Autoflux::invocationResultEvent
15
+ event = {
16
+ role: ROLE_TOOL,
17
+ content: run(workflow: workflow, invocation: invocation).to_json,
18
+ invocation_id: invocation[:id]
19
+ }
20
+ workflow.memory.push(event)
14
21
  end
15
22
 
16
23
  Assistant.new
@@ -18,12 +25,12 @@ module Autoflux
18
25
 
19
26
  protected
20
27
 
21
- def run(workflow:, tool:)
22
- name = tool.dig("function", "name")
23
- params = JSON.parse(tool.dig("function", "arguments"), symbolize_names: true)
28
+ def run(workflow:, invocation:)
29
+ name = invocation[:name]
30
+ params = JSON.parse(invocation[:args], symbolize_names: true)
24
31
  return { status: "error", message: "Tool not found" } unless workflow.agent.tool?(name)
25
32
 
26
- workflow.agent.tool(name).call(**params) # steep:ignore
33
+ workflow.agent.tool(name)&.call(workflow: workflow, params: params)
27
34
  rescue JSON::ParserError
28
35
  { status: "error", message: "Invalid arguments" }
29
36
  end
data/lib/autoflux/step.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  module Autoflux
4
4
  # The Step means a state in the workflow
5
5
  module Step
6
- require "autoflux/step/base"
7
6
  require "autoflux/step/start"
8
7
  require "autoflux/step/stop"
9
8
  require "autoflux/step/command"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Autoflux
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -16,6 +16,8 @@ module Autoflux
16
16
  end
17
17
  end
18
18
 
19
+ include Enumerable
20
+
19
21
  attr_reader :id, :agent, :memory, :io
20
22
 
21
23
  # @rbs state: State
@@ -27,12 +29,27 @@ module Autoflux
27
29
  @memory = memory
28
30
  end
29
31
 
32
+ def each
33
+ return to_enum(:each) unless block_given?
34
+
35
+ yield self
36
+ while @step
37
+ @step = step.call(workflow: self)
38
+ yield self if @step
39
+ end
40
+ end
41
+
30
42
  # Run the workflow.
31
43
  #
32
44
  # @rbs system_prompt: String?
33
- def run(system_prompt: nil)
34
- memory.push(role: :system, content: system_prompt) unless system_prompt.nil?
35
- @step = step.call(workflow: self) while @step
45
+ def run(system_prompt: nil, &block)
46
+ if system_prompt
47
+ # @type var event: Autoflux::event
48
+ event = { role: ROLE_SYSTEM, content: system_prompt }
49
+ memory.push(event)
50
+ end
51
+
52
+ each(&block || ->(_workflow) {})
36
53
  end
37
54
 
38
55
  # Stop the workflow.
@@ -51,7 +68,7 @@ module Autoflux
51
68
  def to_h
52
69
  {
53
70
  id: id,
54
- step: step.name
71
+ step: step.to_s
55
72
  }
56
73
  end
57
74
  end
data/lib/autoflux.rb CHANGED
@@ -6,9 +6,11 @@ require_relative "autoflux/version"
6
6
  module Autoflux
7
7
  class Error < StandardError; end
8
8
 
9
- require_relative "autoflux/tool"
10
- require_relative "autoflux/agent"
11
- require_relative "autoflux/io"
9
+ ROLE_SYSTEM = "system"
10
+ ROLE_ASSISTANT = "assistant"
11
+ ROLE_TOOL = "tool"
12
+ ROLE_USER = "user"
13
+
12
14
  require_relative "autoflux/memory"
13
15
  require_relative "autoflux/step"
14
16
  require_relative "autoflux/workflow"
@@ -3,14 +3,6 @@ module Autoflux
3
3
  interface _Agent
4
4
  def tool?: (String name) -> bool
5
5
  def tool: (String name) -> _Tool?
6
- def call: (memory: _Memory) -> untyped
7
- end
8
-
9
- # The Agent is a abstract class to represent the adapter of the Language Model.
10
- class Agent
11
- include _Agent
12
-
13
- @_tools: Array[_Tool]
14
- def initialize: (?tools: Array[_Tool]?) -> void
6
+ def call: (memory: _Memory) -> event
15
7
  end
16
8
  end
@@ -0,0 +1,27 @@
1
+ module Autoflux
2
+ type jsonString = String
3
+
4
+ type invocation = {
5
+ id: String,
6
+ name: String,
7
+ args: jsonString
8
+ }
9
+
10
+ type eventRole = "assistant" | "system" | "user" | "tool" | String
11
+ type baseEvent = {
12
+ role: eventRole,
13
+ agent_id?: String,
14
+ raw?: Hash[untyped, untyped]
15
+ }
16
+ type textEvent = baseEvent & {
17
+ content: String
18
+ }
19
+ type invocationEvent = baseEvent & {
20
+ invocations: Array[invocation]
21
+ }
22
+ type invocationResultEvent = textEvent & {
23
+ invocation_id: String
24
+ }
25
+
26
+ type event = textEvent | invocationEvent | invocationResultEvent
27
+ end
data/sig/autoflux/io.rbs CHANGED
@@ -1,11 +1,6 @@
1
1
  module Autoflux
2
2
  interface _IO
3
- def read: () -> String
4
- def write: (String data) -> String
5
- end
6
-
7
- # The IO is abstract class to represent the interface of the IO
8
- class IO
9
- include _IO
3
+ def read: () -> String?
4
+ def write: (String? data) -> untyped
10
5
  end
11
6
  end
@@ -1,20 +1,20 @@
1
1
  module Autoflux
2
2
  interface _Memory
3
- def data: () -> Array[untyped]
4
- def push: (untyped data) -> untyped
5
- def last: () -> untyped
3
+ def data: () -> Array[event]
4
+ def push: (event event) -> void
5
+ def last: () -> event
6
6
  end
7
7
 
8
8
  # The Memory is a class to store the memory of the workflow.
9
9
  class Memory
10
10
  include _Memory
11
11
 
12
- @data: Array[untyped]
12
+ @data: Array[event]
13
13
  @verbose: bool
14
14
 
15
15
  attr_reader verbose: bool
16
16
 
17
17
  # @rbs data: Array[Hash]
18
- def initialize: (?data: Array[untyped], ?verbose: bool) -> void
18
+ def initialize: (?data: Array[event], ?verbose: bool) -> void
19
19
  end
20
20
  end
@@ -1,21 +1,14 @@
1
1
  module Autoflux
2
2
  # The Stdio is a class to represent the standard input/output.
3
- class Stdio < IO
4
- @input: untyped
3
+ class Stdio
4
+ include _IO
5
5
 
6
- @output: untyped
6
+ @input: ::IO
7
+ @output: ::IO
8
+ @prompt: String?
7
9
 
8
- @prompt: untyped
10
+ attr_accessor prompt: String?
9
11
 
10
- attr_accessor prompt: untyped
11
-
12
- # @rbs input: IO
13
- # @rbs output: IO
14
- def initialize: (?input: untyped, ?output: untyped, ?prompt: untyped?) -> void
15
-
16
- def read: () -> untyped
17
-
18
- # @rbs data: String
19
- def write: (untyped data) -> untyped
12
+ def initialize: (?input: IO, ?output: IO, ?prompt: String?) -> void
20
13
  end
21
14
  end
@@ -1,35 +1,35 @@
1
1
  module Autoflux
2
2
  interface _Step
3
- def name: () -> String
3
+ def to_s: () -> String
4
4
  def call: (workflow: Workflow) -> untyped
5
5
  end
6
6
 
7
7
  module Step
8
- # The Step::Base is abstract class to represent the interface of the state
9
- class Base
10
- include Autoflux::_Step
11
- end
12
-
13
8
  # The Start step is used to start the workflow.
14
- class Start < Base
9
+ class Start
10
+ include Autoflux::_Step
15
11
  end
16
12
 
17
13
  # The Stop step is used to stop the workflow.
18
- class Stop < Base
14
+ class Stop
15
+ include Autoflux::_Step
19
16
  end
20
17
 
21
18
  # The Assistant state is used to call the agent.
22
- class Assistant < Base
19
+ class Assistant
20
+ include Autoflux::_Step
23
21
  OUTPUT_ROLE_NAME: "assistant"
24
22
  end
25
23
 
26
24
  # The Tool state is used to call the tools provided by the agent.
27
- class Tool < Base
28
- def run: (workflow: Workflow, tool: untyped) -> untyped
25
+ class Tool
26
+ include Autoflux::_Step
27
+ def run: (workflow: Workflow, invocation: invocation) -> ::_ToJson
29
28
  end
30
29
 
31
30
  # The Command step is used to get the user input.
32
- class Command < Base
31
+ class Command
32
+ include Autoflux::_Step
33
33
  EXIT_COMMAND: "exit"
34
34
  end
35
35
  end
@@ -1,20 +1,5 @@
1
1
  module Autoflux
2
2
  interface _Tool
3
- def name: () -> String
4
- def description: () -> String
5
- def parameters: () -> untyped
6
-
7
- def call: (**untyped) -> untyped
8
- end
9
-
10
- # The Tool is a abstract class to represent the adapter of tools which can be used by the Language Model.
11
- class Tool
12
- include _Tool
13
-
14
- @name: String
15
- @description: String
16
- @parameters: untyped
17
-
18
- def initialize: (name: String, description: String, ?parameters: untyped?) -> void
3
+ def call: (workflow: Workflow, params: untyped) -> untyped
19
4
  end
20
5
  end
@@ -1,15 +1,14 @@
1
1
  module Autoflux
2
2
  # The workflow is a state machine to manage the flow of agentic AI.
3
3
  class Workflow
4
+ include Enumerable[Workflow]
5
+
4
6
  @id: String
5
7
  @agent: _Agent
6
8
  @io: _IO
7
9
  @step: _Step
8
10
  @memory: _Memory
9
11
 
10
- # Generate a random UUID.
11
- #
12
- # @return [String]
13
12
  def self.next_id: () -> String
14
13
 
15
14
  attr_reader id: String
@@ -17,23 +16,11 @@ module Autoflux
17
16
  attr_reader memory: _Memory
18
17
  attr_reader io: _IO
19
18
 
20
- # @rbs state: State
21
19
  def initialize: (agent: _Agent, io: _IO, ?id: String?, ?step: _Step, ?memory: _Memory) -> void
22
-
23
- # Run the workflow.
24
- #
25
- # @rbs system_prompt: String?
26
- def run: (?system_prompt: String?) -> void
27
-
28
- # Stop the workflow.
20
+ def each: { (Workflow) -> void } -> void
21
+ def run: (?system_prompt: String?) ?{ (Workflow) -> void } -> void
29
22
  def stop: () -> void
30
-
31
- # Get the current step. If the step is nil, return a Stop step.
32
23
  def step: () -> _Step
33
-
34
- # Get the hash representation of the workflow.
35
- #
36
- # @return [Hash]
37
24
  def to_h: () -> { id: String, step: String }
38
25
  end
39
26
  end
data/sig/autoflux.rbs CHANGED
@@ -1,6 +1,11 @@
1
1
  module Autoflux
2
2
  VERSION: String
3
3
 
4
+ ROLE_SYSTEM: eventRole & "system"
5
+ ROLE_USER: eventRole & "user"
6
+ ROLE_TOOL: eventRole & "tool"
7
+ ROLE_ASSISTANT: eventRole & "assistant"
8
+
4
9
  class Error < StandardError
5
10
  end
6
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoflux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aotokitsuruya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight AI agent framework for Ruby
14
14
  email:
@@ -27,24 +27,21 @@ files:
27
27
  - Steepfile
28
28
  - commitlint.config.js
29
29
  - lib/autoflux.rb
30
- - lib/autoflux/agent.rb
31
- - lib/autoflux/io.rb
32
30
  - lib/autoflux/memory.rb
33
31
  - lib/autoflux/stdio.rb
34
32
  - lib/autoflux/step.rb
35
33
  - lib/autoflux/step/assistant.rb
36
- - lib/autoflux/step/base.rb
37
34
  - lib/autoflux/step/command.rb
38
35
  - lib/autoflux/step/start.rb
39
36
  - lib/autoflux/step/stop.rb
40
37
  - lib/autoflux/step/tool.rb
41
- - lib/autoflux/tool.rb
42
38
  - lib/autoflux/version.rb
43
39
  - lib/autoflux/workflow.rb
44
40
  - package-lock.json
45
41
  - package.json
46
42
  - sig/autoflux.rbs
47
43
  - sig/autoflux/agent.rbs
44
+ - sig/autoflux/event.rbs
48
45
  - sig/autoflux/io.rbs
49
46
  - sig/autoflux/memory.rbs
50
47
  - sig/autoflux/stdio.rbs
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Autoflux
4
- # The Agent is a abstract class to represent the adapter of the Language Model.
5
- class Agent
6
- # @rbs tools: Array<Tool>
7
- def initialize(tools: [])
8
- @_tools = tools
9
- end
10
-
11
- # @rbs name: String
12
- def tool?(name)
13
- @_tools.any? { |tool| tool.name == name }
14
- end
15
-
16
- # @rbs name: String
17
- def tool(name)
18
- @_tools.find { |tool| tool.name == name }
19
- end
20
-
21
- # @rbs memory: Memory?
22
- def call(**)
23
- raise NotImplementedError
24
- end
25
- end
26
- end
data/lib/autoflux/io.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Autoflux
4
- # The IO is abstract class to represent the interface of the IO
5
- class IO
6
- def read
7
- raise NotImplementedError
8
- end
9
-
10
- # @rbs data: String
11
- def write(_)
12
- raise NotImplementedError
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Autoflux
4
- module Step
5
- # The Step::Base is abstract class to represent the interface of the state
6
- class Base
7
- # @rbs workflow: Workflow
8
- def call(**)
9
- raise NotImplementedError
10
- end
11
-
12
- def name
13
- self.class.name || "Step"
14
- end
15
- end
16
- end
17
- end
data/lib/autoflux/tool.rb DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Autoflux
4
- # The Tool is a abstract class to represent the adapter of tools which can be used by the Language Model.
5
- class Tool
6
- attr_reader :name, :description, :parameters
7
-
8
- def initialize(name:, description:, parameters: nil)
9
- @name = name
10
- @description = description
11
- @parameters = parameters
12
- freeze
13
- end
14
-
15
- def call(**)
16
- raise NotImplementedError
17
- end
18
- end
19
- end