Class: LLM::Mistral

Inherits:
OpenAI show all
Includes:
Mistral::RequestAdapter
Defined in:
lib/llm/providers/mistral.rb,
lib/llm/providers/mistral/request_adapter.rb

Overview

The Mistral class implements a provider for Mistral through its OpenAI-compatible API.

Examples:

#!/usr/bin/env ruby
require "llm"

llm = LLM.mistral(key: ENV["KEY"])
ctx = LLM::Context.new(llm)
ctx.talk "Hello"
ctx.messages.select(&:assistant?).each { print "[#{_1.role}]", _1.content, "\n" }

Defined Under Namespace

Modules: RequestAdapter

Constant Summary collapse

HOST =
"api.mistral.ai"
BASE_PATH =
"/v1/"

Instance Method Summary collapse

Methods inherited from OpenAI

#assistant_role, #complete, #models, #server_tools, #web_search

Methods included from OpenAI::RequestAdapter

#adapt

Methods inherited from Provider

#assistant_role, #chat, #complete, #developer_role, #inspect, #interrupt!, #key?, #models, #request_owner, #respond, #schema, #server_tool, #server_tools, #streamable?, #system_role, #tool_role, #tracer, #tracer=, #user_role, #web_search, #with, #with_tracer

Constructor Details

#initialize(host: HOST, base_path: BASE_PATH) ⇒ LLM::Mistral

Parameters:

  • key (String, nil)

    The secret key for authentication

  • host (String) (defaults to: HOST)

    The host address of the LLM provider

  • base_path (String) (defaults to: BASE_PATH)

    Optional base path prefix for HTTP API routes.



31
32
33
# File 'lib/llm/providers/mistral.rb', line 31

def initialize(host: HOST, base_path: BASE_PATH, **)
  super
end

Instance Method Details

#audioLLM::Mistral::Audio

Returns:

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/llm/providers/mistral.rb', line 67

def audio
  raise NotImplementedError
end

#default_modelString

Returns the default model for chat completions

Returns:

  • (String)


92
93
94
# File 'lib/llm/providers/mistral.rb', line 92

def default_model
  "mistral-large-latest"
end

#embed(input, model: "mistral-embed", **params) ⇒ LLM::Response

Provides an embedding.

Parameters:

  • input (String, Array<String>)

    The input to embed

  • model (String) (defaults to: "mistral-embed")

    The embedding model to use

  • params (Hash)

    Other embedding parameters

Returns:



55
56
57
# File 'lib/llm/providers/mistral.rb', line 55

def embed(input, model: "mistral-embed", **params)
  super
end

#filesObject

Raises:

  • (NotImplementedError)


73
74
75
# File 'lib/llm/providers/mistral.rb', line 73

def files
  raise NotImplementedError
end

#imagesNotImplementedError

Returns:

  • (NotImplementedError)

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/llm/providers/mistral.rb', line 44

def images
  raise NotImplementedError
end

#moderationsObject

Raises:

  • (NotImplementedError)


79
80
81
# File 'lib/llm/providers/mistral.rb', line 79

def moderations
  raise NotImplementedError
end

#nameSymbol

Returns the provider's name

Returns:

  • (Symbol)

    Returns the provider's name



38
39
40
# File 'lib/llm/providers/mistral.rb', line 38

def name
  :mistral
end

#responsesObject

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/llm/providers/mistral.rb', line 61

def responses
  raise NotImplementedError
end

#vector_storesObject

Raises:

  • (NotImplementedError)


85
86
87
# File 'lib/llm/providers/mistral.rb', line 85

def vector_stores
  raise NotImplementedError
end