Class: Langchain::LLM::AI21
Overview
Constant Summary collapse
- DEFAULTS =
{ temperature: 0.0, model: "j2-ultra" }.freeze
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#complete(prompt:, **params) ⇒ Langchain::LLM::AI21Response
Generate a completion for a given prompt.
-
#initialize(api_key:, default_options: {}) ⇒ AI21
constructor
A new instance of AI21.
-
#summarize(text:, **params) ⇒ String
Generate a summary for a given text.
Methods inherited from Base
#chat, #chat_parameters, #default_dimension, #default_dimensions, #embed
Methods included from DependencyHelper
Constructor Details
#initialize(api_key:, default_options: {}) ⇒ AI21
Returns a new instance of AI21.
19 20 21 22 23 24 25 26 |
# File 'lib/langchain/llm/ai21.rb', line 19 def initialize(api_key:, default_options: {}) Langchain.logger.warn "DEPRECATED: `Langchain::LLM::AI21` is deprecated, and will be removed in the next major version. Please use another LLM provider." depends_on "ai21" @client = ::AI21::Client.new(api_key) @defaults = DEFAULTS.merge() end |
Instance Method Details
#complete(prompt:, **params) ⇒ Langchain::LLM::AI21Response
Generate a completion for a given prompt
35 36 37 38 39 40 |
# File 'lib/langchain/llm/ai21.rb', line 35 def complete(prompt:, **params) parameters = complete_parameters params response = client.complete(prompt, parameters) Langchain::LLM::AI21Response.new response, model: parameters[:model] end |
#summarize(text:, **params) ⇒ String
Generate a summary for a given text
49 50 51 52 53 |
# File 'lib/langchain/llm/ai21.rb', line 49 def summarize(text:, **params) response = client.summarize(text, "TEXT", params) response.dig(:summary) # Should we update this to also return a Langchain::LLM::AI21Response? end |