lib/gen_ai/language.rb in gen-ai-0.3.2 vs lib/gen_ai/language.rb in gen-ai-0.4.0.alpha.1

- old
+ new

@@ -1,39 +1,19 @@ # frozen_string_literal: true +require 'forwardable' + module GenAI class Language + extend Forwardable + + def_delegators :@llm, :embed, :complete, :chat + def initialize(provider, token, options: {}) build_llm(provider, token, options) end - def embed(text, model: nil) - llm.embed(text, model: model) - end - - def complete(prompt, options = {}) - llm.complete(prompt, options: options) - end - - def chat(message, context: nil, history: [], examples: [], **options) - llm.chat(message, context: context, history: history, examples: examples, options: options) - end - - # def answer(prompt); end - - # def sentiment(text); end - - # def keywords(text); end - - # def summarization(text); end - - # def translation(text, _target:); end - - # def correction(text); end - private - - attr_reader :llm def build_llm(provider, token, options) klass = GenAI::Language.constants.find do |const| const.to_s.downcase == provider.to_s.downcase.gsub('_', '') end