Class: OpenAI::Models::Responses::FunctionTool

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/responses/function_tool.rb,
sig/openai/models/responses/function_tool.rbs

Defined Under Namespace

Modules: AllowedCaller

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_cached, coerce_with_error, #dump, dump, #inspect, inspect, meta_info, new_coerce_state, resolve_type, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize ⇒ FunctionTool

Returns a new instance of FunctionTool.

Parameters:

  • name —

    The name of the function to call.

  • parameters —

    A JSON schema object describing the parameters of the function.

  • strict —

    Whether strict parameter validation is enforced for this function tool.

  • allowed_callers —

    The tool invocation context(s).

  • defer_loading —

    Whether this function is deferred and loaded via tool search.

  • description —

    A description of the function. Used by the model to determine whether or not to call the function.

  • output_schema —

    A JSON schema object describing the JSON value encoded in string outputs for this function.

  • type —

    The type of the function tool. Always function.

  • name: (String)
  • parameters: (::Hash[Symbol, top], nil)
  • strict: (Boolean, nil)
  • allowed_callers: (::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller], nil)
  • async: (Boolean)
  • defer_loading: (Boolean)
  • description: (String, nil)
  • output_schema: (::Hash[Symbol, top], nil)
  • type: (:function)


69
70
71
72
73
74
75
76
77
78
79
# File 'sig/openai/models/responses/function_tool.rbs', line 69

def initialize: (
  name: String,
  parameters: ::Hash[Symbol, top]?,
  strict: bool?,
  ?allowed_callers: ::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller]?,
  ?async: bool,
  ?defer_loading: bool,
  ?description: String?,
  ?output_schema: ::Hash[Symbol, top]?,
  ?type: :function
) -> void

Instance Attribute Details

#allowed_callers ⇒ ::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller]?

The tool invocation context(s).

Returns:

  • (::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller], nil)


44
45
46
47
48
# File 'lib/openai/models/responses/function_tool.rb', line 44

optional(
  :allowed_callers,
  -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Responses::FunctionTool::AllowedCaller] },
  nil?: true
)

#async ⇒ Boolean?

Parameters:

Returns:



53
# File 'lib/openai/models/responses/function_tool.rb', line 53

optional :async, OpenAI::Internal::Type::Boolean

#defer_loading ⇒ Boolean?

Whether this function is deferred and loaded via tool search.

Returns:



59
# File 'lib/openai/models/responses/function_tool.rb', line 59

optional :defer_loading, OpenAI::Internal::Type::Boolean

#description ⇒ String?

A description of the function. Used by the model to determine whether or not to call the function.

Returns:

  • (String, nil)


66
# File 'lib/openai/models/responses/function_tool.rb', line 66

optional :description, String, nil?: true

#name ⇒ String

The name of the function to call.

Returns:

  • (String)


11
# File 'lib/openai/models/responses/function_tool.rb', line 11

required :name, String

#output_schema ⇒ ::Hash[Symbol, top]?

A JSON schema object describing the JSON value encoded in string outputs for this function.

Returns:

  • (::Hash[Symbol, top], nil)


73
# File 'lib/openai/models/responses/function_tool.rb', line 73

optional :output_schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown], nil?: true

#parameters ⇒ ::Hash[Symbol, top]?

A JSON schema object describing the parameters of the function.

Returns:

  • (::Hash[Symbol, top], nil)


17
18
19
20
21
22
23
24
25
26
# File 'lib/openai/models/responses/function_tool.rb', line 17

required(
  :parameters,
  union: -> {
    OpenAI::UnionOf[
      OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown],
      OpenAI::StructuredOutput::JsonSchemaConverter
    ]
  },
  nil?: true
)

#strict ⇒ Boolean?

Whether strict parameter validation is enforced for this function tool.

Returns:



32
# File 'lib/openai/models/responses/function_tool.rb', line 32

required :strict, OpenAI::Internal::Type::Boolean, nil?: true

#type ⇒ :function

The type of the function tool. Always function.

Returns:

  • (:function)


38
# File 'lib/openai/models/responses/function_tool.rb', line 38

required :type, const: :function

Instance Method Details

#to_hash ⇒ { name: String, parameters: ::Hash[Symbol, top]?, strict: bool?, ?type: :function, ?allowed_callers: ::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller]?, ?async: bool, ?defer_loading: bool, ?description: String?, ?output_schema: ::Hash[Symbol, top]? }

Returns:

  • ({ name: String, parameters: ::Hash[Symbol, top]?, strict: bool?, ?type: :function, ?allowed_callers: ::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller]?, ?async: bool, ?defer_loading: bool, ?description: String?, ?output_schema: ::Hash[Symbol, top]? })


81
82
83
84
85
86
87
88
89
90
91
# File 'sig/openai/models/responses/function_tool.rbs', line 81

def to_hash: -> {
  name: String,
  parameters: ::Hash[Symbol, top]?,
  strict: bool?,
  ?type: :function,
  ?allowed_callers: ::Array[OpenAI::Models::Responses::FunctionTool::allowed_caller]?,
  ?async: bool,
  ?defer_loading: bool,
  ?description: String?,
  ?output_schema: ::Hash[Symbol, top]?
}