Sha256: 2307e41103d13bcd789ca5b698222c257ba0c0860d61170421f04a509a9766af
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true module AI21 class Client include AI21::Helper extend AI21::HTTP DEFALUT_COMPLETE_MODEL = "j2-grande" DEFAULT_INSTRUCT_MODEL = "j2-grande-instruct" def initialize(access_token) AI21.configuration.access_token = access_token if access_token end def complete(prompt, options = {}) model = options.delete(:model) || DEFALUT_COMPLETE_MODEL AI21::Client.post("/#{model}/complete", {prompt: prompt}.merge(snake_to_camel(options))) end def instruct(prompt, options = {}) model = options.delete(:model) || DEFAULT_INSTRUCT_MODEL AI21::Client.post("/#{model}/complete", {prompt: prompt}.merge(snake_to_camel(options))) end def paraphrase(prompt, options = {}) AI21::Client.post("/paraphrase", {text: prompt}.merge(snake_to_camel(options))) end def correct(prompt) AI21::Client.post("/gec", {text: prompt}) end def improvements(prompt, types, options = {}) AI21::Client.post("/improvements", {text: prompt, types: types}.merge(snake_to_camel(options))) end def summarize(prompt, source_type, options = {}) AI21::Client.post("/summarize", {source: prompt, sourceType: source_type}.merge(snake_to_camel(options))) end def segmentation(prompt, source_type, options = {}) AI21::Client.post("/segmentation", {source: prompt, sourceType: source_type}.merge(snake_to_camel(options))) end def answer(question, context) AI21::Client.post("/experimental/answer", {question: question, context: context}) end def dataset @dataset ||= AI21::Dataset.new end def custom_model @custom_model ||= AI21::CustomModel.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ai21-0.1.0 | lib/ai21/client.rb |