Class: OpenaiAssistant::Assistant::Retrieve

Inherits:
Base
  • Object
show all
Defined in:
lib/openai_assistant/clients/assistant/retrieve.rb

Overview

An openai assistant

Instance Method Summary collapse

Methods inherited from Base

#default_headers, #initialize

Constructor Details

This class inherits a constructor from OpenaiAssistant::Base

Instance Method Details

#retrieve_assistant(assistant_id) ⇒ OpenaiAssistant::Mapper::OpenaiAssistant

Returns A new response object of assistant.

Parameters:

  • assistant_id (String)

    The id of assistant after create

Returns:

  • (OpenaiAssistant::Mapper::OpenaiAssistant)

    A new response object of assistant.



9
10
11
12
13
14
15
16
# File 'lib/openai_assistant/clients/assistant/retrieve.rb', line 9

def retrieve_assistant(assistant_id)
  url = "#{@openai_url}/#{assistant_id}"
  uri = URI(url)
  response = @http_client.call_get(uri, default_headers)
  return OpenaiAssistant::ErrorResponse.from_json(response.body) unless response.code == "200"

  OpenaiAssistant::Mapper::Assistant.from_json(JSON.parse(response.body))
end