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 }, "anthropic.claude-3-opus-20240229-v1:0": { format: :claude, provider: :bedrock, type: :chat }, "meta.llama3-8b-instruct-v1:0": { format: :llama3, provider: :bedrock, type: :chat }, "meta.llama3-70b-instruct-v1:0": { format: :llama3, 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.
27 28 29 30 31 32 33 |
# File 'lib/inst_llm/client.rb', line 27 def initialize(model, **) model = model.to_sym raise UnknownArgumentError unless MODELS.key?(model) @model = model @options = end |
Instance Method Details
#chat(messages, **options) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/inst_llm/client.rb', line 35 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
42 43 44 45 46 47 |
# File 'lib/inst_llm/client.rb', line 42 def (, **) model = ([:model] || [:model_id] || @model).to_sym raise ArgumentError, "Model #{model} is not an embedding model" unless (model) (model, call(model, , **)) end |