Module: OxAiWorkers

Defined in:
lib/oxaiworkers/tool_definition.rb,
lib/ox-ai-workers.rb,
lib/oxaiworkers/engine.rb,
lib/oxaiworkers/request.rb,
lib/oxaiworkers/version.rb,
lib/oxaiworkers/iterator.rb,
lib/oxaiworkers/load_i18n.rb,
lib/oxaiworkers/tool/eval.rb,
lib/oxaiworkers/state_batch.rb,
lib/oxaiworkers/state_tools.rb,
lib/oxaiworkers/state_helper.rb,
lib/oxaiworkers/tool/database.rb,
lib/oxaiworkers/module_request.rb,
lib/oxaiworkers/present_compat.rb,
lib/oxaiworkers/assistant/coder.rb,
lib/oxaiworkers/assistant/sysop.rb,
lib/oxaiworkers/delayed_request.rb,
lib/oxaiworkers/tool/file_system.rb,
lib/oxaiworkers/contextual_logger.rb,
lib/oxaiworkers/dependency_helper.rb,
lib/oxaiworkers/assistant/localizer.rb,
lib/oxaiworkers/assistant/module_base.rb

Overview

Extends a class to be used as a tool in the assistant. A tool is a collection of functions (methods) used to perform specific tasks.

Usage

  1. Extend your class with ToolDefinition

  2. Use #define_function to define each function of the tool

Key Concepts

  • #define_function: Defines a new function (method) for the tool

  • ParameterBuilder#property: Defines properties for the function parameters

  • ParameterBuilder#item: Alias for ParameterBuilder#property, used for array items

These methods support various data types and nested structures, allowing for flexible and expressive tool definitions.

Examples:

Defining a tool with various property types and configurations

define_function :sample_function, description: "Demonstrates various property types and configurations" do
  property :string_prop, type: "string", description: "A simple string property"
  property :number_prop, type: "number", description: "A number property"
  property :integer_prop, type: "integer", description: "An integer property"
  property :boolean_prop, type: "boolean", description: "A boolean property"
  property :enum_prop, type: "string", description: "An enum property", enum: ["option1", "option2", "option3"]
  property :required_prop, type: "string", description: "A required property", required: true
  property :array_prop, type: "array", description: "An array property" do
    item type: "string", description: "Array item"
  end
  property :object_prop, type: "object", description: "An object property" do
    property :nested_string, type: "string", description: "Nested string property"
    property :nested_number, type: "number", description: "Nested number property"
  end
end

Defined Under Namespace

Modules: Assistant, CamelizeCompat, DependencyHelper, LoadI18n, PresentCompat, StateHelper, Tool, ToolDefinition Classes: Configuration, ConfigurationError, ContextualLogger, DelayedRequest, Engine, Error, Iterator, ModuleRequest, Request, StateBatch, StateTools

Constant Summary collapse

DEFAULT_MODEL =
'gpt-4o-mini'
DEFAULT_MAX_TOKEN =
4096
DEFAULT_TEMPERATURE =
0.7
VERSION =
'0.7.4'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



75
76
77
# File 'lib/ox-ai-workers.rb', line 75

def self.configuration
  @configuration ||= OxAiWorkers::Configuration.new
end

.loggerObject

Returns the value of attribute logger.



64
65
66
# File 'lib/ox-ai-workers.rb', line 64

def logger
  @logger
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



79
80
81
# File 'lib/ox-ai-workers.rb', line 79

def self.configure
  yield(configuration)
end