lib/gen_ai/language/base.rb in gen-ai-0.1.0 vs lib/gen_ai/language/base.rb in gen-ai-0.2.0

- old
+ new

@@ -1,12 +1,10 @@ # frozen_string_literal: true module GenAI class Language - class Base - include GenAI::Dependency - + class Base < GenAI::Base DEFAULT_ROLE = 'user' def embed(...) raise NotImplementedError, "#{self.class.name} does not support embedding" end @@ -15,32 +13,9 @@ raise NotImplementedError, "#{self.class.name} does not support completion" end def chat(...) raise NotImplementedError, "#{self.class.name} does not support conversations" - end - - private - - attr_reader :client - - def handle_errors - response = yield - return if response.empty? - - if response['error'] - raise GenAI::ApiError, "#{api_provider_name} API error: #{response.dig('error', 'message')}" - end - - response - end - - def api_provider_name - self.class.name.split('::').last - end - - def build_result(model:, raw:, parsed:) - GenAI::Result.new(provider: @provider, model: model, raw: raw, values: parsed) end end end end