lib/omniai/client.rb in omniai-0.0.1 vs lib/omniai/client.rb in omniai-0.0.2

- old
+ new

@@ -1,27 +1,38 @@ # frozen_string_literal: true -# Usage: -# -# require "omniai" -# require "omniai-anthropic" -# require "omniai-google" -# require "omniai-mistral" -# require "omniai-openai" -# -# anthropic = OmniAI::Anthropic.new(api_key: ENV.fetch("OPENAI_API_KEY")) -# google = OmniAI::Google.new(api_key: ENV.fetch("OPENAI_API_KEY")) -# mistral = OmniAI::Mistral.new(api_key: ENV.fetch("OPENAI_API_KEY")) -# openai = OmniAI::OpenAI.new(api_key: ENV.fetch("OPENAI_API_KEY")) +module OmniAI + # An abstract class that must be subclassed (e.g. OmniAI::OpenAI::Client). + # + # Usage: + # + # class OmniAI::OpenAI::Client < OmniAI::Client + # def initialize(api_key: ENV.fetch('OPENAI_API_KEY')) + # super + # end + # + # @return [OmniAI::OpenAI::Chat] + # def chat + # # TODO: implement + # end + # end + class Client + class Error < StandardError; end -module OmniAI::Client - class Error < StandardError; end + attr_accessor :api_key - # @param api_key [String] The API key to use for requests - def initialize(api_key:) - @api_key = api_key - end + # @param api_key [String] + def initialize(api_key:) + @api_key = api_key + end - def http - HTTP.auth("Bearer #{@api_key}") + # @return [HTTP::Client] + def connection + HTTP.auth("Bearer #{api_key}") + end + + # @return [OmniAI::Chat] an instance of OmniAI::Chat + def chat + raise NotImplementedError, "#{self.class.name}#chat undefined" + end end end