chore: noise in tests

This commit is contained in:
2026-05-04 06:18:06 +02:00
parent 4de8492c4f
commit 43a4610ce7
48 changed files with 619 additions and 239 deletions

View File

@@ -69,7 +69,9 @@ defmodule BDS.AI.Chat do
{:error, :not_found}
%ChatConversation{} = conversation ->
Repo.delete_all(from message in ChatMessage, where: message.conversation_id == ^conversation_id)
Repo.delete_all(
from message in ChatMessage, where: message.conversation_id == ^conversation_id
)
case Repo.delete(conversation) do
{:ok, _conversation} -> {:ok, :deleted}
@@ -375,7 +377,8 @@ defmodule BDS.AI.Chat do
opts,
@chat_max_tool_rounds
),
{:ok, reply} <- maybe_generate_chat_title(conversation.id, user_message.content, reply, opts) do
{:ok, reply} <-
maybe_generate_chat_title(conversation.id, user_message.content, reply, opts) do
{:ok, reply}
end
end
@@ -425,7 +428,8 @@ defmodule BDS.AI.Chat do
with {:ok, endpoint, model, mode} <- Runtime.resolve_target(:chat_title, opts),
:ok <- Runtime.validate_target(:chat_title, model, mode),
request <- build_chat_title_request(user_content, model),
{:ok, response} <- runtime.generate(Runtime.endpoint_with_model(endpoint, model), request, opts) do
{:ok, response} <-
runtime.generate(Runtime.endpoint_with_model(endpoint, model), request, opts) do
title = sanitize_chat_title(Map.get(response, :content))
if title == "" do

View File

@@ -36,7 +36,9 @@ defmodule BDS.AI.ChatMessage do
:cache_read_tokens,
:cache_write_tokens,
:created_at
], empty_values: [nil])
],
empty_values: [nil]
)
|> validate_required([:conversation_id, :role, :created_at])
|> assoc_constraint(:conversation)
end

View File

@@ -60,7 +60,9 @@ defmodule BDS.AI.Model do
:interleaved,
:status,
:updated_at
], empty_values: [nil])
],
empty_values: [nil]
)
|> validate_required([
:provider,
:model_id,

View File

@@ -211,8 +211,14 @@ defmodule BDS.AI.OneShot do
model: model,
max_output_tokens: @default_max_output_tokens,
messages: [
%{"role" => "system", "content" => one_shot_system_prompt(operation, language, source_language)},
%{"role" => "user", "content" => one_shot_user_content(operation, payload, language, source_language)}
%{
"role" => "system",
"content" => one_shot_system_prompt(operation, language, source_language)
},
%{
"role" => "user",
"content" => one_shot_user_content(operation, payload, language, source_language)
}
]
}
end
@@ -320,7 +326,8 @@ defmodule BDS.AI.OneShot do
[
%{
"type" => "text",
"text" => "Analyze this image and return title, alt text, and caption in #{language_name(language)}."
"text" =>
"Analyze this image and return title, alt text, and caption in #{language_name(language)}."
},
%{"type" => "image_url", "image_url" => %{"url" => media.image_url}}
]
@@ -443,7 +450,11 @@ defmodule BDS.AI.OneShot do
defp resolve_image_data_url(%{image_url: "file://" <> path, mime_type: mime_type} = media) do
with {:ok, binary} <- File.read(path) do
data_url = "data:#{mime_type};base64," <> Base.encode64(binary)
Logger.debug("AI analyze_image converted file://#{path} to data URL (#{byte_size(data_url)} chars)")
Logger.debug(
"AI analyze_image converted file://#{path} to data URL (#{byte_size(data_url)} chars)"
)
{:ok, %{media | image_url: data_url}}
else
{:error, reason} ->
@@ -452,7 +463,9 @@ defmodule BDS.AI.OneShot do
end
end
defp resolve_image_data_url(%{file_path: file_path, project_id: project_id, mime_type: mime_type} = media)
defp resolve_image_data_url(
%{file_path: file_path, project_id: project_id, mime_type: mime_type} = media
)
when is_binary(file_path) and is_binary(project_id) do
case Projects.get_project(project_id) do
nil ->
@@ -465,7 +478,11 @@ defmodule BDS.AI.OneShot do
case File.read(absolute_path) do
{:ok, binary} ->
data_url = "data:#{mime_type};base64," <> Base.encode64(binary)
Logger.debug("AI analyze_image converted #{absolute_path} to data URL (#{byte_size(data_url)} chars)")
Logger.debug(
"AI analyze_image converted #{absolute_path} to data URL (#{byte_size(data_url)} chars)"
)
{:ok, %{media | image_url: data_url}}
{:error, reason} ->

View File

@@ -53,7 +53,7 @@ defmodule BDS.AI.OpenAICompatibleRuntime do
case result do
{:ok, %{json: nil, content: content}} when is_binary(content) ->
Logger.warning(
Logger.debug(
"AI OpenAI-compatible response parsed but content is not valid JSON. Content: #{String.slice(content, 0, 500)}"
)

View File

@@ -39,7 +39,8 @@ defmodule BDS.AI.Runtime do
:ok
capabilities.supports_attachment == false ->
{:error, %{kind: :model_capability_missing, capability: :supports_attachment, model: model}}
{:error,
%{kind: :model_capability_missing, capability: :supports_attachment, model: model}}
true ->
:ok