<commit_before>module DismalTony # :nodoc:
  # The essential class. A VI, or Virtual Intelligence,
  # forms the basis for the DismalTony gem, and is your conversational agents for handling queries
  class VIBase
    # The name of the Intelligence
    attr_reader :name
    # A DialogInterface object representing where to route the VI's speech
    attr_reader :return_interface
    # An Array of QueryHandler objects that the VI can use
    attr_reader :directives
    # A DataStore object representing the VI's memory and userspace
    attr_reader :data_store
    attr_reader :user
    # the Scheduler object for executing timed tasks
    attr_reader :scheduler

    # Options for +opts+
    # * +:name+ - The name for the VI. Defaults to 'Tony'
    # * +:directives+ - The Array of directives. Defaults to the entire contents of the HandlerRegistry.
    # * +:data_store+ - The data store to use with this VI. Defaults to a generic DataStore object.
    # * +:return_interface+ - The interface to route conversation back through. Defaults to the ConsoleInterface.
    def initialize(**opts)
      @name = (opts[:name] || 'Tony'.freeze)
      @return_interface = (opts[:return_interface] || DismalTony::ConsoleInterface.new)
      @directives = (opts[:directives] || DismalTony::Directives.all)
      @data_store = (opts[:data_store] || DismalTony::DataStore.new(vi_name: name))
      @user = (@data_store.users.find { |u| u == opts[:user]} || DismalTony::UserIdentity::DEFAULT)
    end

    # Sends the message +str+ back through the DialogInterface +interface+, after calling DismalTony::Formatter.format on it.
    def say_through(interface, str)
      interface.send(DismalTony::Formatter.format(str, {}))
    end

    # Sends the message +str+ back through the DialogInterface +interface+, after calling DismalTony::Formatter.format on it, with the options +opts+
    def say_opts(interface, str, opts)
      interface.send(DismalTony::Formatter.format(str, opts))
    end

    # Simplest dialog function. Sends the message +str+ back through VIBase.return_interface
    def say(str)
      return_interface.send(DismalTony::Formatter.format(str))
    end

    def call(q)
      result = QueryResolver.(q, self)
      say result.response.outgoing_message unless result.response.format[:silent]
      @user.modify_state!(result.user.state)
      result      
    end
  end
end<commit_msg>More fixes to VI_Base#call<commit_after>module DismalTony # :nodoc:
  # The essential class. A VI, or Virtual Intelligence,
  # forms the basis for the DismalTony gem, and is your conversational agents for handling queries
  class VIBase
    # The name of the Intelligence
    attr_reader :name
    # A DialogInterface object representing where to route the VI's speech
    attr_reader :return_interface
    # An Array of QueryHandler objects that the VI can use
    attr_reader :directives
    # A DataStore object representing the VI's memory and userspace
    attr_reader :data_store
    attr_reader :user
    # the Scheduler object for executing timed tasks
    attr_reader :scheduler

    # Options for +opts+
    # * +:name+ - The name for the VI. Defaults to 'Tony'
    # * +:directives+ - The Array of directives. Defaults to the entire contents of the HandlerRegistry.
    # * +:data_store+ - The data store to use with this VI. Defaults to a generic DataStore object.
    # * +:return_interface+ - The interface to route conversation back through. Defaults to the ConsoleInterface.
    def initialize(**opts)
      @name = (opts[:name] || 'Tony'.freeze)
      @return_interface = (opts[:return_interface] || DismalTony::ConsoleInterface.new)
      @directives = (opts[:directives] || DismalTony::Directives.all)
      @data_store = (opts[:data_store] || DismalTony::DataStore.new(vi_name: name))
      @user = (@data_store.users.find { |u| u == opts[:user]} || DismalTony::UserIdentity::DEFAULT)
    end

    # Sends the message +str+ back through the DialogInterface +interface+, after calling DismalTony::Formatter.format on it.
    def say_through(interface, str)
      interface.send(DismalTony::Formatter.format(str, {}))
    end

    # Sends the message +str+ back through the DialogInterface +interface+, after calling DismalTony::Formatter.format on it, with the options +opts+
    def say_opts(interface, str, opts)
      interface.send(DismalTony::Formatter.format(str, opts))
    end

    # Simplest dialog function. Sends the message +str+ back through VIBase.return_interface
    def say(str)
      return_interface.send(DismalTony::Formatter.format(str))
    end

    def call(q)
      result = QueryResolver.(q, self)
      say result.response.outgoing_message unless result.response.format[:silent]
      @user.modify_state!(result.query.user.state)
      result      
    end
  end
end
{'fraction_non_alphanumeric': 0.09323621227887617, 'fraction_numerical': 0.0, 'mean_word_length': 3.7071498530852107, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4088773', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1367, 'n_words': 456}