Sha256: 36fdaaeba3192b0a676532a09adceb7167133b21f48452909545aead7668802a

Contents?: true

Size: 994 Bytes

Versions: 1

Compression:

Stored size: 994 Bytes

Contents

# frozen_string_literal: true

module OpenaiAsissistant
  module Assistant
    # An openai assistant
    class Create < Base
      # @param model [String] Select model of the assistant. refer on: https://platform.openai.com/docs/api-reference/models/list.
      # @param instructions [String] The system instructions that the assistant uses.
      # @return [OpenaiAsissistant::Mapper::Assistant] A new response object of assistant.
      def create_assistant(model, instructions)
        url = URI.parse(@openai_url)
        req_body = {
          "instructions": instructions,
          "name": "assistant",
          "tools": [{ "type": "code_interpreter" }],
          "model": model
        }.to_json
        response = @http_client.call_post(url, req_body, default_headers)
        return OpenaiAsissistant::ErrorResponse.from_json(response.body) unless response.code == "200"

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openai-assistant-1.0.0 lib/openai_assistant/clients/assistant/create.rb