Sha256: 116b18118dc576d0acaf57cf1ff7050c5090e5368287924cb9216c6aeb9ce79c
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true module GenAI class Language class Base include GenAI::Dependency DEFAULT_ROLE = 'user' def embed(...) raise NotImplementedError, "#{self.class.name} does not support embedding" end def complete(...) 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gen-ai-0.1.0 | lib/gen_ai/language/base.rb |