From d528c6cd6fc9a810d9ab825b540a7f2a30839e9d Mon Sep 17 00:00:00 2001 From: Anthony Robin Date: Fri, 12 Jan 2024 10:32:35 +0100 Subject: [PATCH] Replace `safe_mode` by `safe_prompt` `safe_mode` attribute seems to have been replaced by `safe_prompt` in the last Mistral API version which results in a crash response: ``` API Error: 422 - {"object":"error","message":"{\"detail\":[{\"type\":\"extra_forbidden\",\"loc\":[\"body\",\"safe_mode\"],\"msg\":\"Extra inputs are not permitted\",\"input\":false,\"url\":\"https://errors.pydantic.dev/2.5/v/extra_forbidden\"}]}","type":"internal_error_proxy","param":null,"code":"1000"} ``` Replacing by `safe_prompt` fix the issue. Co-Authored-By @unplugandplay --- lib/mistral_rb.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mistral_rb.rb b/lib/mistral_rb.rb index d23d20d..508483e 100644 --- a/lib/mistral_rb.rb +++ b/lib/mistral_rb.rb @@ -20,7 +20,7 @@ def initialize(api_key: ENV["MISTRAL_API_KEY"], base_uri: "https://api.mistral.a self.class.base_uri base_uri end - def create_chat_completion(model:, messages:, temperature: 0.7, top_p: 1, max_tokens: nil, stream: false, safe_mode: false, random_seed: nil) + def create_chat_completion(model:, messages:, temperature: 0.7, top_p: 1, max_tokens: nil, stream: false, safe_prompt: false, random_seed: nil) body = { model: model, messages: messages, @@ -28,7 +28,7 @@ def create_chat_completion(model:, messages:, temperature: 0.7, top_p: 1, max_to top_p: top_p, max_tokens: max_tokens, stream: stream, - safe_mode: safe_mode, + safe_prompt: safe_prompt, random_seed: random_seed }.compact.to_json