Skip to content

Commit 4eed98d

Browse files
committed
chore(mistral): Update Mistral provider files and remove outdated VCR cassettes
- Refactored the chat provider to be closer to the other implementations. - No longer ignoring specs except custom dimensions. - Refactored error message formatting in the Mistral provider. - Mistral (small) may hallucinate tools which explains previous failures. Added robustness for that. - Updated chat and streaming files to include necessary modules and methods. - Removed outdated VCR cassettes related to Mistral functionality. - Updated test fixtures to reflect changes in API responses and model handling. - Added frozen string literal to Mistral provider files for performance.
1 parent 4290b8c commit 4eed98d

File tree

42 files changed

+641
-5089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+641
-5089
lines changed

lib/ruby_llm/providers/mistral.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module RubyLLM
24
module Providers
35
# Mistral API integration. Handles chat completion, embeddings,
@@ -36,24 +38,24 @@ def parse_error(response)
3638

3739
body = try_parse_json(response.body)
3840
error_message = case body
39-
when Hash
40-
# Check for standard { detail: [{ msg: ... }] } structure
41-
if body['detail'].is_a?(Array)
42-
body['detail'].map { |err| err['msg'] }.join("; ")
43-
# Check for simple { message: ... } structure (some Mistral errors use this)
44-
elsif body['message']
45-
body['message']
46-
# Fallback for other hash structures
47-
else
48-
body.to_s
49-
end
50-
else
51-
body.to_s # Return raw body if not a hash
52-
end
41+
when Hash
42+
# Check for standard { detail: [{ msg: ... }] } structure
43+
if body['detail'].is_a?(Array)
44+
body['detail'].map { |err| err['msg'] }.join('; ')
45+
# Check for simple { message: ... } structure (some Mistral errors use this)
46+
elsif body['message']
47+
body['message']
48+
# Fallback for other hash structures
49+
else
50+
body.to_s
51+
end
52+
else
53+
body.to_s # Return raw body if not a hash
54+
end
5355

5456
# Format the error message
5557
if error_message.include?('Input should be a valid')
56-
"Invalid message format: The message content is not properly formatted"
58+
'Invalid message format: The message content is not properly formatted'
5759
else
5860
error_message
5961
end

0 commit comments

Comments
 (0)