Class: Llm::Functions::SwitchAssignee
- Includes:
- AttrReader
- Defined in:
- lib/llm/functions/switch_assignee.rb
Instance Attribute Summary collapse
-
#assignee ⇒ Object
readonly
Returns the value of attribute assignee.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
- #definition ⇒ Object
- #execute_and_generate_message(args) ⇒ Object
- #function_name ⇒ Object
-
#initialize(assignee, agents) ⇒ SwitchAssignee
constructor
A new instance of SwitchAssignee.
- #last_assignee ⇒ Object
- #last_message ⇒ Object
- #stop_llm_call? ⇒ Boolean
Constructor Details
#initialize(assignee, agents) ⇒ SwitchAssignee
Returns a new instance of SwitchAssignee.
11 12 13 14 15 16 |
# File 'lib/llm/functions/switch_assignee.rb', line 11 def initialize(assignee, agents) @messages = [] @assignee = assignee @agents = agents @valid_agents = agents.map(&:name_with_type) end |
Instance Attribute Details
#assignee ⇒ Object (readonly)
Returns the value of attribute assignee.
5 6 7 |
# File 'lib/llm/functions/switch_assignee.rb', line 5 def assignee @assignee end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
5 6 7 |
# File 'lib/llm/functions/switch_assignee.rb', line 5 def @messages end |
Instance Method Details
#definition ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/llm/functions/switch_assignee.rb', line 31 def definition # @assigneeに応じて毎回作り直す definition = { name: self.function_name, description: I18n.t("ghostest.functions.#{self.function_name}.description"), parameters: { type: :object, properties: { next_assignee: { type: :string, description: I18n.t("ghostest.functions.#{self.function_name}.parameters.next_assignee"), enum: @valid_agents - [@assignee.name_with_type], }, message: { type: :string, description: I18n.t("ghostest.functions.#{self.function_name}.parameters.message"), }, }, required: [:assignee, :message], }, } definition end |
#execute_and_generate_message(args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/llm/functions/switch_assignee.rb', line 55 def (args) if args[:next_assignee].nil? || args[:next_assignee].empty? raise Ghostest::Error.new("next_assignee is required") end if args[:message].nil? || args[:message].empty? raise Ghostest::Error.new("message is required") end next_assignee = @agents.find { |agent| agent.name_with_type == args[:next_assignee] } = { name: @assignee.name_with_type, next_assignee: next_assignee.name_with_type, message: args[:message], } @assignee = next_assignee @messages << end |
#function_name ⇒ Object
7 8 9 |
# File 'lib/llm/functions/switch_assignee.rb', line 7 def function_name :switch_assignee end |
#last_assignee ⇒ Object
27 28 29 |
# File 'lib/llm/functions/switch_assignee.rb', line 27 def last_assignee @messages.last[:name] end |
#last_message ⇒ Object
23 24 25 |
# File 'lib/llm/functions/switch_assignee.rb', line 23 def @messages.last[:message] end |
#stop_llm_call? ⇒ Boolean
18 19 20 21 |
# File 'lib/llm/functions/switch_assignee.rb', line 18 def stop_llm_call? # stop always true end |