Class: InstLLM::Client
- Inherits:
-
Object
- Object
- InstLLM::Client
- Defined in:
- lib/inst_llm/client.rb
Constant Summary collapse
- MODELS =
{ "anthropic.claude-3-sonnet-20240229-v1:0": { format: :claude, provider: :bedrock, type: :chat }, "anthropic.claude-3-haiku-20240307-v1:0": { format: :claude, provider: :bedrock, type: :chat }, "mistral.mistral-7b-instruct-v0:2": { format: :mistral, provider: :bedrock, type: :chat }, "mistral.mixtral-8x7b-instruct-v0:1": { format: :mistral, provider: :bedrock, type: :chat }, "mistral.mistral-large-2402-v1:0": { format: :mistral, provider: :bedrock, type: :chat }, "cohere.embed-english-v3": { format: :cohere_embed, provider: :bedrock, type: :embedding }, "cohere.embed-multilingual-v3": { format: :cohere_embed, provider: :bedrock, type: :embedding }, }.freeze
Instance Method Summary collapse
- #chat(messages, **options) ⇒ Object
- #embedding(message, **options) ⇒ Object
-
#initialize(model, **options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(model, **options) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 |
# File 'lib/inst_llm/client.rb', line 23 def initialize(model, **) model = model.to_sym raise UnknownArgumentError unless MODELS.key?(model) @model = model @options = end |
Instance Method Details
#chat(messages, **options) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/inst_llm/client.rb', line 31 def chat(, **) model = ([:model] || [:model_id] || @model).to_sym raise ArgumentError, "Model #{model} is not a chat model" unless chat_model?(model) response_factory(model, call(model, , **)) end |
#embedding(message, **options) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/inst_llm/client.rb', line 38 def (, **) model = ([:model] || [:model_id] || @model).to_sym raise ArgumentError, "Model #{model} is not an embedding model" unless (model) (model, call(model, , **)) end |