Skip to content

Commit

Permalink
Add safety handling to google model
Browse files Browse the repository at this point in the history
  • Loading branch information
michalwarda committed Feb 24, 2024
1 parent c7b24bd commit 6f09ce9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/api/lib/buildel/langchain/chat_google_ai.ex
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,17 @@ defmodule Buildel.LangChain.ChatModels.ChatGoogleAI do
)
end

def do_process_response(%{"finishReason" => "SAFETY", "index" => index}, message_type) do
do_process_response(
%{
"finishReason" => "DOESNOTMATTER",
"content" => %{"role" => "model", "parts" => [%{"text" => "Safety"}]},
"index" => index
},
message_type
)
end

def do_process_response(%{"error" => %{"message" => reason}}, _) do
Logger.error("Received error from API: #{inspect(reason)}")
{:error, reason}
Expand Down

0 comments on commit 6f09ce9

Please sign in to comment.