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/tool/pixels.rb,
lib/oxaiworkers/state_helper.rb,
lib/oxaiworkers/tool/wolfram.rb,
lib/oxaiworkers/tool/database.rb,
lib/oxaiworkers/tool/pipeline.rb,
lib/oxaiworkers/image_iterator.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/models/llm_base.rb,
lib/oxaiworkers/assistant/expert.rb,
lib/oxaiworkers/tool/file_system.rb,
lib/oxaiworkers/assistant/painter.rb,
lib/oxaiworkers/contextual_logger.rb,
lib/oxaiworkers/dependency_helper.rb,
lib/oxaiworkers/models/gemini_pro.rb,
lib/oxaiworkers/models/openai_max.rb,
lib/oxaiworkers/models/images_base.rb,
lib/oxaiworkers/models/openai_mini.rb,
lib/oxaiworkers/models/openai_nano.rb,
lib/oxaiworkers/assistant/localizer.rb,
lib/oxaiworkers/models/deepseek_max.rb,
lib/oxaiworkers/models/anthropic_max.rb,
lib/oxaiworkers/models/openai_dalle3.rb,
lib/oxaiworkers/assistant/module_base.rb,
lib/oxaiworkers/models/openai_whisper.rb,
lib/oxaiworkers/assistant/orchestrator.rb,
lib/oxaiworkers/models/openai_gpt_image.rb,
lib/oxaiworkers/models/stability_images.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, Models, PresentCompat, StateHelper, Tool, ToolDefinition Classes: Configuration, ConfigurationError, ContextualLogger, DelayedRequest, Engine, Error, ImageIterator, Iterator, ModuleRequest, Request, StateBatch, StateTools

Constant Summary collapse

DEFAULT_MAX_TOKEN =
4096
VERSION =
'1.1.6'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



98
99
100
# File 'lib/ox-ai-workers.rb', line 98

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

.default_modelObject

Returns the value of attribute default_model.



87
88
89
# File 'lib/ox-ai-workers.rb', line 87

def default_model
  @default_model
end

.loggerObject

Returns the value of attribute logger.



86
87
88
# File 'lib/ox-ai-workers.rb', line 86

def logger
  @logger
end

Class Method Details

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

Yields:



102
103
104
# File 'lib/ox-ai-workers.rb', line 102

def self.configure
  yield(configuration)
end