Class: LLM::Mistral
- 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.
Defined Under Namespace
Modules: RequestAdapter
Constant Summary collapse
- HOST =
"api.mistral.ai"- BASE_PATH =
"/v1/"
Instance Method Summary collapse
- #audio ⇒ LLM::Mistral::Audio
-
#default_model ⇒ String
Returns the default model for chat completions.
-
#embed(input, model: "mistral-embed", **params) ⇒ LLM::Response
Provides an embedding.
- #files ⇒ Object
- #images ⇒ NotImplementedError
- #initialize(host: HOST, base_path: BASE_PATH) ⇒ LLM::Mistral constructor
- #moderations ⇒ Object
-
#name ⇒ Symbol
Returns the provider's name.
-
#ocr(image_url: nil, document_url: nil, model: "mistral-ocr-latest", **params) ⇒ LLM::Response
Runs OCR on a remote image or document URL.
- #responses ⇒ Object
- #vector_stores ⇒ Object
Methods inherited from OpenAI
#assistant_role, #complete, #models, #server_tools, #web_search
Methods included from OpenAI::RequestAdapter
Methods inherited from Provider
#assistant_role, #chat, #complete, #developer_role, #inspect, #interrupt!, #key?, #models, #request_owner, #respond, #schema, #server_tool, #server_tools, #system_role, #tool_role, #tracer, #tracer=, #user_role, #web_search, #with, #with_tracer
Constructor Details
#initialize(host: HOST, base_path: BASE_PATH) ⇒ LLM::Mistral
31 32 33 |
# File 'lib/llm/providers/mistral.rb', line 31 def initialize(host: HOST, base_path: BASE_PATH, **) super end |
Instance Method Details
#audio ⇒ LLM::Mistral::Audio
93 94 95 |
# File 'lib/llm/providers/mistral.rb', line 93 def audio raise NotImplementedError end |
#default_model ⇒ String
Returns the default model for chat completions
118 119 120 |
# File 'lib/llm/providers/mistral.rb', line 118 def default_model "mistral-large-latest" end |
#embed(input, model: "mistral-embed", **params) ⇒ LLM::Response
Provides an embedding.
55 56 57 |
# File 'lib/llm/providers/mistral.rb', line 55 def (input, model: "mistral-embed", **params) super end |
#files ⇒ Object
99 100 101 |
# File 'lib/llm/providers/mistral.rb', line 99 def files raise NotImplementedError end |
#images ⇒ NotImplementedError
44 45 46 |
# File 'lib/llm/providers/mistral.rb', line 44 def images raise NotImplementedError end |
#moderations ⇒ Object
105 106 107 |
# File 'lib/llm/providers/mistral.rb', line 105 def moderations raise NotImplementedError end |
#name ⇒ Symbol
Returns the provider's name
38 39 40 |
# File 'lib/llm/providers/mistral.rb', line 38 def name :mistral end |
#ocr(image_url: nil, document_url: nil, model: "mistral-ocr-latest", **params) ⇒ LLM::Response
Runs OCR on a remote image or document URL.
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/llm/providers/mistral.rb', line 72 def ocr(image_url: nil, document_url: nil, model: "mistral-ocr-latest", **params) if [image_url, document_url].all?(&:nil?) raise ArgumentError, "must provide one of: image_url, document_url" elsif [image_url, document_url].compact.size > 1 raise ArgumentError, "must provide one of: image_url, document_url" end document = parse_document(image_url, document_url) req = LLM::Transport::Request.post("/v1/ocr", headers) req.body = LLM.json.dump({model:, document:}.merge!(params)) res, = execute(request: req, operation: "ocr", model:) LLM::Response.new(res) end |
#responses ⇒ Object
87 88 89 |
# File 'lib/llm/providers/mistral.rb', line 87 def responses raise NotImplementedError end |
#vector_stores ⇒ Object
111 112 113 |
# File 'lib/llm/providers/mistral.rb', line 111 def vector_stores raise NotImplementedError end |