Sha256: eeeab54d1bb048cc30dea4f2b1ef59489c87788532d6bf7410441c976b8d5c06

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

module Bristow
  module Agencies
    class Supervisor < Agency
      attr_accessor :supervisor

      def self.create(agents: [])
        agency = new(agents: agents)
        supervisor = Agents::Supervisor.new(
          available_agents: agents,
          agency: agency
        )
        agency.supervisor = supervisor
        agency.agents << supervisor
        agency
      end

      def initialize(agents: [])
        @agents = agents
        @supervisor = nil  # Will be set by create
      end

      def chat(messages, &block)
        raise "No supervisor set" unless supervisor

        # Convert string message to proper format
        messages = [{ role: "user", content: messages }] if messages.is_a?(String)
        
        # Convert array of strings to proper format
        messages = messages.map { |msg| msg.is_a?(String) ? { role: "user", content: msg } : msg } if messages.is_a?(Array)

        supervisor.chat(messages, &block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bristow-0.1.0 lib/bristow/agencies/supervisor.rb