Class: Asimov::Client
- Inherits:
-
Object
- Object
- Asimov::Client
- Extended by:
- Forwardable
- Defined in:
- lib/asimov/client.rb
Overview
Asimov::Client is the main class which developers will use to interact with OpenAI.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#openai_api_base ⇒ Object
readonly
Returns the value of attribute openai_api_base.
-
#organization_id ⇒ Object
readonly
Returns the value of attribute organization_id.
-
#request_options ⇒ Object
readonly
Returns the value of attribute request_options.
Instance Method Summary collapse
-
#audio ⇒ Object
Use the audio method to access API calls in the /audio URI space.
-
#chat ⇒ Object
Use the chat method to access API calls in the /chat URI space.
-
#completions ⇒ Object
Use the completions method to access API calls in the /completions URI space.
-
#edits ⇒ Object
Use the edits method to access API calls in the /edits URI space.
-
#embeddings ⇒ Object
Use the embeddings method to access API calls in the /embeddings URI space.
-
#files ⇒ Object
Use the files method to access API calls in the /files URI space.
-
#finetunes ⇒ Object
Use the finetunes method to access API calls in the /fine-tunes URI space.
-
#images ⇒ Object
Use the images method to access API calls in the /images URI space.
-
#initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}, openai_api_base: nil) ⇒ Client
constructor
Creates a new Asimov::Client.
-
#models ⇒ Object
Use the models method to access API calls in the /models URI space.
-
#moderations ⇒ Object
Use the moderations method to access API calls in the /moderations URI space.
Constructor Details
#initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}, openai_api_base: nil) ⇒ Client
Creates a new Asimov::Client. Includes several optional named parameters:
api_key - The OpenAI API key that this Asimov::Client instance will use. If unspecified,
defaults to the application-wide configuration
organization_id - The OpenAI organization identifier that this Asimov::Client instance
will use. If unspecified, defaults to the application-wide configuration.
request_options - HTTParty request options that will be passed to the underlying network
client. Merges (and overrides) global configuration value.
openai_api_base - Custom base URI for the API calls made by this client. Defaults to global
configuration value.
39 40 41 42 43 44 45 46 47 |
# File 'lib/asimov/client.rb', line 39 def initialize(api_key: nil, organization_id: HeadersFactory::NULL_ORGANIZATION_ID, request_options: {}, openai_api_base: nil) @headers_factory = HeadersFactory.new(api_key, organization_id) @request_options = Asimov.configuration. .merge(Utils::RequestOptionsValidator.validate()) .freeze initialize_openai_api_base(openai_api_base) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
25 26 27 |
# File 'lib/asimov/client.rb', line 25 def api_key @api_key end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
25 26 27 |
# File 'lib/asimov/client.rb', line 25 def api_version @api_version end |
#openai_api_base ⇒ Object (readonly)
Returns the value of attribute openai_api_base.
25 26 27 |
# File 'lib/asimov/client.rb', line 25 def openai_api_base @openai_api_base end |
#organization_id ⇒ Object (readonly)
Returns the value of attribute organization_id.
25 26 27 |
# File 'lib/asimov/client.rb', line 25 def organization_id @organization_id end |
#request_options ⇒ Object (readonly)
Returns the value of attribute request_options.
25 26 27 |
# File 'lib/asimov/client.rb', line 25 def @request_options end |
Instance Method Details
#audio ⇒ Object
Use the audio method to access API calls in the /audio URI space.
53 54 55 |
# File 'lib/asimov/client.rb', line 53 def audio @audio ||= Asimov::ApiV1::Audio.new(client: self) end |
#chat ⇒ Object
Use the chat method to access API calls in the /chat URI space.
60 61 62 |
# File 'lib/asimov/client.rb', line 60 def chat @chat ||= Asimov::ApiV1::Chat.new(client: self) end |
#completions ⇒ Object
Use the completions method to access API calls in the /completions URI space.
67 68 69 |
# File 'lib/asimov/client.rb', line 67 def completions @completions ||= Asimov::ApiV1::Completions.new(client: self) end |
#edits ⇒ Object
Use the edits method to access API calls in the /edits URI space.
74 75 76 |
# File 'lib/asimov/client.rb', line 74 def edits @edits ||= Asimov::ApiV1::Edits.new(client: self) end |
#embeddings ⇒ Object
Use the embeddings method to access API calls in the /embeddings URI space.
81 82 83 |
# File 'lib/asimov/client.rb', line 81 def @embeddings ||= Asimov::ApiV1::Embeddings.new(client: self) end |
#files ⇒ Object
Use the files method to access API calls in the /files URI space.
88 89 90 |
# File 'lib/asimov/client.rb', line 88 def files @files ||= Asimov::ApiV1::Files.new(client: self) end |
#finetunes ⇒ Object
Use the finetunes method to access API calls in the /fine-tunes URI space.
95 96 97 |
# File 'lib/asimov/client.rb', line 95 def finetunes @finetunes ||= Asimov::ApiV1::Finetunes.new(client: self) end |
#images ⇒ Object
Use the images method to access API calls in the /images URI space.
102 103 104 |
# File 'lib/asimov/client.rb', line 102 def images @images ||= Asimov::ApiV1::Images.new(client: self) end |
#models ⇒ Object
Use the models method to access API calls in the /models URI space.
109 110 111 |
# File 'lib/asimov/client.rb', line 109 def models @models ||= Asimov::ApiV1::Models.new(client: self) end |
#moderations ⇒ Object
Use the moderations method to access API calls in the /moderations URI space.
116 117 118 |
# File 'lib/asimov/client.rb', line 116 def moderations @moderations ||= Asimov::ApiV1::Moderations.new(client: self) end |