Class: Tavily::ResearchTask

Inherits:
Object
  • Object
show all
Includes:
Envelope
Defined in:
lib/tavily/responses.rb

Overview

A research task, returned by Client#research (status pending) and by Client#research_task / Client#wait_for_research (with the final result).

Instance Attribute Summary

Attributes inherited from Object

#attributes

Instance Method Summary collapse

Methods included from Envelope

#credits, included, #usage

Methods inherited from Object

#==, #[], attribute, #dig, #hash, #initialize, #inspect, #key?, #to_h

Constructor Details

This class inherits a constructor from Tavily::Object

Instance Method Details

#completed?Boolean

Returns whether the task finished successfully.

Returns:

  • (Boolean)

    whether the task finished successfully.



178
179
180
# File 'lib/tavily/responses.rb', line 178

def completed?
  status == "completed"
end

#contentString, ...

Returns the final report (String, or Hash when output_schema used).

Returns:

  • (String, Hash, nil)

    the final report (String, or Hash when output_schema used).



173
# File 'lib/tavily/responses.rb', line 173

attribute :content

#created_atString?

Returns creation timestamp (ISO 8601).

Returns:

  • (String, nil)

    creation timestamp (ISO 8601).



165
# File 'lib/tavily/responses.rb', line 165

attribute :created_at

#failed?Boolean

Returns whether the task failed.

Returns:

  • (Boolean)

    whether the task failed.



183
184
185
# File 'lib/tavily/responses.rb', line 183

def failed?
  status == "failed"
end

#inputString?

Returns echo of the research input.

Returns:

  • (String, nil)

    echo of the research input.



169
# File 'lib/tavily/responses.rb', line 169

attribute :input

#modelString?

Returns the model used (“mini”, “pro”, or resolved from “auto”).

Returns:

  • (String, nil)

    the model used (“mini”, “pro”, or resolved from “auto”).



171
# File 'lib/tavily/responses.rb', line 171

attribute :model

#pending?Boolean

Returns whether the task is still running or queued.

Returns:

  • (Boolean)

    whether the task is still running or queued.



188
189
190
# File 'lib/tavily/responses.rb', line 188

def pending?
  %w[pending in_progress].include?(status)
end

#request_idString?

Returns research task id (use to poll for results).

Returns:

  • (String, nil)

    research task id (use to poll for results).



163
# File 'lib/tavily/responses.rb', line 163

attribute :request_id

#sourcesArray<ResearchSource>

Returns sources used in the research.

Returns:



175
# File 'lib/tavily/responses.rb', line 175

attribute :sources, wrap: ResearchSource, collection: true

#statusString?

Returns one of “pending”, “in_progress”, “completed”, “failed”.

Returns:

  • (String, nil)

    one of “pending”, “in_progress”, “completed”, “failed”.



167
# File 'lib/tavily/responses.rb', line 167

attribute :status